private static object CreateCommandServiceObject(
            CommandsInvokationEvaluator commandInvokationEvaluator,
            Type serviceType,
            IOptimizationPackage optPack)
        {
            var serviceObjectType = default(Type);

            if (optPack.typeContainer.Contains($"{serviceType}_Dispatcher"))
            {
                serviceObjectType = optPack.typeContainer.Get($"{serviceType}_Dispatcher");
            }
            else
            {
                var moduleBuilder = ModuleBuilderProvider.GetModuleBuilder();

                var serviceObjectTypeBuilder = DynamicTypeBuilderFactory.CreateClassBuilder(
                    $"{serviceType}_Dispatcher",
                    new Dictionary <string, Type>(),
                    moduleBuilder,
                    serviceType, typeof(IDisposable));

                serviceObjectType = serviceObjectTypeBuilder.Build();

                optPack.typeContainer.Save(serviceObjectType);
            }

            var serviceObject = Activator.CreateInstance(serviceObjectType, commandInvokationEvaluator);

            return(serviceObject);
        }
Exemplo n.º 2
0
 public ChannelFactory(
     Type serviceType,
     IOptimizationPackage optimizationPackage = null,
     Type invoker = null)
 {
     this.serviceType         = serviceType;
     this.optimizationPackage = optimizationPackage;
     this.invoker             = invoker ?? typeof(DefaultInvoker);
 }
Exemplo n.º 3
0
 public static ServicePack CreateImplementationServicePack(
     Type type, string typePostfix,
     Type[] interfaces,
     IOptimizationPackage optimizationPackage   = null,
     IDictionary <string, Type> extraCtorParams = null)
 {
     return(CreateServicePack(
                type, TypeCategories.Implementation, typePostfix,
                new List <AttributePack>(),
                new List <AttributePack>(),
                new List <AttributePack>(),
                new List <AttributePack>(), extraCtorParams, interfaces: interfaces, optimizationPackage: optimizationPackage));
 }
Exemplo n.º 4
0
 public static ServicePack CreateInterfaceServicePack(
     Type type,
     string typePostfix,
     IList <AttributePack> onType,
     IList <AttributePack> forAllmembers,
     IList <AttributePack> forAllInvolvedTypes,
     IList <AttributePack> forAllInvolvedTypeMembers,
     IOptimizationPackage optimizationPackage = null,
     bool allMethodsVoid = false)
 {
     return(CreateServicePack(type, TypeCategories.Interface, typePostfix, onType,
                              forAllmembers, forAllInvolvedTypes, forAllInvolvedTypeMembers, allMethodsVoid: allMethodsVoid, optimizationPackage: optimizationPackage));
 }
        public static object CreateCommandService(
            Type serviceType,
            IProxyContainer proxyContainer,
            IOptimizationPackage optPack)
        {
            var connectedProxy    = ProxyFactory.CreateConnectedCommandProxy(serviceType, optPack);
            var disconnectedProxy = ProxyFactory.CreateDisconnectedCommandProxy(serviceType, optPack);

            proxyContainer.AddProxyObject(connectedProxy);
            proxyContainer.AddProxyObject(disconnectedProxy);

            var commandInvokationEvaluator = new CommandsInvokationEvaluator(connectedProxy, disconnectedProxy);

            return(CreateCommandServiceObject(commandInvokationEvaluator, serviceType, optPack));
        }
Exemplo n.º 6
0
        private static ServicePack CreateServicePack(
            Type type,
            TypeCategories typeCategory,
            string typePostfix,
            IList <AttributePack> onType,
            IList <AttributePack> forAllmembers,
            IList <AttributePack> forAllInvolvedTypes,
            IList <AttributePack> forAllInvolvedTypeMembers,
            IDictionary <string, Type> extraCtorParams = null,
            IOptimizationPackage optimizationPackage   = null,
            bool allMethodsVoid = false,

            params Type[] interfaces)
        {
            var matcher = new ServiceMatcher(type, typeCategory, typePostfix, extraCtorParams, interfaces: interfaces, allMethodsVoid: allMethodsVoid, optimizationPackage: optimizationPackage);

            SetOnTypeAttributes(matcher, onType);
            SetForAllmembersAttributes(matcher, forAllmembers);
            SetForAllInvolvedTypesAttributes(matcher, forAllInvolvedTypes);
            SetForAllInvolvedTypeMembersAttributes(matcher, forAllInvolvedTypeMembers);

            return(matcher.Pack());
        }
Exemplo n.º 7
0
 public static ServicePack CreateClassServicePack(
     Type type,
     string typePostfix,
     IList <AttributePack> onType,
     IList <AttributePack> forAllmembers,
     IList <AttributePack> forAllInvolvedTypes,
     IList <AttributePack> forAllInvolvedTypeMembers,
     IDictionary <string, Type> extraCtorParams = null,
     IOptimizationPackage optimizationPackage   = null,
     bool allMethodsVoid = false)
 {
     return(CreateServicePack(
                type,
                TypeCategories.Class,
                typePostfix,
                onType,
                forAllmembers,
                forAllInvolvedTypes,
                forAllInvolvedTypeMembers,
                extraCtorParams,
                optimizationPackage,
                allMethodsVoid: allMethodsVoid));
 }
Exemplo n.º 8
0
        public ServiceMatcher(
            Type targetType, TypeCategories typeCategory,
            string namePostfix = null,
            IDictionary <string, Type> ctorExtraParamsType = null,
            bool allMethodsVoid = false,
            IOptimizationPackage optimizationPackage = null,
            params Type[] interfaces)
        {
            this.allMethodsVoid      = allMethodsVoid;
            this.optimizationPackage = optimizationPackage;
            moduleBuilder            = optimizationPackage?.moduleBuilder ?? CreateModuleBuilder();
            typeContainer            = optimizationPackage?.typeContainer ?? new DummyTypeContainer();
            this.targetType          = targetType;
            this.typeCategory        = typeCategory;
            this.namePostfix         = namePostfix ?? string.Empty;
            this.ctorExtraParamsType = ctorExtraParamsType ?? new Dictionary <string, Type>();
            this.interfaces          = interfaces;

            typeAttributes       = new List <Tuple <Type, IDictionary <Type, object>, IDictionary <string, object> > >();
            allMembersAttributes = new List <Tuple <Type, IDictionary <Type, object>, IDictionary <string, object> > >();

            involvedAttributes            = new List <Tuple <Type, IDictionary <Type, object>, IDictionary <string, object> > >();
            involvedTypeMembersAttributes = new List <Tuple <Type, IDictionary <Type, object>, IDictionary <string, object> > >();
        }
Exemplo n.º 9
0
        public static object CreateQueryProxy(Type type, IOptimizationPackage optPack)
        {
            var channelFactory = new ChannelFactory(type, optPack);

            return(channelFactory.CreateConnectedChannel(TypeCacher.Instance, isTransactional: false));
        }
Exemplo n.º 10
0
        public static object CreateDisconnectedCommandProxy(Type type, IOptimizationPackage optPack)
        {
            var channelFactory = new ChannelFactory(type, optPack);

            return(channelFactory.CreateDisconnectedChannel(TypeCacher.Instance));
        }