예제 #1
0
        internal static InterceptionBehaviorsPolicy GetOrCreate <TPolicySet>(ref TPolicySet policies)
            where TPolicySet : IPolicySet
        {
            IInterceptionBehaviorsPolicy policy = (IInterceptionBehaviorsPolicy)policies.Get(typeof(IInterceptionBehaviorsPolicy));

            if (!(policy is InterceptionBehaviorsPolicy))
            {
                policy = new InterceptionBehaviorsPolicy();
                policies.Set(typeof(IInterceptionBehaviorsPolicy), policy);
            }
            return((InterceptionBehaviorsPolicy)policy);
        }
        internal static InterceptionBehaviorsPolicy GetOrCreate(
            IPolicyList policies,
            Type typeToCreate,
            string name)
        {
            IInterceptionBehaviorsPolicy policy =
                (IInterceptionBehaviorsPolicy)policies.Get(typeToCreate, name, typeof(IInterceptionBehaviorsPolicy), out _);

            if (!(policy is InterceptionBehaviorsPolicy))
            {
                policy = new InterceptionBehaviorsPolicy();
                policies.Set(typeToCreate, name, typeof(IInterceptionBehaviorsPolicy), policy);
            }
            return((InterceptionBehaviorsPolicy)policy);
        }
예제 #3
0
        internal static InterceptionBehaviorsPolicy GetOrCreate(
            IPolicyList policies,
            Type typeToCreate,
            string name)
        {
            NamedTypeBuildKey            key    = new NamedTypeBuildKey(typeToCreate, name);
            IInterceptionBehaviorsPolicy policy =
                policies.GetNoDefault <IInterceptionBehaviorsPolicy>(key, false);

            if (policy == null || !(policy is InterceptionBehaviorsPolicy))
            {
                policy = new InterceptionBehaviorsPolicy();
                policies.Set(policy, key);
            }
            return((InterceptionBehaviorsPolicy)policy);
        }