internal static AdditionalInterfacesPolicy GetOrCreate <TPolicySet>(ref TPolicySet policies)
            where  TPolicySet : IPolicySet
        {
            var policy = policies.Get <IAdditionalInterfacesPolicy>();

            if (!(policy is AdditionalInterfacesPolicy))
            {
                policy = new AdditionalInterfacesPolicy();
                policies.Set <IAdditionalInterfacesPolicy>(policy);
            }
            return((AdditionalInterfacesPolicy)policy);
        }
Пример #2
0
        internal static AdditionalInterfacesPolicy GetOrCreate(IPolicyList policies,
                                                               Type typeToCreate,
                                                               string name)
        {
            NamedTypeBuildKey           key    = new NamedTypeBuildKey(typeToCreate, name);
            IAdditionalInterfacesPolicy policy =
                (IAdditionalInterfacesPolicy)policies.Get(typeToCreate, name, typeof(IAdditionalInterfacesPolicy), out _);

            if (!(policy is AdditionalInterfacesPolicy))
            {
                policy = new AdditionalInterfacesPolicy();
                policies.Set(typeToCreate, name, typeof(IAdditionalInterfacesPolicy), policy);
            }
            return((AdditionalInterfacesPolicy)policy);
        }
        internal static AdditionalInterfacesPolicy GetOrCreate(
            IPolicyList policies,
            Type typeToCreate,
            string name)
        {
            NamedTypeBuildKey           key    = new NamedTypeBuildKey(typeToCreate, name);
            IAdditionalInterfacesPolicy policy =
                policies.GetNoDefault <IAdditionalInterfacesPolicy>(key, false);

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