本文整理汇总了C#中IContainer.RegisterComponentSettings方法的典型用法代码示例。如果您正苦于以下问题:C# IContainer.RegisterComponentSettings方法的具体用法?C# IContainer.RegisterComponentSettings怎么用?C# IContainer.RegisterComponentSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContainer
的用法示例。
在下文中一共展示了IContainer.RegisterComponentSettings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallProvider
private void InstallProvider(IContainer container, Provider provider)
{
if (provider != null)
{
Type type = System.Web.Compilation.BuildManager.GetType(provider.Type, false, true);
if (type == null)
{
throw new ConfigurationErrorsException(string.Format("Could not load provider {0}", provider.Type));
}
container.RegisterComponent(provider.Name, _ProviderInterface, type, _ComponentLifeStyle);
Dictionary<string, string> settingsDict = new Dictionary<string, string>();
settingsDict.Add("providerName", provider.Name);
foreach (string key in provider.Attributes.Keys)
{
settingsDict.Add(key, provider.Attributes.Get(key));
}
container.RegisterComponentSettings(type.FullName, settingsDict);
}
}
示例2: InstallProvider
private void InstallProvider(IContainer container, Provider provider)
{
if (provider != null)
{
Type type = null;
//Get the provider type
try
{
type = BuildManager.GetType(provider.Type, false, true);
}
catch (TypeLoadException)
{
if (_defaultProvider != null)
{
type = _defaultProvider;
}
}
if (type == null)
{
Logger.Error(new ConfigurationErrorsException(string.Format("Could not load provider {0}", provider.Type)));
}
else
{
//Register the component
container.RegisterComponent(provider.Name, _ProviderInterface, type, _ComponentLifeStyle);
//Load the settings into a dictionary
var settingsDict = new Dictionary<string, string> { { "providerName", provider.Name } };
foreach (string key in provider.Attributes.Keys)
{
settingsDict.Add(key, provider.Attributes.Get(key));
}
//Register the settings as dependencies
container.RegisterComponentSettings(type.FullName, settingsDict);
}
}
}