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); }
public ChannelFactory( Type serviceType, IOptimizationPackage optimizationPackage = null, Type invoker = null) { this.serviceType = serviceType; this.optimizationPackage = optimizationPackage; this.invoker = invoker ?? typeof(DefaultInvoker); }
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)); }
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)); }
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()); }
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)); }
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> > >(); }
public static object CreateQueryProxy(Type type, IOptimizationPackage optPack) { var channelFactory = new ChannelFactory(type, optPack); return(channelFactory.CreateConnectedChannel(TypeCacher.Instance, isTransactional: false)); }
public static object CreateDisconnectedCommandProxy(Type type, IOptimizationPackage optPack) { var channelFactory = new ChannelFactory(type, optPack); return(channelFactory.CreateDisconnectedChannel(TypeCacher.Instance)); }