当前位置: 首页>>代码示例>>C#>>正文


C# IServiceLocator.GetAllInstances方法代码示例

本文整理汇总了C#中IServiceLocator.GetAllInstances方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.GetAllInstances方法的具体用法?C# IServiceLocator.GetAllInstances怎么用?C# IServiceLocator.GetAllInstances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceLocator的用法示例。


在下文中一共展示了IServiceLocator.GetAllInstances方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteCore

        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        protected override void ExecuteCore(IServiceLocator serviceLocator)
        {
            IEnumerable<IModelMetadataConfiguration> configurations = serviceLocator.GetAllInstances<IModelMetadataConfiguration>();

            IModelMetadataRegistry registry = serviceLocator.GetInstance<IModelMetadataRegistry>();

            configurations.Each(configuration => registry.Register(configuration.ModelType, configuration.Configurations));

            ModelMetadataProviders.Current = serviceLocator.GetInstance<CompositeModelMetadataProvider>();

            // We have to make sure that custom provider will appear first,
            // otherwise it will return wrong validation messages.
            serviceLocator.GetAllInstances<ModelValidatorProvider>()
                          .Each(provider => ModelValidatorProviders.Providers.Insert(0, provider));
        }
开发者ID:GTuritto,项目名称:AspNetMvcExtensibility,代码行数:19,代码来源:RegisterModelMetadata.cs

示例2: DataProviderViewModel

 public DataProviderViewModel(ExperimentViewModel experimentViewModel, IServiceLocator serviceLocator)
 {
     this.serviceLocator = serviceLocator;
     _experimentViewModel = experimentViewModel;
     ViewModel = experimentViewModel;
     dataProviders = serviceLocator.GetAllInstances<IDataProvider>().ToList();
     selectedDataProvider = dataProviders.First();
 }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:8,代码来源:DataProviderViewModel.cs

示例3: DocumentManager

 public DocumentManager(IEventAggregator eventAggregator, IServiceLocator serviceLocator)
 {
     Save = new DelegateCommand<string>(OnSave, CanSave);
     Close = new DelegateCommand<string>(OnClose, CanClose);
     New = new DelegateCommand<string>(OnNew, CanNew);
     _experiments = new List<ExperimentBase>();
     _eventAggregator = eventAggregator;
     _serviceLocator = serviceLocator;
     _experimentTypes = _serviceLocator.GetAllInstances<IExperimentType>();
 }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:10,代码来源:DocumentManager.cs

示例4: ConvertExperimentReferencesToExperiments

 public static void ConvertExperimentReferencesToExperiments(ProjectBase project, IServiceLocator serviceLocator)
 {
     project.Experiments.Clear();
     IEnumerable<IExperimentType> experimentTypes = serviceLocator.GetAllInstances<IExperimentType>();
     foreach (MassSpecStudio.Core.Domain.ProjectBase.ExperimentReference experimentReference in project.ExperimentReferences)
     {
         IExperimentType experimentType = experimentTypes.Where(item => item.ExperimentType == experimentReference.ExperimentType).FirstOrDefault();
         project.Experiments.Add(new Experiment(experimentReference.Name, project, experimentType));
     }
 }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:10,代码来源:CreateProjectHelper.cs

示例5: ExecuteCore

        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        protected override void ExecuteCore(IServiceLocator serviceLocator)
        {
            IEnumerable<Type> viewEngineTypes = ViewEngines.Select(ve => ve.GetType());

            serviceLocator.GetAllInstances<IViewEngine>()
                          .Each(engine =>
                                  {
                                      if (!viewEngineTypes.Any(type => type == engine.GetType()))
                                      {
                                          ViewEngines.Add(engine);
                                      }
                                  });
        }
开发者ID:GTuritto,项目名称:AspNetMvcExtensibility,代码行数:17,代码来源:RegisterViewEngines.cs

示例6: ExecuteCore

 /// <summary>
 /// Executes the task.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 protected override void ExecuteCore(IServiceLocator serviceLocator)
 {
     serviceLocator.GetAllInstances<IModelBinder>()
                   .Select(binder => new
                                  {
                                      Binder = binder,
                                      Types = binder.GetType()
                                                    .GetCustomAttributes(KnownTypes.BindingAttributeType, true)
                                                    .OfType<BindingTypesAttribute>()
                                                    .SelectMany(attribute => attribute.Types)
                                  })
                    .Each(pair => pair.Types.Each(type =>
                                                  {
                                                      if (!Binders.ContainsKey(type))
                                                      {
                                                          Binders.Add(type, pair.Binder);
                                                      }
                                                  }));
 }
开发者ID:GTuritto,项目名称:AspNetMvcExtensibility,代码行数:23,代码来源:RegisterModelBinders.cs

示例7: NewProjectViewModel

        public NewProjectViewModel(IEventAggregator eventAggregator, IServiceLocator serviceLocator)
        {
            _eventAggregator = eventAggregator;
            _experimentTypes = serviceLocator.GetAllInstances<IExperimentType>();
            _documentManager = serviceLocator.GetInstance<IDocumentManager>();

            _recentLocations = Properties.Settings.Default.RecentLocations.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries);

            _selectedExperimentType = _experimentTypes.Where(type => type.Name == Properties.Settings.Default.LastSelectedExperimentType).FirstOrDefault();
            _selectedExperimentType = _selectedExperimentType ?? _experimentTypes.First();

            if (string.IsNullOrEmpty(Properties.Settings.Default.LastBrowseLocation))
            {
                string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                Properties.Settings.Default.LastBrowseLocation = Path.Combine(documents, "Mass Spec Studio Projects");
            }
            _location = Properties.Settings.Default.LastBrowseLocation;
            _projectName = GetNextDirectoryName(_location, _selectedExperimentType.Name + "Project");
            _experimentName = _selectedExperimentType.Name + "Experiment";
        }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:20,代码来源:NewProjectViewModel.cs

示例8: Open

        public static Experiment Open(string path, ProjectBase parentProject, IServiceLocator serviceLocator)
        {
            DataContractSerializer serializer = new DataContractSerializer(typeof(Experiment));
            using (XmlReader stream = XmlReader.Create(path))
            {
                Experiment experiment = serializer.ReadObject(stream, true) as Experiment;
                experiment.Project = parentProject;
                if (parentProject == null)
                {
                    string directory = Path.GetDirectoryName(path);
                    experiment.Peptides = Peptides.Open(Path.Combine(directory, experiment.PeptidesFileLocation));
                }
                else
                {
                    experiment.Peptides = Peptides.Open(Path.Combine(experiment.Directory, experiment.PeptidesFileLocation));
                }
                if (parentProject != null)
                {
                    experiment.Results = Result.OpenDirectory(experiment);
                }
                IDataProvider dataProvider = serviceLocator.GetAllInstances<IDataProvider>().Where(item => item.TypeId == experiment.DataProviderType).FirstOrDefault();
                if (dataProvider == null)
                {
                    throw new Exception("Data provider specified in this experiment was not found.");
                }

                experiment.DataProvider = dataProvider;
                foreach (Run run in experiment.Runs)
                {
                    run.Experiment = experiment;
                }
                return experiment;
            }
        }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:34,代码来源:Experiment.cs


注:本文中的IServiceLocator.GetAllInstances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。