Exemple #1
0
        public RpcService(TServiceInterface singletonService, ISerializer serializer)
        {
            using (EneterTrace.Entering())
            {
                if (serializer == null)
                {
                    string anError = "Input parameter serializer is null.";
                    EneterTrace.Error(anError);
                    throw new ArgumentNullException(anError);
                }

                ServiceInterfaceChecker.Check <TServiceInterface>();
                mySingletonService = new ServiceStub <TServiceInterface>(singletonService, serializer);
            }
        }
Exemple #2
0
        public RpcClient(ISerializer serializer, TimeSpan rpcTimeout, IThreadDispatcher threadDispatcher)
        {
            using (EneterTrace.Entering())
            {
                if (serializer == null)
                {
                    string anError = "Input parameter serializer is null.";
                    EneterTrace.Error(anError);
                    throw new ArgumentNullException(anError);
                }

                mySerializer = serializer;
                myRpcTimeout = rpcTimeout;

#if !NETSTANDARD
                ServiceInterfaceChecker.CheckForClient <TServiceInterface>();

                // Dynamically implement and instantiate the given interface as the proxy.
                Proxy = ProxyProvider.CreateInstance <TServiceInterface>(CallMethod, SubscribeEvent, UnsubscribeEvent);
#endif

                // Store remote methods.
                foreach (MethodInfo aMethodInfo in typeof(TServiceInterface).GetMethods())
                {
                    Type         aReturnType   = aMethodInfo.ReturnType;
                    Type[]       anArgTypes    = aMethodInfo.GetParameters().Select(x => x.ParameterType).ToArray();
                    RemoteMethod aRemoteMethod = new RemoteMethod(aReturnType, anArgTypes);
                    myRemoteMethods[aMethodInfo.Name] = aRemoteMethod;
                }

                // Store remote events.
                foreach (EventInfo anEventInfo in typeof(TServiceInterface).GetEvents())
                {
                    if (anEventInfo.EventHandlerType.IsGenericType)
                    {
                        RemoteEvent aRemoteEvent = new RemoteEvent(anEventInfo.EventHandlerType.GetGenericArguments()[0]);
                        myRemoteEvents[anEventInfo.Name] = aRemoteEvent;
                    }
                    else
                    {
                        RemoteEvent aRemoteEvent = new RemoteEvent(typeof(EventArgs));
                        myRemoteEvents[anEventInfo.Name] = aRemoteEvent;
                    }
                }

                myThreadDispatcher = threadDispatcher;
            }
        }
Exemple #3
0
        public RpcService(Func <TServiceInterface> serviceFactoryMethod, ISerializer serializer)
        {
            using (EneterTrace.Entering())
            {
                if (serializer == null)
                {
                    string anError = "Input parameter serializer is null.";
                    EneterTrace.Error(anError);
                    throw new ArgumentNullException(anError);
                }

                ServiceInterfaceChecker.Check <TServiceInterface>();

                myServiceFactoryMethod = serviceFactoryMethod;

                mySerializer = serializer;
            }
        }