本文整理汇总了C#中Castle.Core.ComponentModel类的典型用法代码示例。如果您正苦于以下问题:C# ComponentModel类的具体用法?C# ComponentModel怎么用?C# ComponentModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentModel类属于Castle.Core命名空间,在下文中一共展示了ComponentModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMismatch
private IEnumerable<LifestyleDependency> GetMismatch(LifestyleDependency parent, ComponentModel component,
Dictionary<ComponentModel, IHandler> model2Handler)
{
if (parent.Handler.ComponentModel == component)
{
yield break;
}
var handler = model2Handler[component];
var item = new LifestyleDependency(handler, parent);
if (item.Mismatched())
{
yield return item;
}
else
{
foreach (ComponentModel dependent in handler.ComponentModel.Dependents)
{
foreach (var mismatch in GetMismatch(item, dependent, model2Handler))
{
yield return mismatch;
}
}
}
}
示例2: SetOnBehalfAware
protected static void SetOnBehalfAware(IOnBehalfAware onBehalfAware, ComponentModel target)
{
if (onBehalfAware != null)
{
onBehalfAware.SetInterceptedComponentModel(target);
}
}
示例3: Resolve
public object Resolve(CreationContext context,
ISubDependencyResolver parentResolver,
ComponentModel model,
DependencyModel dependency)
{
return _kernel.ResolveAll(dependency.TargetType.GetElementType(), null);
}
示例4: ProcessModel
public void ProcessModel(IKernel kernel, ComponentModel model)
{
if (model.Configuration == null)
{
return;
}
var remoteserverAttValue = model.Configuration.Attributes["remoteserver"];
var remoteclientAttValue = model.Configuration.Attributes["remoteclient"];
var server = RemotingStrategy.None;
var client = RemotingStrategy.None;
if (remoteserverAttValue == null && remoteclientAttValue == null)
{
return;
}
if (remoteserverAttValue != null)
{
server = converter.PerformConversion<RemotingStrategy>(remoteserverAttValue);
}
if (remoteclientAttValue != null)
{
client = converter.PerformConversion<RemotingStrategy>(remoteclientAttValue);
}
DoSemanticCheck(server, model, client);
ConfigureServerComponent(server, model.Implementation, model);
ConfigureClientComponent(client, model.Services.Single(), model);
}
示例5: UpdateActivator
private void UpdateActivator(ComponentModel model)
{
if (model.CustomComponentActivator == null)
{
model.CustomComponentActivator = typeof(WcfBehaviorActivator);
}
}
示例6: ProcessModel
public void ProcessModel(IKernel kernel, ComponentModel model)
{
if (model.Configuration == null)
{
return;
}
var mixins = model.Configuration.Children["mixins"];
if (mixins == null)
{
return;
}
var mixinReferences = new List<ComponentReference<object>>();
foreach (var mixin in mixins.Children)
{
var value = mixin.Value;
var mixinComponent = ReferenceExpressionUtil.ExtractComponentKey(value);
if (mixinComponent == null)
{
throw new Exception(
String.Format("The value for the mixin must be a reference to a component (Currently {0})", value));
}
mixinReferences.Add(new ComponentReference<object>("mixin-" + mixinComponent, mixinComponent));
}
if (mixinReferences.Count == 0)
{
return;
}
var options = ProxyUtil.ObtainProxyOptions(model, true);
mixinReferences.ForEach(options.AddMixinReference);
}
示例7: AbstractComponentActivator
/// <summary>
/// Constructs an AbstractComponentActivator
/// </summary>
protected AbstractComponentActivator(ComponentModel model, IKernel kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction)
{
this.model = model;
this.kernel = kernel;
this.onCreation = onCreation;
this.onDestruction = onDestruction;
}
示例8: 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);
}
示例9: Kernel_ComponentCreated
private void Kernel_ComponentCreated(ComponentModel model, object instance)
{
if (instance is IListener)
{
_eventPublisher.AddListener((IListener) instance);
}
}
示例10: CreateTransactionConfig
private TransactionConfig CreateTransactionConfig(ComponentModel model)
{
TransactionConfig config = new TransactionConfig();
GatherTransactionAttributes(config, model.Implementation);
GatherTransactionConfiguration(config, model);
return config;
}
示例11: SelectInterceptors
public InterceptorReference[] SelectInterceptors(ComponentModel model, InterceptorReference[] interceptors)
{
return new[]
{
new InterceptorReference(interceptorType),
};
}
示例12: Kernel_ComponentModelCreated
private void Kernel_ComponentModelCreated(ComponentModel model)
{
IEnumerable <Type> services = model.Services;
bool isView = services.Any(x => x.GetInterface("IView") != null);
// if (!services.Select(service => typeof (IView).IsAssignableFrom(service)).Any(isView => isView))
// {
// return;
// }
//
// if (model.CustomComponentActivator == null)
// {
// model.CustomComponentActivator = typeof (WpfWindowActivator);
// }
// bool isView = model
//
if ( !isView )
{
return;
}
if ( model.CustomComponentActivator == null )
{
model.CustomComponentActivator = typeof( WpfWindowActivator );
}
}
示例13: 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));
}
示例14: NoResolvableConstructorFoundException
public NoResolvableConstructorFoundException(Type type, ComponentModel componentModel)
: base(
string.Format("Could not find resolvable constructor for {0}. Make sure all required dependencies are provided.",
type.FullName), componentModel)
{
this.type = type;
}
示例15: ProcessModel
/// <summary>
/// Queries the kernel's ConfigurationStore for a configuration
/// associated with the component name.
/// </summary>
/// <param name="kernel"></param>
/// <param name="model"></param>
public virtual void ProcessModel(IKernel kernel, ComponentModel model)
{
IConfiguration config = kernel.ConfigurationStore.GetComponentConfiguration(model.Name) ??
kernel.ConfigurationStore.GetBootstrapComponentConfiguration(model.Name);
model.Configuration = config;
}