/// <summary>
        /// Registers all the assemblies - looks for ExportService attributes
        /// </summary>
        private void RegisterAssemblyTypes()
        {
            var assemblies = PlatformHelpers.GetAssemblies();

            foreach (var asm in assemblies)
            {
                try
                {
                    var attributes = asm.GetCustomAttributes <ExportServiceAttribute>().ToList();

                    // Look for assembly level attributes.
                    foreach (var att in attributes.Where(a => !a.IsFallback))
                    {
                        Add(att.ContractType, att.ServiceType);
                    }

                    // Register fall back services if no other service is in place.
                    foreach (var att in attributes.Where(a => a.IsFallback))
                    {
                        if (!this.Exists(att.ContractType))
                        {
                            Add(att.ContractType, att.ServiceType);
                        }
                    }
                }
                catch
                {
                    // Skip.
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method uses an internal object to gather the list of ViewModels based
        /// on the ExportViewModel attribute.
        /// </summary>
        /// <returns></returns>
        private void Initialize()
        {
            var assemblies = PlatformHelpers.GetAssemblies();

            foreach (var asm in assemblies)
            {
                foreach (var att in asm.GetCustomAttributes <ExportViewModelAttribute>())
                {
                    Add(att.Key, att.ViewModelType);
                }
            }
        }