本文整理汇总了C#中IConversionManager.PerformConversion方法的典型用法代码示例。如果您正苦于以下问题:C# IConversionManager.PerformConversion方法的具体用法?C# IConversionManager.PerformConversion怎么用?C# IConversionManager.PerformConversion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConversionManager
的用法示例。
在下文中一共展示了IConversionManager.PerformConversion方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddInstaller
private void AddInstaller(IConfiguration installer, Dictionary<Type, IWindsorInstaller> cache,
IConversionManager conversionManager, ICollection<Assembly> assemblies)
{
var typeName = installer.Attributes["type"];
if (string.IsNullOrEmpty(typeName) == false)
{
var type = conversionManager.PerformConversion<Type>(typeName);
AddInstaller(cache, type);
return;
}
assemblyName = installer.Attributes["assembly"];
if (string.IsNullOrEmpty(assemblyName) == false)
{
var assembly = ReflectionUtil.GetAssemblyNamed(assemblyName);
if (assemblies.Contains(assembly))
{
return;
}
assemblies.Add(assembly);
GetAssemblyInstallers(cache, assembly);
return;
}
#if !SILVERLIGHT
var directory = installer.Attributes["directory"];
var mask = installer.Attributes["fileMask"];
var token = installer.Attributes["publicKeyToken"];
Debug.Assert(directory != null, "directory != null");
var assemblyFilter = new AssemblyFilter(directory, mask);
if (token != null)
{
assemblyFilter.WithKeyToken(token);
}
foreach (var assembly in ReflectionUtil.GetAssemblies(assemblyFilter))
{
if (assemblies.Contains(assembly))
{
continue;
}
assemblies.Add(assembly);
GetAssemblyInstallers(cache, assembly);
}
#endif
}
示例2: AddInstaller
private void AddInstaller(IConfiguration installer, Dictionary<Type, IWindsorInstaller> cache, IConversionManager conversionManager)
{
var typeName = installer.Attributes["type"];
if (string.IsNullOrEmpty(typeName) == false)
{
var type = conversionManager.PerformConversion(typeName, typeof(Type)) as Type;
AddInstaller(cache, type);
return;
}
Debug.Assert(string.IsNullOrEmpty(installer.Attributes["assembly"]) == false);
var types = Assembly.Load(installer.Attributes["assembly"]).GetExportedTypes();
foreach (var type in InstallerTypes(types))
{
AddInstaller(cache, type);
}
}
示例3: CollectForwardedTypes
private void CollectForwardedTypes(IKernelInternal kernel, IConfiguration component, string typeName, string id,
IConversionManager converter, List<Type> services)
{
if (kernel == null)
{
return;
}
var forwardedTypes = component.Children["forwardedTypes"];
if (forwardedTypes == null)
{
return;
}
foreach (var forwardedType in forwardedTypes.Children
.Where(c => c.Name.Trim().Equals("add", StringComparison.InvariantCultureIgnoreCase)))
{
var forwardedServiceTypeName = forwardedType.Attributes["service"];
try
{
services.Add(converter.PerformConversion<Type>(forwardedServiceTypeName));
}
catch (Exception e)
{
throw new Exception(
string.Format("Component {0}-{1} defines invalid forwarded type.", id ?? string.Empty, typeName), e);
}
}
}
示例4: SetUpComponents
protected virtual void SetUpComponents(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
{
foreach (var component in configurations)
{
var id = component.Attributes["id"];
var typeName = component.Attributes["type"];
var serviceTypeName = component.Attributes["service"];
if (string.IsNullOrEmpty(typeName))
{
continue;
}
var type = converter.PerformConversion<Type>(typeName);
var service = type;
if (!string.IsNullOrEmpty(serviceTypeName))
{
service = converter.PerformConversion<Type>(serviceTypeName);
}
AssertImplementsService(id, service, type);
Debug.Assert(id != null);
Debug.Assert(type != null);
Debug.Assert(service != null);
var services = new List<Type> { service };
CollectForwardedTypes(container.Kernel as IKernelInternal, component, typeName, id, converter, services);
var registration = Component.For(services).ImplementedBy(type);
if (component.Attributes["id-automatic"] == true.ToString())
{
container.Register(registration.NamedAutomatically(id));
}
else
{
container.Register(registration.Named(id));
}
}
}
示例5: SetUpFacilities
protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter)
{
foreach (var facility in configurations)
{
var type = converter.PerformConversion<Type>(facility.Attributes["type"]);
var facilityInstance = type.CreateInstance<IFacility>();
Debug.Assert(facilityInstance != null);
container.AddFacility(facilityInstance);
}
}
示例6: CollectAdditionalServices
private void CollectAdditionalServices(IConfiguration component, IConversionManager converter, ICollection<Type> services)
{
var forwardedTypes = component.Children["forwardedTypes"];
if (forwardedTypes == null)
{
return;
}
foreach (var forwardedType in forwardedTypes.Children)
{
var forwardedServiceTypeName = forwardedType.Attributes["service"];
try
{
services.Add(converter.PerformConversion<Type>(forwardedServiceTypeName));
}
catch (ConverterException e)
{
throw new ComponentRegistrationException(
string.Format("Component {0} defines invalid forwarded type.", component.Attributes["id"]), e);
}
}
}
示例7: GetType
private Type GetType(IConversionManager converter, string typeName)
{
if (typeName == null)
{
return null;
}
return converter.PerformConversion<Type>(typeName);
}
示例8: ObtainProxyHook
private static IReference<IProxyGenerationHook> ObtainProxyHook(IConfiguration config, IConversionManager converter)
{
IProxyGenerationHook hook = null;
if (config != null)
{
var hookAttrib = config.Attributes[Constants.ControlProxyHookAttrib];
if (hookAttrib != null)
{
var hookComponent = ReferenceExpressionUtil.ExtractComponentName(hookAttrib);
if (hookComponent != null)
{
return new ComponentReference<IProxyGenerationHook>(hookComponent);
}
var hookType = converter.PerformConversion<Type>(hookAttrib);
if (hookType.Is<IProxyGenerationHook>() == false)
{
var message = String.Format("The specified controlProxyHook does " +
"not implement the interface {1}. Type {0}",
hookType.FullName, typeof(IProxyGenerationHook).FullName);
throw new ConfigurationErrorsException(message);
}
hook = hookType.CreateInstance<IProxyGenerationHook>();
}
}
if (hook == null)
{
hook = SynchronizeProxyHook.Instance;
}
return new InstanceReference<IProxyGenerationHook>(hook);
}
示例9: SetUpComponents
protected virtual void SetUpComponents(IConfiguration[] configurations, IWindsorContainer container,
IConversionManager converter)
{
foreach (IConfiguration component in configurations)
{
var id = component.Attributes["id"];
var typeName = component.Attributes["type"];
var serviceTypeName = component.Attributes["service"];
if (string.IsNullOrEmpty(typeName))
{
continue;
}
var type = converter.PerformConversion<Type>(typeName);
var service = type;
if (!string.IsNullOrEmpty(serviceTypeName))
{
service = converter.PerformConversion<Type>(serviceTypeName);
}
AssertImplementsService(id, service, type);
Debug.Assert(id != null);
Debug.Assert(type != null);
Debug.Assert(service != null);
container.Register(Component.For(service).ImplementedBy(type).Named(id));
SetUpComponentForwardedTypes(container.Kernel as IKernelInternal, component, typeName, id, converter);
}
}
示例10: SetUpFacilities
protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container,
IConversionManager converter)
{
foreach (IConfiguration facility in configurations)
{
var id = facility.Attributes["id"];
var typeName = facility.Attributes["type"];
if (string.IsNullOrEmpty(typeName))
{
continue;
}
var type = converter.PerformConversion<Type>(typeName);
var facilityInstance = ReflectionUtil.CreateInstance<IFacility>(type);
Debug.Assert(id != null);
Debug.Assert(facilityInstance != null);
container.AddFacility(id, facilityInstance);
}
}
示例11: ObtainType
private static Type ObtainType(String typeName, IConversionManager converter)
{
return (Type)converter.PerformConversion(typeName, typeof(Type));
}
示例12: DeserializeComponent
private static void DeserializeComponent(XmlNode node, IConfigurationStore store, IConversionManager converter)
{
var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
var id = config.Attributes["id"];
if(string.IsNullOrEmpty(id))
{
var type = converter.PerformConversion<Type>(config.Attributes["type"]);
id = type.FullName;
config.Attributes["id"] = id;
config.Attributes.Add("id-automatic", true.ToString());
}
AddComponentConfig(id, config, store);
}
示例13: DeserializeFacility
private static void DeserializeFacility(XmlNode node, IConfigurationStore store, IConversionManager converter)
{
var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
var typeName = GetRequiredAttributeValue(config, "type");
var type = converter.PerformConversion<Type>(typeName);
AddFacilityConfig(type.FullName, config, store);
}