本文整理汇总了C#中IKernel.GetSubSystem方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.GetSubSystem方法的具体用法?C# IKernel.GetSubSystem怎么用?C# IKernel.GetSubSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.GetSubSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RelativePathSubDependencyResolver
/// <summary>
/// Constructor
/// </summary>
public RelativePathSubDependencyResolver(IKernel kernel)
{
m_converter = (IConversionManager)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
SettingsSubSystem settingsSubSystem = kernel.GetSettingsSubSystem();
settingsSubSystem.ResolveRelativePaths = true;
VALUES = new Dictionary<string, object>();
}
示例2: KernelDebuggerProxy
public KernelDebuggerProxy(IKernel kernel)
{
if (kernel == null)
{
throw new ArgumentNullException("kernel");
}
extensions = (IEnumerable<IContainerDebuggerExtension>)(kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey) as IContainerDebuggerExtensionHost) ??
new IContainerDebuggerExtension[0];
}
示例3: KernelDebuggerProxy
public KernelDebuggerProxy(IKernel kernel)
{
if (kernel == null)
{
throw new ArgumentNullException("kernel");
}
this.kernel = kernel;
naming = kernel.GetSubSystem(SubSystemConstants.NamingKey) as INamingSubSystem;
}
示例4: GetScopeSubSystem
private static IScopeManager GetScopeSubSystem(IKernel kernel)
{
var scopes = (IScopeManager)kernel.GetSubSystem("scope");
if (scopes == null)
{
throw new InvalidCastException("Unable to obtain the ScopeSubsystem. " +
"Did you forget to add it using the key 'scope'?");
}
return scopes;
}
示例5: ProcessModel
/// <summary>
/// Adds the properties as optional dependencies of this component.
/// </summary>
/// <param name="kernel"></param>
/// <param name="model"></param>
public virtual void ProcessModel(IKernel kernel, ComponentModel model)
{
if (converter == null)
{
converter = (IConversionManager)
kernel.GetSubSystem( SubSystemConstants.ConversionManagerKey );
}
InspectProperties(model);
}
示例6: Init
public override void Init(IComponentActivator componentActivator, IKernel kernel, ComponentModel model)
{
base.Init(componentActivator, kernel, model);
manager = kernel.GetSubSystem("scope") as IScopeManager;
if (manager == null)
{
throw new InvalidOperationException("Scope Subsystem not found. Did you forget to add it?");
}
}
示例7: 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);
}
}
示例8: ProcessModel
public virtual void ProcessModel(IKernel kernel, ComponentModel model)
{
if (converter == null) {
converter = (IConversionManager) kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
}
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));
}
}
示例9: ProcessModel
public void ProcessModel(IKernel kernel, ComponentModel model)
{
if (model.Configuration != null)
{
String manageableProxy = model.Configuration.Attributes["manageableProxy"];
if (manageableProxy == null) return;
ITypeConverter converter = (ITypeConverter)
kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
if ((bool)converter.PerformConversion(manageableProxy, typeof (bool)))
{
// model.Interceptors.Add();
}
}
}
示例10: ReadProxyBehavior
/// <summary>
/// Reads the proxy behavior associated with the
/// component configuration/type and applies it to the model.
/// </summary>
/// <exception cref="System.Configuration.ConfigurationException">
/// 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;
string marshalByRefProxyAttrib = model.Configuration != null ? model.Configuration.Attributes["marshalByRefProxy"] : null;
ITypeConverter converter = (ITypeConverter)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
if (useSingleInterfaceProxyAttrib != null)
{
try
{
proxyBehaviorAtt.UseSingleInterfaceProxy = (bool)
converter.PerformConversion(useSingleInterfaceProxyAttrib, typeof(bool));
}
catch(ConverterException ex)
{
throw new ConfigurationErrorsException("Could not convert attribute " +
"'useSingleInterfaceProxy' to bool. Value is " + useSingleInterfaceProxyAttrib, ex);
}
}
if (marshalByRefProxyAttrib != null)
{
try
{
proxyBehaviorAtt.UseMarshalByRefProxy = (bool)
converter.PerformConversion(marshalByRefProxyAttrib, typeof(bool));
}
catch(ConverterException ex)
{
throw new ConfigurationErrorsException("Could not convert attribute " +
"'marshalByRefProxy' to bool. Value is " + marshalByRefProxyAttrib, ex);
}
}
ApplyProxyBehavior(proxyBehaviorAtt, model);
}
示例11: 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
ITypeConverter converter = (ITypeConverter)kernel.GetSubSystem(SubSystemConstants.ConversionManagerKey);
if (useSingleInterfaceProxyAttrib != null)
{
try
{
proxyBehaviorAtt.UseSingleInterfaceProxy = converter.PerformConversion<bool>(useSingleInterfaceProxyAttrib);
}
catch(ConverterException ex)
{
throw new Exception(string.Format("Could not convert attribute 'useSingleInterfaceProxy' to bool. Value is '{0}'.", useSingleInterfaceProxyAttrib), ex);
}
}
#if !SILVERLIGHT
if (marshalByRefProxyAttrib != null)
{
try
{
proxyBehaviorAtt.UseMarshalByRefProxy = converter.PerformConversion<bool>(marshalByRefProxyAttrib);
}
catch(ConverterException ex)
{
throw new Exception(string.Format("Could not convert attribute 'marshalByRefProxy' to bool. Value is '{0}'.", marshalByRefProxyAttrib), ex);
}
}
#endif
ApplyProxyBehavior(proxyBehaviorAtt, model);
}
示例12: BuildMap
private void BuildMap(Dictionary<Type, IHandler> map, IKernel currentKernel)
{
var defaults = currentKernel.GetSubSystem(SubSystemConstants.NamingKey) as IExposeDefaultComponentsForServices;
if (defaults != null)
{
foreach (var @default in defaults.GetDefaultComponentsForServices())
{
if (map.ContainsKey(@default.Key))
{
continue;
}
map.Add(@default.Key, @default.Value);
}
}
var parentKernel = currentKernel.Parent;
if (parentKernel != null)
{
BuildMap(map, parentKernel);
}
}
示例13: ConfigureComponentModel
/// <summary>
/// Contribute to component model after standard <see cref="IContributeComponentModelConstruction" /> run.
/// </summary>
/// <param name="kernel"></param>
/// <param name="model"></param>
public void ConfigureComponentModel(IKernel kernel, ComponentModel model)
{
PropertiesSubSystem subsystem = kernel.GetSubSystem<PropertiesSubSystem>(PropertiesSubSystem.SubSystemKey);
foreach (var prop in m_properties)
{
if (!subsystem.Resolver.CanResolve(prop.ConfigPropertyName))
throw new ConfigurationProcessingException("No config property with name '" + prop.ConfigPropertyName + "' found");
string propKey = m_implPropertyTypes.Keys.FirstOrDefault(f => f.Equals(prop.Name, StringComparison.OrdinalIgnoreCase));
if (string.IsNullOrWhiteSpace(propKey))
throw new ConfigurationProcessingException("No public property with a similar to name '" + prop.Name + "' found on " + model.Implementation.FullName);
Type propType = m_implPropertyTypes[propKey];
object value = subsystem.Resolver.GetValue(prop.ConfigPropertyName, propType);
model.CustomDependencies[propKey] = value;
}
}
示例14: IsCacheModelOn
private bool IsCacheModelOn(IKernel kernel, ComponentModel model)
{
IConversionManager converter = kernel.GetSubSystem( SubSystemConstants.ConversionManagerKey ) as IConversionManager;
bool allowCache = false;
if (model.Configuration != null)
{
String enableInterceptionAttribute = model.Configuration.Attributes["Cache"];
if (enableInterceptionAttribute != null)
{
allowCache = (bool) converter.PerformConversion( enableInterceptionAttribute, typeof(bool) );
}
}
if ( model.Implementation.IsDefined( typeof(CacheAttribute), true ) )
{
allowCache = true;
}
return allowCache;
}
示例15: GetTrackedComponentsDiagnostic
public static ITrackedComponentsDiagnostic GetTrackedComponentsDiagnostic(IKernel kernel)
{
var diagnosticsHost = (IDiagnosticsHost)kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
return diagnosticsHost.GetDiagnostic<ITrackedComponentsDiagnostic>();
}