本文整理汇总了C#中IKernel.GetConversionManager方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.GetConversionManager方法的具体用法?C# IKernel.GetConversionManager怎么用?C# IKernel.GetConversionManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.GetConversionManager方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadProxyBehavior
/// <summary>
/// Reads the proxy behavior associated with the
/// component configuration/type and applies it to the model.
/// </summary>
/// <exception cref="System.Exception">
/// If the conversion fails
/// </exception>
/// <param name="kernel"></param>
/// <param name="model"></param>
protected virtual void ReadProxyBehavior(IKernel kernel, ComponentModel model)
{
ComponentProxyBehaviorAttribute proxyBehaviorAtt = GetProxyBehaviorFromType(model.Implementation);
if (proxyBehaviorAtt == null)
{
proxyBehaviorAtt = new ComponentProxyBehaviorAttribute();
}
string useSingleInterfaceProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["useSingleInterfaceProxy"] : null;
#if !SILVERLIGHT
string marshalByRefProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["marshalByRefProxy"] : null;
#endif
var converter = kernel.GetConversionManager();
if (useSingleInterfaceProxyAttrib != null)
{
#pragma warning disable 0618 //call to obsolete method
proxyBehaviorAtt.UseSingleInterfaceProxy =
converter.PerformConversion<bool?>(useSingleInterfaceProxyAttrib).GetValueOrDefault(false);
#pragma warning restore
}
#if !SILVERLIGHT
if (marshalByRefProxyAttrib != null)
{
proxyBehaviorAtt.UseMarshalByRefProxy =
converter.PerformConversion<bool?>(marshalByRefProxyAttrib).GetValueOrDefault(false);
}
#endif
ApplyProxyBehavior(proxyBehaviorAtt, model);
}
示例2: EnsureConverterInitialized
private void EnsureConverterInitialized(IKernel kernel)
{
if(converter == null)
{
converter = kernel.GetConversionManager();
}
}
示例3: ProcessResource
public override void ProcessResource(IResource source, IConfigurationStore store, IKernel kernel)
{
var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
var processor = new XmlProcessor.XmlProcessor(EnvironmentName, resourceSubSystem);
try
{
var element = processor.Process(source);
var converter = kernel.GetConversionManager();
Deserialize(element, store, converter);
}
catch (XmlProcessorException e)
{
throw new ConfigurationProcessingException("Unable to process xml resource.", e);
}
}
示例4: ProcessModel
public virtual void ProcessModel(IKernel kernel, ComponentModel model)
{
if (converter == null)
{
converter = kernel.GetConversionManager();
}
var targetType = model.Implementation;
var constructors = targetType.GetConstructors(BindingFlags.Public | BindingFlags.Instance);
foreach(var constructor in constructors)
{
// We register each public constructor
// and let the ComponentFactory select an
// eligible amongst the candidates later
model.Constructors.Add(CreateConstructorCandidate(model, constructor));
}
}
示例5: ProcessModel
public void ProcessModel(IKernel kernel, ComponentModel model)
{
if (model.Configuration == null) return;
var interfaces = model.Configuration.Children["additionalInterfaces"];
if (interfaces == null) return;
if(converter == null)
{
converter = kernel.GetConversionManager();
}
var list = new List<Type>();
foreach (var @interface in interfaces.Children
.Where(c => c.Name.Equals("add", StringComparison.InvariantCultureIgnoreCase)))
{
var interfaceTypeName = @interface.Attributes["interface"];
list.Add(converter.PerformConversion<Type>(interfaceTypeName));
}
var options = ProxyUtil.ObtainProxyOptions(model, true);
options.AddAdditionalInterfaces(list.ToArray());
}
示例6: ReadProxyBehavior
/// <summary>
/// Reads the proxy behavior associated with the
/// component configuration/type and applies it to the model.
/// </summary>
/// <exception cref = "System.Exception">
/// If the conversion fails
/// </exception>
/// <param name = "kernel"></param>
/// <param name = "model"></param>
protected virtual void ReadProxyBehavior(IKernel kernel, ComponentModel model)
{
var proxyBehaviorAtt = GetProxyBehaviorFromType(model.Implementation);
if (proxyBehaviorAtt == null)
{
proxyBehaviorAtt = new ComponentProxyBehaviorAttribute();
}
#if !SILVERLIGHT
var marshalByRefProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["marshalByRefProxy"] : null;
#endif
var converter = kernel.GetConversionManager();
#if !SILVERLIGHT
if (marshalByRefProxyAttrib != null)
{
proxyBehaviorAtt.UseMarshalByRefProxy =
converter.PerformConversion<bool?>(marshalByRefProxyAttrib).GetValueOrDefault(false);
}
#endif
ApplyProxyBehavior(proxyBehaviorAtt, model);
}
示例7: ProcessResource
/// <summary>
/// Should obtain the contents from the resource,
/// interpret it and populate the <see cref="T:Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore" />
/// accordingly.
/// </summary>
/// <param name="resource"></param>
/// <param name="store"></param>
/// <param name="kernel"></param>
public override void ProcessResource(IResource resource, IConfigurationStore store, IKernel kernel)
{
PropertiesJsonProcessor processor = new PropertiesJsonProcessor();
processor.Process(resource);
IConversionManager converter = kernel.GetConversionManager();
// setup the properties resolver
Resolver = new PropertyResolver(processor, converter);
m_processResourceCalled = true;
}
示例8: Initialize
/// <summary>
/// Initializes this instance with the specified dependency delegate.
/// </summary>
/// <param name="kernel">kernel</param>
/// <param name = "dependencyDelegate">The dependency delegate.</param>
public void Initialize(IKernel kernel, DependencyDelegate dependencyDelegate)
{
this.kernel = kernel;
converter = kernel.GetConversionManager();
dependencyResolvingDelegate = dependencyDelegate;
}
示例9: ObtainProxyHook
private static IReference<IProxyGenerationHook> ObtainProxyHook(IKernel kernel, IConfiguration config)
{
IProxyGenerationHook hook = null;
if (config != null)
{
var hookAttrib = config.Attributes[Constants.ControlProxyHookAttrib];
if (hookAttrib != null)
{
if (ReferenceExpressionUtil.IsReference(hookAttrib))
{
var hookKey = ReferenceExpressionUtil.ExtractComponentKey(hookAttrib);
return new ComponentReference<IProxyGenerationHook>(hookKey);
}
var converter = kernel.GetConversionManager();
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).Name);
throw new ConfigurationErrorsException(message);
}
hook = (IProxyGenerationHook)Activator.CreateInstance(hookType);
}
}
if (hook == null)
{
hook = SynchronizeProxyHook.Instance;
}
return new InstanceReference<IProxyGenerationHook>(hook);
}
示例10: ProcessResource
/// <summary>
/// Should obtain the contents from the resource,
/// interpret it and populate the <see cref="IConfigurationStore" />
/// accordingly.
/// </summary>
/// <param name="resource">Resource to process</param>
/// <param name="store">Windsor configuration store</param>
/// <param name="kernel">Windsor kernel</param>
public override void ProcessResource(IResource resource, IConfigurationStore store, IKernel kernel)
{
var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
PropertiesXmlProcessor processor = new PropertiesXmlProcessor(EnvironmentName, resourceSubSystem);
IConversionManager converter = kernel.GetConversionManager();
processor.Process(resource);
// setup the properties resolver
m_resolver = new PropertyResolver(processor, converter);
m_processResourceCalled = true;
}