本文整理汇总了C#中ITypeConverter.PerformConversion方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeConverter.PerformConversion方法的具体用法?C# ITypeConverter.PerformConversion怎么用?C# ITypeConverter.PerformConversion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeConverter
的用法示例。
在下文中一共展示了ITypeConverter.PerformConversion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFactories
protected virtual void AddFactories(IConfiguration facilityConfig, ITypeConverter converter)
{
if (facilityConfig != null)
{
foreach(IConfiguration config in facilityConfig.Children["factories"].Children)
{
String id = config.Attributes["id"];
String creation = config.Attributes["creation"];
String destruction = config.Attributes["destruction"];
Type factoryType = (Type)
converter.PerformConversion( config.Attributes["interface"], typeof(Type) );
try
{
AddTypedFactoryEntry(
new FactoryEntry(id, factoryType, creation, destruction) );
}
catch(Exception)
{
string message = "Invalid factory entry in configuration";
throw new ConfigurationErrorsException(message);
}
}
}
}
示例2: AddFactories
protected virtual void AddFactories(IConfiguration facilityConfig, ITypeConverter converter)
{
if (facilityConfig != null)
{
foreach (IConfiguration config in facilityConfig.Children["factories"].Children)
{
var id = config.Attributes["id"];
var creation = config.Attributes["creation"];
var destruction = config.Attributes["destruction"];
var factoryType = (Type)converter.PerformConversion(config.Attributes["interface"], typeof(Type));
if(string.IsNullOrEmpty(creation))
{
RegisterFactory(id, factoryType);
continue;
}
RegisterFactoryLegacy(creation, id, factoryType, destruction);
}
}
}
示例3: AddFactories
protected virtual void AddFactories(IConfiguration facilityConfig, ITypeConverter converter)
{
if (facilityConfig == null)
{
return;
}
foreach (var config in facilityConfig.Children["factories"].Children)
{
var id = config.Attributes["id"];
var creation = config.Attributes["creation"];
var destruction = config.Attributes["destruction"];
var factoryType = converter.PerformConversion<Type>(config.Attributes["interface"]);
if (string.IsNullOrEmpty(creation))
{
var selector = config.Attributes["selector"];
RegisterFactory(id, factoryType, selector);
continue;
}
LegacyRegisterFactory(id, factoryType, creation, destruction);
}
}