本文整理汇总了C#中IBinding类的典型用法代码示例。如果您正苦于以下问题:C# IBinding类的具体用法?C# IBinding怎么用?C# IBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IBinding类属于命名空间,在下文中一共展示了IBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:12,代码来源:SingletonScopeStorage.cs
示例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;
}
开发者ID:jamarlthomas,项目名称:ninject1,代码行数:14,代码来源:StandardDirectiveFactory.cs
示例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;
} ) );
}
}
开发者ID:Invenietis,项目名称:ck-certified,代码行数:29,代码来源:PreviewBindingInfo.cs
示例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);
}
开发者ID:schambers,项目名称:ninject,代码行数:11,代码来源:NinjectModule.cs
示例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;
}
开发者ID:jamarlthomas,项目名称:ninject1,代码行数:45,代码来源:EventReflectionStrategy.cs
示例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;
}
开发者ID:yuriik83,项目名称:OPC-UA-OOI,代码行数:7,代码来源:EncodingFactoryUnitTest.cs
示例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;
}
开发者ID:afifmohammed,项目名称:efsession,代码行数:7,代码来源:OverridableBindingGenerator.cs
示例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;
}
开发者ID:jamarlthomas,项目名称:ninject1,代码行数:41,代码来源:BehaviorReflectionStrategy.cs
示例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();
}
开发者ID:LuckyStarry,项目名称:Ninject,代码行数:26,代码来源:BindingPrecedenceComparer.cs
示例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;
}
开发者ID:rsuter,项目名称:ScopeCheckingNinjectKernel,代码行数:31,代码来源:ScopeCheckingStandardKernel.cs
示例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);
}
}
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:14,代码来源:InjectPipeline.cs
示例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;
}
开发者ID:jokingbear,项目名称:Simplect,代码行数:7,代码来源:ScopeTimeoutBinding.cs
示例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);
}
开发者ID:NuPattern,项目名称:CodeFirst,代码行数:8,代码来源:CommandAutomation.cs
示例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;
}
}
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:13,代码来源:SingletonScopeStorage.cs
示例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()}");
}
}
开发者ID:abdelkarim,项目名称:Perspex,代码行数:8,代码来源:PerspexXamlMemberValuePlugin.cs
示例16: AddBindingDependency
protected override void AddBindingDependency(IBinding binding)
{
if (binding == null)
return;
if (_dependencies.Contains(binding))
return;
_dependencies.Add(binding);
}
开发者ID:jpbenge,项目名称:SkullFist,代码行数:9,代码来源:VariableContext.cs
示例17: BoundCollectionChangedEventArgs
public BoundCollectionChangedEventArgs(string propertyName, NotifyCollectionChangedEventArgs sourceEventArgs, IBinding binding, object[] PreviousCollectionContent)
{
Argument.NotNull(() => sourceEventArgs);
this.PropertyName = propertyName;
this.SourceEventArgs = sourceEventArgs;
this.Binding = binding;
this.PreviousCollectionContent = PreviousCollectionContent;
}
开发者ID:ashleydavis,项目名称:Binding-System,代码行数:9,代码来源:BoundCollectionChangedEventArgs.cs
示例18: CreateContextMock
protected static Mock<IContext> CreateContextMock(object scope, IBinding binding, params Type[] genericArguments)
{
var contextMock = new Mock<IContext>();
contextMock.SetupGet(context => context.Binding).Returns(binding);
contextMock.Setup(context => context.GetScope()).Returns(scope);
contextMock.SetupGet(context => context.GenericArguments).Returns(genericArguments);
contextMock.SetupGet(context => context.HasInferredGenericArguments).Returns(genericArguments != null && genericArguments.Length > 0);
return contextMock;
}
开发者ID:Qiredev,项目名称:ninject,代码行数:9,代码来源:CacheTests.cs
示例19: AddBinding
public static void AddBinding(Type targetType, string methodName, IBinding binding)
{
Dictionary<string, IBinding> bindings;
if (!Cache.TryGetValue(targetType, out bindings))
{
bindings = new Dictionary<string, IBinding>();
Cache.Add(targetType, bindings);
}
bindings[methodName] = binding;
}
开发者ID:DenisVuyka,项目名称:SSharp,代码行数:10,代码来源:MethodProvider.cs
示例20: Add
public void Add(IBinding binding)
{
IList<IBinding> bindings;
if (!_bindingDict.TryGetValue(binding.SourceType, out bindings)) {
bindings = new List<IBinding>();
_bindingDict.Add(binding.SourceType, bindings);
}
if (!binding.Multiple) bindings.Clear();
bindings.Add(binding);
}
开发者ID:jammycakes,项目名称:dolstagis.web,代码行数:11,代码来源:FakeIoCContainer.cs
注:本文中的IBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论