本文整理汇总了C#中IBinding类的典型用法代码示例。如果您正苦于以下问题:C# IBinding类的具体用法?C# IBinding怎么用?C# IBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IBinding类属于命名空间,在下文中一共展示了IBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Remember
/// <summary>
///
/// </summary>
/// <param name="binding"></param>
/// <param name="instance"></param>
public void Remember(IBinding binding, object instance)
{
lock (cache)
{
cache[binding] = instance;
}
}
示例2: Create
/*----------------------------------------------------------------------------------------*/
/// <summary>
/// Creates an injection directive for the specified method.
/// </summary>
/// <param name="binding">The binding.</param>
/// <param name="method">The method to create the directive for.</param>
/// <returns>The created directive.</returns>
public MethodInjectionDirective Create(IBinding binding, MethodInfo method)
{
var directive = new MethodInjectionDirective(method);
CreateArgumentsForMethod(binding, method).Each(directive.Arguments.Add);
return directive;
}
示例3: Display
public void Display( IBinding binding )
{
if( binding == null ) return;
if( Window == null )
{
Window = new CKWindow();
}
Binding = binding;
Rect r = Binding.GetWindowArea();
if( r != Rect.Empty )
{
Window.Dispatcher.BeginInvoke( new Action( () =>
{
Window.Opacity = .8;
Window.Background = new System.Windows.Media.SolidColorBrush( System.Windows.Media.Color.FromRgb( 152, 120, 152 ) );
Window.ResizeMode = ResizeMode.NoResize;
Window.WindowStyle = WindowStyle.None;
Window.ShowInTaskbar = false;
Window.Show();
Window.Left = r.Left;
Window.Top = r.Top;
Window.Width = r.Width;
Window.Height = r.Height;
Window.Topmost = true;
} ) );
}
}
示例4: AddBinding
/// <summary>
/// Registers the specified binding.
/// </summary>
/// <param name="binding">The binding to add.</param>
public override void AddBinding(IBinding binding)
{
Ensure.ArgumentNotNull(binding, "binding");
Kernel.AddBinding(binding);
Bindings.Add(binding);
}
示例5: Build
/*----------------------------------------------------------------------------------------*/
/// <summary>
/// Executed to build the activation plan.
/// </summary>
/// <param name="binding">The binding that points at the type whose activation plan is being released.</param>
/// <param name="type">The type whose activation plan is being manipulated.</param>
/// <param name="plan">The activation plan that is being manipulated.</param>
/// <returns>
/// A value indicating whether to proceed or interrupt the strategy chain.
/// </returns>
public override StrategyResult Build(IBinding binding, Type type, IActivationPlan plan)
{
EventInfo[] events = type.GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (EventInfo evt in events)
{
#if !MONO
PublishAttribute[] attributes = evt.GetAllAttributes<PublishAttribute>();
#else
PublishAttribute[] attributes = ExtensionsForICustomAttributeProvider.GetAllAttributes<PublishAttribute>(evt);
#endif
foreach (PublishAttribute attribute in attributes)
plan.Directives.Add(new PublicationDirective(attribute.Channel, evt));
}
MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var injectorFactory = binding.Components.Get<IInjectorFactory>();
foreach (MethodInfo method in methods)
{
#if !MONO
SubscribeAttribute[] attributes = method.GetAllAttributes<SubscribeAttribute>();
#else
SubscribeAttribute[] attributes = ExtensionsForICustomAttributeProvider.GetAllAttributes<SubscribeAttribute>(method);
#endif
foreach (SubscribeAttribute attribute in attributes)
{
IMethodInjector injector = injectorFactory.GetInjector(method);
plan.Directives.Add(new SubscriptionDirective(attribute.Channel, injector, attribute.Thread));
}
}
return StrategyResult.Proceed;
}
示例6: UpdateValueConverter
public void UpdateValueConverter(IBinding binding, string repositoryGroup, UATypeInfo sourceEncoding)
{
Assert.IsNotNull(binding);
binding.Parameter = "Conversion parameter";
binding.Converter = new IVC();
binding.Culture = CultureInfo.InvariantCulture;
}
示例7: IsServiceAssemblyBinding
private bool IsServiceAssemblyBinding(IBinding b)
{
var haskey = HasAssemblyKey(b);
if (!haskey) return false;
var satisfies = b.Metadata.Get<string>("assembly") == _serviceAssembly;
return satisfies;
}
示例8: Build
/*----------------------------------------------------------------------------------------*/
/// <summary>
/// Executed to build the activation plan.
/// </summary>
/// <param name="binding">The binding that points at the type whose activation plan is being released.</param>
/// <param name="type">The type whose activation plan is being manipulated.</param>
/// <param name="plan">The activation plan that is being manipulated.</param>
/// <returns>
/// A value indicating whether to proceed or interrupt the strategy chain.
/// </returns>
public override StrategyResult Build(IBinding binding, Type type, IActivationPlan plan)
{
if (binding.Behavior != null)
{
// If the binding declares a behavior, it overrides any behavior that would be read
// via reflection.
plan.Behavior = binding.Behavior;
}
else
{
IBehavior behavior;
var attribute = type.GetOneAttribute<BehaviorAttribute>();
if (attribute != null)
{
// If a behavior attribute was defined on the implementation type, ask it to create
// the appropriate behavior.
behavior = attribute.CreateBehavior();
}
else
{
// If no behavior attribute was defined, create a behavior as defined by the kernel's options.
behavior = Activator.CreateInstance(Kernel.Options.DefaultBehaviorType) as IBehavior;
}
behavior.Kernel = Kernel;
plan.Behavior = behavior;
}
return StrategyResult.Proceed;
}
示例9: Compare
/// <inheritdoc />
public int Compare(IBinding x, IBinding y)
{
if (x == y)
{
return 0;
}
// Each function represents a level of precedence.
var funcs = new List<Func<IBinding, bool>>
{
b => b != null, // null bindings should never happen, but just in case
b => b.IsConditional, // conditional bindings > unconditional
b => !b.Service.GetTypeInfo().ContainsGenericParameters, // closed generics > open generics
b => !b.IsImplicit, // explicit bindings > implicit
};
var q = from func in funcs
let xVal = func(x)
where xVal != func(y)
select xVal ? 1 : -1;
// returns the value of the first function that represents a difference
// between the bindings, or else returns 0 (equal)
return q.FirstOrDefault();
}
示例10: IsScopeAllowed
private bool IsScopeAllowed(IRequest request, IBinding binding, IBinding parentBinding)
{
var scope = binding.GetScope(CreateContext(request, binding));
var parentScope = parentBinding.GetScope(CreateContext(request, parentBinding));
var haveSameScope = scope == parentScope;
if (haveSameScope)
return true;
var isChildSingletonScoped = scope == this;
if (isChildSingletonScoped)
return true;
var isChildTransientScoped = scope == null;
var isChildPerRequestScoped = scope != null && scope.GetType().Name == "HttpContext";
var isParentSingletonScoped = parentScope == this;
if (isParentSingletonScoped)
return AllowTransientScopeInSingletonScope && isChildTransientScoped;
var isParentThreadScoped = parentScope is Thread;
if (isParentThreadScoped)
return AllowTransientScopeInThreadScope && isChildTransientScoped;
var isParentAController = parentBinding.Service.Name.EndsWith("Controller");
var isParentTransientScoped = parentScope == null;
if (isParentTransientScoped)
return AllowPerRequestScopeInTransientScopedController && isParentAController && isChildPerRequestScoped;
return AllowTransientScopeInCustomScope && isChildTransientScoped;
}
示例11: Inject
/// <summary>
///
/// </summary>
/// <param name="kernel"></param>
/// <param name="binding"></param>
/// <param name="metadata"></param>
/// <param name="instance"></param>
public void Inject(IKernel kernel, IBinding binding, TypeMetadata metadata, object instance)
{
for (var i = 0; i < Injectors.Count; i++)
{
Injectors[i].Inject(kernel, binding, metadata, instance);
}
}
示例12: ScopeTimeoutBinding
internal ScopeTimeoutBinding(IBinding prev, Func<object> scopeObj, int timeout) : base(prev)
{
cachedObjs = new ConcurrentDictionary<object, ObjGetter>(10, 10);
this.timeout = timeout;
Condition = this;
scopeObjGetter = scopeObj;
}
示例13: CommandAutomation
public CommandAutomation(IComponentContext context, CommandAutomationSettings settings)
{
Guard.NotNull(() => context, context);
Guard.NotNull(() => settings, settings);
// CommandAutomationSettings validates the cast is valid.
this.command = context.Resolve<IBindingFactory>().CreateBinding<ICommand>(context, settings.Binding);
}
示例14: TryGet
/// <summary>
///
/// </summary>
/// <param name="binding"></param>
/// <returns></returns>
public object TryGet(IBinding binding)
{
lock (cache)
{
object instance;
return cache.TryGetValue(binding, out instance) ? instance : null;
}
}
示例15: HandleBinding
private void HandleBinding(object instance, IBinding binding)
{
if (!(AssignBinding(instance, binding) || ApplyBinding(instance, binding)))
{
throw new InvalidOperationException(
$"Cannot assign to '{_xamlMember.Name}' on '{instance.GetType()}");
}
}