コード例 #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 Type CreateEquivalentWrapperType(
            Type contractType,
            IDictionary <string, Type> extraCtorParams,
            ITypeCacher typeCacher,
            string wrapperMode)
        {
            var keyObject = $"{contractType.FullName}-{wrapperMode}-Wrapper";

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

            var wrapperType = TypeFactory.CreateImplementationServicePack(
                type: contractType,
                typePostfix: $"{wrapperMode}_Wrapper",
                interfaces: new[] { contractType, typeof(IDisposable) },
                optimizationPackage: optimizationPackage,
                extraCtorParams: extraCtorParams)
                              .MatchType;

            typeCacher.Hold(keyObject, wrapperType);

            return(wrapperType);
        }
コード例 #3
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);
        }
コード例 #4
0
        public object CreateDisconnectedChannel(ITypeCacher typeCacher)
        {
            var disconnectedServicePack = CreateEquivalentDisconnectedType(serviceType, typeCacher);

            var disconnectedServiceTypeWrapper = CreateEquivalentWrapperType(serviceType,
                                                                             new Dictionary <string, Type>
            {
                { "disconnectedServiceType", disconnectedServicePack.MatchType },
            }, typeCacher, disconnectedPostFix);

            var connectedServiceObject = CreateDefaultChannel(null, disconnectedServicePack.MatchType);

            var defaultEvluatorObject = CreateDefaultInvoker(invoker);

            var returnObject = CreateReturnObject(disconnectedServiceTypeWrapper, defaultEvluatorObject, connectedServiceObject);

            return(returnObject);
        }
コード例 #5
0
        public object CreateConnectedChannel(
            ITypeCacher typeCacher,
            int?arbitaryPort     = null,
            bool isTransactional = true)
        {
            var connectedServicePack = CreateEquivalentConnectedType(serviceType, typeCacher, isTransactional);

            var connectedServiceTypeWrapper = CreateEquivalentWrapperType(serviceType,
                                                                          new Dictionary <string, Type>
            {
                { "connectedServiceType", connectedServicePack.MatchType },
            }, typeCacher, connectedPostFix);

            var connectedServiceObject = CreateDefaultChannel(arbitaryPort, connectedServicePack.MatchType);

            var defaultEvluatorObject = CreateDefaultInvoker(invoker);

            var returnObject = CreateReturnObject(connectedServiceTypeWrapper, defaultEvluatorObject, connectedServiceObject);

            return(returnObject);
        }
コード例 #6
0
 protected ContractTestFixture()
 {
     container            = CreateContainer();
     typeCacher           = new TypeCacherMock();
     testOptimizationPack = new TestOptimizationPack();
 }