PageRenderTime 20ms CodeModel.GetById 17ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.MefExtensions/Modularity/MefModuleManager.Desktop.cs

#
C# | 65 lines | 32 code | 5 blank | 28 comment | 2 complexity | 49960553f72a62ebf42bc3ed5c0cefa6 MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System.Collections.Generic;
18using System.ComponentModel.Composition;
19using Microsoft.Practices.Prism.Modularity;
20
21namespace Microsoft.Practices.Prism.MefExtensions.Modularity
22{
23    /// <summary>    
24    /// Component responsible for coordinating the modules' type loading and module initialization process. 
25    /// </summary>
26    /// <remarks>
27    /// This allows the MefBootstrapper to provide this class as a default implementation.
28    /// If another implementation is found, this export will not be used.
29    /// </remarks>
30    public partial class MefModuleManager : ModuleManager, IPartImportsSatisfiedNotification
31    {
32        // disable the warning that the field is never assigned to, and will always have its default value null
33        // as it is imported by MEF
34#pragma warning disable 0649
35        [Import(AllowRecomposition = false)] 
36        private MefFileModuleTypeLoader mefFileModuleTypeLoader;
37#pragma warning restore 0649
38
39        private IEnumerable<IModuleTypeLoader> mefTypeLoaders;
40
41        /// <summary>
42        /// Gets or sets the type loaders used by the module manager.
43        /// </summary>
44        public override IEnumerable<IModuleTypeLoader> ModuleTypeLoaders
45        {
46            get
47            {
48                if (this.mefTypeLoaders == null)
49                {
50                    this.mefTypeLoaders = new List<IModuleTypeLoader>()
51                                              {
52                                                  this.mefFileModuleTypeLoader
53                                              };
54                }
55
56                return this.mefTypeLoaders;
57            }
58
59            set
60            {
61                this.mefTypeLoaders = value;
62            }
63        }
64    }
65}