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


C# ConfigurationExpression.SetAllProperties方法代码示例

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


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

示例1: SetupContainer

 private static void SetupContainer(ConfigurationExpression x)
 {
     x.Scan(i =>
     {
         i.TheCallingAssembly();
         i.Convention<SettingsScanner>();
     });
     x.SetAllProperties(s => s.Matching(p => p.Name.EndsWith("Settings")));
 }
开发者ID:jemacom,项目名称:fubumvc,代码行数:9,代码来源:Global.asax.cs

示例2: SetupContainer

 private static void SetupContainer(ConfigurationExpression x)
 {
     x.For<IHttpSession>().Use<CurrentHttpContextSession>();
     x.Scan(i =>
     {
         i.TheCallingAssembly();
         i.Convention<SettingsScanner>();
     });
     x.For<ISettingsProvider>().Use<AppSettingsProvider>();
     x.SetAllProperties(s => s.Matching(p => p.Name.EndsWith("Settings")));
 }
开发者ID:KevM,项目名称:fubumvc,代码行数:11,代码来源:Global.asax.cs

示例3: Configure

        private void Configure(ConfigurationExpression x)
        {
            if (_useCustomInstances)
            {
                // Config
                x.For<ApplicationSettings>().Singleton().Use(_applicationSettings);

                // Repository
                x.For<IRepository>().HybridHttpOrThreadLocalScoped().Use(_repository);

                // Context
                x.For<IUserContext>().HybridHttpOrThreadLocalScoped().Use(_context);
            }
            else
            {
                //
                // Default repository, or get it from the DataStoreType
                //
                x.For<IRepository>().HybridHttpOrThreadLocalScoped().Use<LightSpeedRepository>();

                if (_applicationSettings.DataStoreType.RequiresCustomRepository)
                {
                    IRepository customRepository = RepositoryManager.LoadRepositoryFromType(_applicationSettings.DataStoreType.CustomRepositoryType);
                    x.For<IRepository>().HybridHttpOrThreadLocalScoped().Use(customRepository);
                }
            }

            //
            // UserService : Windows authentication, custom or the default
            //
            string userServiceTypeName = _applicationSettings.UserServiceType;

            if (_applicationSettings.UseWindowsAuthentication)
            {
            #if !MONO
                x.For<UserServiceBase>().HybridHttpOrThreadLocalScoped().Use<ActiveDirectoryUserService>();
            #endif
            }
            else if (!string.IsNullOrEmpty(userServiceTypeName))
            {
                InstanceRef userServiceRef = ObjectFactory.Model.InstancesOf<UserServiceBase>().FirstOrDefault(t => t.ConcreteType.FullName == userServiceTypeName);
                if (userServiceRef == null)
                {
                    var instances = ObjectFactory.Model.InstancesOf<UserServiceBase>();
                    string debugMessage = string.Join(Environment.NewLine, instances.Select(t => t.ConcreteType.FullName).ToArray());
                    throw new ConfigurationException(null, "Unable to find custom user service type '{0}' - I only have these types: \n\n{1}", userServiceTypeName, debugMessage);
                }

                x.For<UserServiceBase>().HybridHttpOrThreadLocalScoped().TheDefault.Is.OfConcreteType(userServiceRef.ConcreteType);
            }
            else
            {
                x.For<UserServiceBase>().HybridHttpOrThreadLocalScoped().Use<FormsAuthUserService>();
            }

            // IFileService : Local or Azure or Custom
            if (_applicationSettings.UseAzureFileStorage)
            {
                x.For<IFileService>().HybridHttpOrThreadLocalScoped().Use<AzureFileService>();
            }
            else
            {
                x.For<IFileService>().HybridHttpOrThreadLocalScoped().Use<LocalFileService>();
            }

            x.For<IPageService>().HybridHttpOrThreadLocalScoped().Use<PageService>();

            // Setter inject the various MVC objects that can't have constructors
            x.SetAllProperties(y => y.OfType<ISetterInjected>());
            x.SetAllProperties(y => y.OfType<IAuthorizationAttribute>());
            x.SetAllProperties(y => y.TypeMatches(t => t == typeof(RoadkillViewPage<>)));
            x.SetAllProperties(y => y.TypeMatches(t => t == typeof(RoadkillLayoutPage)));

            // Setter inject the *internal* properties for the text plugins
            x.For<TextPlugin>().OnCreationForAll((ctx, plugin) => plugin.PluginCache = ctx.GetInstance<IPluginCache>());
            x.For<TextPlugin>().OnCreationForAll((ctx, plugin) => plugin.Repository = ctx.GetInstance<IRepository>());
        }
开发者ID:Khamull,项目名称:roadkill,代码行数:77,代码来源:DependencyManager.cs


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