Пример #1
0
        private ServicePack CreateEquivalentConnectedType(
            Type contractType,
            ITypeCacher typeCacher,
            bool isTransactional)
        {
            var keyObject = $"{serviceType.FullName}-Connected:{isTransactional}";

            if (typeCacher.ContainesKey(keyObject))
            {
                return((ServicePack)typeCacher.Get(keyObject));
            }

            var onTypeAttributes                    = WcfAttributeFactory.CreateOnTypeAttributes(isTransactional);
            var forAllmembersAttributes             = WcfAttributeFactory.CreateForAllmembersConnectedAttributes(isTransactional);
            var forAllInvolvedTypesAttributes       = WcfAttributeFactory.CreateForAllInvolvedTypesAttributes();
            var forAllInvolvedTypeMembersAttributes = WcfAttributeFactory.CreateForAllInvolvedTypeMembersAttributes();

            var servicePack = TypeFactory.CreateInterfaceServicePack(
                type: contractType,
                typePostfix: connectedPostFix,
                onType: onTypeAttributes,
                forAllmembers: forAllmembersAttributes,
                forAllInvolvedTypes: forAllInvolvedTypesAttributes,
                optimizationPackage: optimizationPackage,
                forAllInvolvedTypeMembers: forAllInvolvedTypeMembersAttributes);

            typeCacher.Hold(keyObject, servicePack);

            return(servicePack);
        }
Пример #2
0
        private ServicePack CreateEquivalentDisconnectedType(Type contractType, ITypeCacher typeCacher)
        {
            var keyObject = $"{serviceType.FullName}-Disconnected";

            if (typeCacher.ContainesKey(keyObject))
            {
                return((ServicePack)typeCacher.Get(keyObject));
            }

            var onTypeAttributes                    = WcfAttributeFactory.CreateOnTypeAttributes();
            var forAllmembersAttributes             = WcfAttributeFactory.CreateForAllmembersDisconnectedAttributes();
            var forAllInvolvedTypesAttributes       = WcfAttributeFactory.CreateForAllInvolvedTypesAttributes();
            var forAllInvolvedTypeMembersAttributes = WcfAttributeFactory.CreateForAllInvolvedTypeMembersAttributes();

            var servicePack = TypeFactory.CreateInterfaceServicePack(
                type: contractType,
                typePostfix: disconnectedPostFix,
                onType: onTypeAttributes,
                forAllmembers: forAllmembersAttributes,
                forAllInvolvedTypes: forAllInvolvedTypesAttributes,
                optimizationPackage: optimizationPackage,
                forAllInvolvedTypeMembers: forAllInvolvedTypeMembersAttributes,
                allMethodsVoid: true);

            typeCacher.Hold(keyObject, servicePack);

            return(servicePack);
        }