当前位置: 首页>>代码示例>>C#>>正文


C# NamedTypeBuildKey类代码示例

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


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


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