本文整理汇总了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")));
}
示例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")));
}
示例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>());
}