• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NamedTypeBuildKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NamedTypeBuildKey的典型用法代码示例。如果您正苦于以下问题:C# NamedTypeBuildKey类的具体用法?C# NamedTypeBuildKey怎么用?C# NamedTypeBuildKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamedTypeBuildKey类属于命名空间,在下文中一共展示了NamedTypeBuildKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ResolvedAutoInterceptorPolicy

 /// <summary>
 /// 
 /// </summary>
 /// <param name="interceptorResolver"></param>
 /// <param name="buildKey"></param>
 public ResolvedAutoInterceptorPolicy(Func<NamedTypeBuildKey, IInstanceInterceptor> interceptorResolver, NamedTypeBuildKey buildKey)
 {
     Guard.ArgumentNotNull(interceptorResolver, "interceptorResolver");
     Guard.ArgumentNotNull(buildKey, "buildKey");
     this.BuildKey = buildKey;
     this.InterceptorResolver = interceptorResolver;
 }
开发者ID:rentianhua,项目名称:AgileMVC,代码行数:12,代码来源:ResolvedAutoInterceptorPolicy.cs


示例2: ConfigureContainer

        /// <summary>
        ///     Configures the container.
        /// </summary>
        /// <param name="container">The container.</param>
        protected override void ConfigureContainer(IUnityContainer container)
        {
            if (Interceptor == null)
            {
                return;
            }

            var interceptorType = TypeResolver.ResolveType(Interceptor.TypeName);
            if (!typeof (IInstanceInterceptor).IsAssignableFrom(interceptorType))
            {
                throw new ConfigurationErrorsException(Resources.ExceptionOnlyInstanceInterceptorBeSupported);
            }

            var builderName = interceptorType.AssemblyQualifiedName;
            var source =
                Interceptor.Injection.SelectMany(
                    (InjectionMemberElement element) =>
                        element.GetInjectionMembers(container, typeof (IInstanceInterceptor), interceptorType,
                            builderName));
            container.RegisterType(typeof (IInstanceInterceptor), interceptorType, builderName,
                new ContainerControlledLifetimeManager(), source.ToArray());

            var buildKey = new NamedTypeBuildKey(typeof (IInstanceInterceptor), builderName);
            var instance =
                new ResolvedAutoInterceptorPolicy(
                    (NamedTypeBuildKey key) => container.Resolve<IInstanceInterceptor>(key.Name), buildKey);
            container.RegisterInstance(typeof (AutoInterceptorPolicy),
                typeof (AutoInterceptorPolicy).AssemblyQualifiedName, instance, new ContainerControlledLifetimeManager());
        }
开发者ID:Chinaccn,项目名称:surfboard,代码行数:33,代码来源:AutoInterceptionElement.cs


示例3: Resolve

 public object Resolve(IBuilderContext context)
 {
     Guard.ArgumentNotNull(context, "context");
     NamedTypeBuildKey key = new NamedTypeBuildKey(type, name);
     IBuilderContext recursiveContext = context.CloneForNewBuild(key, null);
     return recursiveContext.Strategies.ExecuteBuildUp(recursiveContext);
 }
开发者ID:shhyder,项目名称:application,代码行数:7,代码来源:NamedTypeDependencyResolverPolicy.cs


示例4: ContainerRegistration

 internal ContainerRegistration(Type registeredType, string name, IPolicyList policies)
 {
     this.buildKey = new NamedTypeBuildKey(registeredType, name);
     MappedToType = GetMappedType(policies);
     LifetimeManagerType = GetLifetimeManagerType(policies);
     LifetimeManager = GetLifetimeManager(policies);
 }
开发者ID:CFMITL,项目名称:unity,代码行数:7,代码来源:ContainerRegistration.cs


示例5: Interceptor

        /// <summary>
        /// Initialize a new instance of the <see cref="Interceptor"/> class with a given
        /// name and type that will be resolved to provide interception.
        /// </summary>
        /// <param name="interceptorType">Type of the interceptor</param>
        /// <param name="name">name to use to resolve.</param>
        public Interceptor(Type interceptorType, string name)
        {
            Guard.ArgumentNotNull(interceptorType, "interceptorType");
            Guard.TypeIsAssignable(typeof(IInterceptor), interceptorType, "interceptorType");

            buildKey = new NamedTypeBuildKey(interceptorType, name);
        }
开发者ID:shhyder,项目名称:MapApplication,代码行数:13,代码来源:Interceptor.cs


示例6: AddPolicies

        /// <summary>
        /// Add policies to the <paramref name="policies"/> to configure the container with 
        /// an appropriate <see cref="IInstanceInterceptionPolicy"/>
        /// </summary>
        /// <param name="serviceType">Type of the interface being registered. This parameter is
        /// ignored by this class.</param>
        /// <param name="implementationType">Type to register.</param>
        /// <param name="name">Name used to resolve the type object.</param>
        /// <param name="policies">Policy list to add policies to.</param>
        public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
        {
            var key = new NamedTypeBuildKey(implementationType);
            policies.Set<IInstanceInterceptionPolicy>(new FixedInstanceInterceptionPolicy(Interceptor), key);

            var piabInjectionMember = new InterceptionBehavior<PolicyInjectionBehavior>();
            piabInjectionMember.AddPolicies(serviceType, implementationType, name, policies);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:17,代码来源:InstanceInterceptionPolicySettingInjectionMember.cs


示例7: OnRegisterInstance

 private void OnRegisterInstance(object sender, RegisterInstanceEventArgs e)
 {
     Context.RegisterNamedType(e.RegisteredType, e.Name);
     SetLifetimeManager(e.RegisteredType, e.Name, e.LifetimeManager);
     NamedTypeBuildKey identityKey = new NamedTypeBuildKey(e.RegisteredType, e.Name);
     Context.Policies.Set<IBuildKeyMappingPolicy>(new BuildKeyMappingPolicy(identityKey), identityKey);
     e.LifetimeManager.SetValue(e.Instance);
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:8,代码来源:UnityDefaultBehaviorExtension.cs


示例8: Resolve

 /// <summary>
 /// Get the value for a dependency.
 /// </summary>
 /// <param name="context">Current build context.</param>
 /// <returns>The value for the dependency.</returns>      
 public object Resolve(IBuilderContext context)
 {
     if (context == null)
      {
     throw new ArgumentNullException("context");
      }
      var buildKey = new NamedTypeBuildKey(typeToBuild);
      return context.NewBuildUp(buildKey);
 }
开发者ID:rsummer,项目名称:NServiceBus,代码行数:14,代码来源:OptionalFixedTypeResolverPolicy.cs


示例9: Map

        /// <summary>
        /// Maps the build key.
        /// </summary>
        /// <param name="buildKey">The build key to map.</param>
        /// <param name="context">Current build context. Used for contextual information
        /// if writing a more sophisticated mapping.</param>
        /// <returns>The new build key.</returns>
        public NamedTypeBuildKey Map(NamedTypeBuildKey buildKey, IBuilderContext context)
        {
            Guard.ArgumentNotNull(buildKey, "buildKey");
            Type originalType = buildKey.Type;
            GuardSameNumberOfGenericArguments(originalType);

            Type[] genericArguments = originalType.GetGenericArguments();
            Type resultType = destinationKey.Type.MakeGenericType(genericArguments);
            return new NamedTypeBuildKey(resultType, destinationKey.Name);
        }
开发者ID:shhyder,项目名称:MapApplication,代码行数:17,代码来源:GenericTypeBuildKeyMappingPolicy.cs


示例10: CanMapGenericTypeFromNamedTypeBuildKey

        public void CanMapGenericTypeFromNamedTypeBuildKey()
        {
            NamedTypeBuildKey original = new NamedTypeBuildKey(typeof (IList<string>), "test");
            IBuildKeyMappingPolicy policy = new GenericTypeBuildKeyMappingPolicy(new NamedTypeBuildKey(typeof (List<>), "test"));

            NamedTypeBuildKey result = policy.Map(original, null);

            Assert.AreEqual(typeof (List<string>), result.Type);
            Assert.AreEqual(original.Name, result.Name);
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:10,代码来源:GenericTypeMappingTest.cs


示例11: GetContext

 private IBuilderContext GetContext(IBuilderContext originalContext, NamedTypeBuildKey buildKey, DynamicBuildPlanGenerationContext ilContext)
 {
     return new BuilderContext(
         strategies.MakeStrategyChain(),
         originalContext.Lifetime,
         originalContext.PersistentPolicies,
         originalContext.Policies,
         buildKey,
         ilContext);
 }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:10,代码来源:DynamicMethodBuildPlanCreatorPolicy.cs


示例12: CanMapGenericTypeToNewGenericType

        public void CanMapGenericTypeToNewGenericType()
        {
            var original = new NamedTypeBuildKey(typeof (IList<int>));
            var expected = new NamedTypeBuildKey(typeof (List<int>));

            IBuildKeyMappingPolicy policy = new GenericTypeBuildKeyMappingPolicy(new NamedTypeBuildKey(typeof (List<>)));

            var result = policy.Map(original, null);
            Assert.AreEqual(expected, result);
        }
开发者ID:jorgeds001,项目名称:CodeSamples,代码行数:10,代码来源:GenericTypeMappingTest.cs


示例13: HasLifetimeFactoryPolicy

        // Checks if the instance being resolved has a lifetime manager factory
        private static bool HasLifetimeFactoryPolicy(IBuilderContext context)
        {
            var openGenericBuildKey = new NamedTypeBuildKey(context.BuildKey.Type.GetGenericTypeDefinition(),
                context.BuildKey.Name);

            IPolicyList factorySource;
            var factoryPolicy = context.Policies.Get<ILifetimeFactoryPolicy>(openGenericBuildKey, out factorySource);

            return factoryPolicy != null;
        }
开发者ID:pkubryk,项目名称:SummerBatch,代码行数:11,代码来源:SingletonStrategy.cs


示例14: BuildTreeItemNode

        public BuildTreeItemNode(NamedTypeBuildKey buildKey, Boolean nodeCreatedByContainer,
                                 BuildTreeItemNode parentNode)
        {
            Contract.Requires<ArgumentNullException>(buildKey != null);

            BuildKey = buildKey;
            NodeCreatedByContainer = nodeCreatedByContainer;
            Parent = parentNode;
            Children = new Collection<BuildTreeItemNode>();
        }
开发者ID:mskichu,项目名称:UnityExtension,代码行数:10,代码来源:BuildTreeItemNode.cs


示例15: RequestIsForValidatorOfT

        private static bool RequestIsForValidatorOfT(NamedTypeBuildKey key)
        {
            var typeToBuild = key.Type;
            if(!typeToBuild.IsGenericType) return false;

            if(typeToBuild.GetGenericTypeDefinition() != typeof(Validator<>)) return false;

            return true;

        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:10,代码来源:ValidatorCreationStrategy.cs


示例16: ApplyPolicies

        void ApplyPolicies(Type type)
        {
            if(type == null)
                return;

            var key = new NamedTypeBuildKey(type);

            Context.Policies.Set<IConstructorSelectorPolicy>(new ConstructorSelectorPolicy(), key);
            Context.Policies.Set<IPropertySelectorPolicy>(new PropertySelectorPolicy(), key);
        }
开发者ID:rokite,项目名称:openrasta-stable,代码行数:10,代码来源:InjectionPolicies.cs


示例17: BuilderContext

 /// <summary>
 /// Create a new <see cref="BuilderContext"/> using the explicitly provided
 /// values.
 /// </summary>
 /// <param name="chain">The <see cref="IStrategyChain"/> to use for this context.</param>
 /// <param name="lifetime">The <see cref="ILifetimeContainer"/> to use for this context.</param>
 /// <param name="persistentPolicies">The set of persistent policies to use for this context.</param>
 /// <param name="transientPolicies">The set of transient policies to use for this context. It is
 /// the caller's responsibility to ensure that the transient and persistent policies are properly
 /// combined.</param>
 /// <param name="buildKey">Build key for this context.</param>
 /// <param name="existing">Existing object to build up.</param>
 public BuilderContext(IStrategyChain chain, ILifetimeContainer lifetime, IPolicyList persistentPolicies, IPolicyList transientPolicies, NamedTypeBuildKey buildKey, object existing)
 {
     this.chain = chain;
     this.lifetime = lifetime;
     this.persistentPolicies = persistentPolicies;
     this.policies = transientPolicies;
     this.originalBuildKey = buildKey;
     this.BuildKey = buildKey;
     this.Existing = existing;
 }
开发者ID:theoju,项目名称:CleanCode,代码行数:22,代码来源:BuilderContext.cs


示例18: GenericTypeBuildKeyMappingPolicy

 public GenericTypeBuildKeyMappingPolicy(NamedTypeBuildKey destinationKey)
 {
     Guard.ArgumentNotNull(destinationKey, "destinationKey");
     if (!destinationKey.Type.GetTypeInfo().IsGenericTypeDefinition)
     {
         throw new ArgumentException(
             string.Format(CultureInfo.CurrentCulture,
                           Resources.MustHaveOpenGenericType,
                           destinationKey.Type.GetTypeInfo().Name));
     }
     this.destinationKey = destinationKey;
 }
开发者ID:kangkot,项目名称:unity,代码行数:12,代码来源:GenericTypeBuildKeyMappingPolicy.cs


示例19: BuilderContext

 /// <summary>
 /// Create a new <see cref="BuilderContext"/> using the explicitly provided
 /// values.
 /// </summary>
 /// <param name="chain">The <see cref="IStrategyChain"/> to use for this context.</param>
 /// <param name="lifetime">The <see cref="ILifetimeContainer"/> to use for this context.</param>
 /// <param name="persistentPolicies">The set of persistent policies to use for this context.</param>
 /// <param name="transientPolicies">The set of transient policies to use for this context. It is
 /// the caller's responsibility to ensure that the transient and persistent policies are properly
 /// combined.</param>
 /// <param name="buildKey">Build key for this context.</param>
 /// <param name="existing">Existing object to build up.</param>
 public BuilderContext(IStrategyChain chain, ILifetimeContainer lifetime, IPolicyList persistentPolicies, IPolicyList transientPolicies, NamedTypeBuildKey buildKey, object existing)
 {
     this.chain = chain;
     this.lifetime = lifetime;
     this.persistentPolicies = persistentPolicies;
     this.policies = transientPolicies;
     this.originalBuildKey = buildKey;
     this.BuildKey = buildKey;
     this.Existing = existing;
     this.resolverOverrides = new CompositeResolverOverride();
     this.ownsOverrides = true;
 }
开发者ID:kangkot,项目名称:unity,代码行数:24,代码来源:BuilderContext.cs


示例20: AddPolicies

 public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
 {
     var key = new NamedTypeBuildKey(implementationType, name);
     var policy = policies.Get<InterceptorPolicy>(key);
     if (policy == null)
     {
         policy = new InterceptorPolicy();
         policies.Set(policy, key);
     }
     
     policy.AddInterceptor(this.interceptorContainer);
 }
开发者ID:BrunoJuchli,项目名称:Unity.StaticProxyExtension,代码行数:12,代码来源:Intercept.cs



注:本文中的NamedTypeBuildKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Namespace类代码示例发布时间:2022-05-24
下一篇:
C# NamedPipeServerStream类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap