本文整理汇总了C#中ISubDependencyResolver类的典型用法代码示例。如果您正苦于以下问题:C# ISubDependencyResolver类的具体用法?C# ISubDependencyResolver怎么用?C# ISubDependencyResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISubDependencyResolver类属于命名空间,在下文中一共展示了ISubDependencyResolver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanResolve
/// <summary>
/// Returns true if the resolver is able to satisfy the specified dependency.
/// </summary>
/// <param name = "context">Creation context, which is a resolver itself</param>
/// <param name = "contextHandlerResolver">Parent resolver</param>
/// <param name = "model">Model of the component that is requesting the dependency</param>
/// <param name = "dependency">The dependency model</param>
/// <returns>
/// <c>true</c>
/// if the dependency can be satisfied</returns>
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
// 1 - check for the dependency on CreationContext, if present
if (CanResolveFromContext(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 2 - check with the model's handler, if not the same as the parent resolver
if (CanResolveFromHandler(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 3 - check within parent resolver, if present
if (CanResolveFromContextHandlerResolver(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 4 - check within subresolvers
if (CanResolveFromSubResolvers(context, contextHandlerResolver, model, dependency))
{
return true;
}
// 5 - normal flow, checking against the kernel
return CanResolveFromKernel(context, model, dependency);
}
开发者ID:jmuralimohanbabu,项目名称:Castle.Windsor,代码行数:39,代码来源:DefaultDependencyResolver.cs
示例2: Resolve
public object Resolve(
CreationContext context,
ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
MockingStrategy strategy = _relatedRepository.GetStrategyFor(dependency);
if (strategy.Instance != null)
return strategy.Instance;
if (strategy.Mock == MockingStrategyType.Mock)
{
//if a dependencywas already registered in the main controller, go and use it
var registration = this._relatedRepository.Kernel.GetHandler(dependency.TargetType);
object resolvedDependencyObject;
if (registration == null)
{
resolvedDependencyObject = MockRepository.GenerateStub(dependency.TargetType);
}
else
{
resolvedDependencyObject = _relatedRepository.Resolve(dependency.TargetType);
}
_relatedRepository.OnMockCreated(resolvedDependencyObject, dependency.DependencyKey);
return resolvedDependencyObject;
}
if (strategy.Mock == MockingStrategyType.Resolve)
return _relatedRepository.Resolve(dependency.TargetType);
return null;
}
开发者ID:alkampfergit,项目名称:ShuppanButsu,代码行数:31,代码来源:AutoMockingDependencyResolver.cs
示例3: Resolve
public object Resolve(CreationContext context, ISubDependencyResolver parentResolver, ComponentModel model,
DependencyModel dependency)
{
if (dependency.TargetType == typeof (ISession))
return SessionFactory.OpenSession();
return SessionFactory.OpenStatelessSession();
}
开发者ID:brumschlag,项目名称:rhino-tools,代码行数:7,代码来源:SessionResolver.cs
示例4: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
return dependency.TargetType != null &&
dependency.TargetType.IsArray &&
dependency.TargetType.GetElementType().IsInterface &&
!model.Parameters.Contains(dependency.DependencyKey);
}
开发者ID:Slesa,项目名称:Playground,代码行数:7,代码来源:ArraySubDependencyResolver.cs
示例5: Resolve
public object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
{
string componentName = null;
if (!_knownDependencies.ContainsKey(dependency))
componentName = dependency.DependencyKey;
return _kernel.Resolve(componentName, dependency.TargetType);
}
开发者ID:gan123,项目名称:RightRecruit,代码行数:7,代码来源:ConventionBasedResolver.cs
示例6: Resolve
public object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model,
DependencyModel dependency)
{
return contextHandlerResolver.Resolve(context, contextHandlerResolver, model,
new DependencyModel(DependencyType.Service, typeof(IBookStore).FullName,
typeof(IBookStore), false));
}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:SubResolversShouldNotBeTrustedToBeCorrect.cs
示例7: CanResolve
/// <inheritdoc />
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, DependencyModel dependency)
{
if (dependency.TargetType == null)
{
return false;
}
Type genericArgument = null;
if ((dependency.TargetType.IsGenericType) && (dependency.TargetType.GetGenericTypeDefinition() == typeof(IEnumerable<>)))
{
genericArgument = dependency.TargetType.GetGenericArguments()[0];
}
else
{
dependency.TargetType.GetInterfaces().Any(implemented => (implemented.IsGenericType) && (implemented.GetGenericTypeDefinition() == typeof(IEnumerable<>)) &&
((genericArgument = implemented.GetGenericArguments()[0]) != null));
}
if ((genericArgument == null) || (!_kernel.HasComponent(genericArgument)))
{
return false;
}
return true;
}
开发者ID:alien-mcl,项目名称:URSA,代码行数:26,代码来源:AutoClosingCollectionResolver.cs
示例8: Resolve
public object Resolve(CreationContext context, ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
Type t = dependency.TargetType.GetGenericArguments()[0];
return kernel.ResolveAll(t, null);
}
开发者ID:emmekappa,项目名称:horn_src,代码行数:7,代码来源:EnumerableResolver.cs
示例9: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model,
DependencyModel dependency)
{
return dependency.TargetType == typeof(IBookStore) && contextHandlerResolver.CanResolve(context, contextHandlerResolver, model,
new DependencyModel(typeof(IBookStore).FullName,
typeof(IBookStore), false));
}
开发者ID:dohansen,项目名称:Windsor,代码行数:7,代码来源:GoodDependencyResolver.cs
示例10: Resolve
public object Resolve(CreationContext context, ISubDependencyResolver parentResolver, ComponentModel model,
DependencyModel dependency)
{
Type elementType = dependency.TargetType.GetElementType();
Array all = kernel.ResolveAll(elementType, new Hashtable());
return all;
}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:7,代码来源:ArrayOfComponentsResolver.cs
示例11: Resolve
public object Resolve(CreationContext context,
ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
return _kernel.ResolveAll(dependency.TargetType.GetElementType(), null);
}
开发者ID:agross,项目名称:fizzbuzz,代码行数:7,代码来源:ArraySubDependencyResolver.cs
示例12: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver parentResolver, ComponentModel model,
DependencyModel dependency)
{
return Context.CurrentUser != null &&
dependency.TargetType == typeof (INotifications);
}
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:7,代码来源:NotificationResolver.cs
示例13: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
return dependency.TargetType != null &&
dependency.TargetType.IsArray &&
dependency.TargetType.GetElementType().IsInterface;
}
开发者ID:somlea-george,项目名称:sutekishop,代码行数:8,代码来源:ArrayResolver.cs
示例14: Resolve
public override object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver,
ComponentModel model,
DependencyModel dependency)
{
var items = base.Resolve(context, contextHandlerResolver, model, dependency);
var listType = BuildListType(dependency);
return listType.CreateInstance<object>(items);
}
开发者ID:pmcg,项目名称:Castle.Windsor,代码行数:8,代码来源:ListResolver.cs
示例15: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver,
ComponentModel model,
DependencyModel dependency)
{
return dependency.TargetType != null &&
dependency.TargetType.IsArray &&
kernel.HasComponent(dependency.TargetType.GetElementType());
}
开发者ID:Huddle,项目名称:Castle.Windsor,代码行数:8,代码来源:ArrayResolver.cs
示例16: CanResolve
public bool CanResolve(
CreationContext context,
ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency )
{
return dependency.DependencyType == DependencyType.Service;
}
开发者ID:aozora,项目名称:arashi,代码行数:8,代码来源:AutoMockingDependencyResolver.cs
示例17: ParentHandlerWithChildResolver
/// <summary>
/// Initializes a new instance of the <see cref="ParentHandlerWithChildResolver"/> class.
/// </summary>
/// <param name="parentHandler">The parent handler.</param>
/// <param name="childResolver">The child resolver.</param>
public ParentHandlerWithChildResolver(IHandler parentHandler, ISubDependencyResolver childResolver)
{
if (parentHandler == null) throw new ArgumentNullException("parentHandler");
if (childResolver == null) throw new ArgumentNullException("childResolver");
this.parentHandler = parentHandler;
parentHandler.OnHandlerStateChanged += new HandlerStateDelegate(RaiseHandlerStateChanged);
this.childResolver = childResolver;
}
开发者ID:ralescano,项目名称:castle,代码行数:14,代码来源:ParentHandlerWithChildResolver.cs
示例18: CanResolve
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver,
ComponentModel model,
DependencyModel dependency)
{
var targetType = dependency.TargetItemType;
return targetType != null &&
targetType.IsArray &&
(allowEmptyArray || kernel.HasComponent(targetType.GetElementType()));
}
开发者ID:simonlaroche,项目名称:Castle.InversionOfControl,代码行数:9,代码来源:ArrayResolver.cs
示例19: CanResolve
/// <summary>
/// Returns true if the resolver is able to satisfy the specified dependency.
/// </summary>
/// <param name="context">Creation context, which is a resolver itself</param>
/// <param name="contextHandlerResolver">Parent resolver</param>
/// <param name="model">Model of the component that is requesting the dependency</param>
/// <param name="dependency">The dependency model</param>
/// <returns><c>true</c> if the dependency can be satisfied</returns>
public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model,
DependencyModel dependency)
{
// 1 - check for the dependency on CreationContext, if present
if (context != null)
{
if (context.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
}
// 2 - check with the model's handler, if not the same as the parent resolver
IHandler handler = kernel.GetHandler(model.Name);
if (handler != null && handler != contextHandlerResolver)
{
if (handler.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
}
// 3 - check within parent resolver, if present
if (contextHandlerResolver != null)
{
if (contextHandlerResolver.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
}
// 4 - check within subresolvers
foreach(ISubDependencyResolver subResolver in subResolvers)
{
if (subResolver.CanResolve(context, contextHandlerResolver, model, dependency))
{
return true;
}
}
// 5 - normal flow, checking against the kernel
if (dependency.DependencyType == DependencyType.Service ||
dependency.DependencyType == DependencyType.ServiceOverride)
{
return CanResolveServiceDependency(context, model, dependency);
}
else
{
return CanResolveParameterDependency(model, dependency);
}
}
开发者ID:ralescano,项目名称:castle,代码行数:65,代码来源:DefaultDependencyResolver.cs
示例20: Resolve
public object Resolve(CreationContext context,
ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
var targetType = dependency.TargetType.GetElementType();
var resolved = _kernel.ResolveAll(targetType, null);
return resolved;
}
开发者ID:agross,项目名称:nhibernate-init,代码行数:9,代码来源:ArraySubDependencyResolver.cs
注:本文中的ISubDependencyResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论