예제 #1
0
 /// <summary>
 /// Constructs request message from pre-computed  specs obtained by reflection. 
 /// This constructor is the fastest as it does not use reflection
 /// </summary>
 protected RequestMsg(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance) : base()
 {
     m_Contract = contract;
     m_Method = method;
     m_OneWay = oneWay;
     m_RemoteInstance = instance;
 }
예제 #2
0
 /// <summary>
 /// This .ctor is handy for message inspectors.
 /// Creates a substitute message for the original one with new values.
 /// Binding-specific context is cloned and headers/correlation data are cloned conditionaly
 /// </summary>
 protected RequestMsg(RequestMsg inspectedOriginal,
                   TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance, 
                   bool cloneHeaders = true, bool cloneCorrelation = true) : this(contract, method, oneWay, instance)
 {
   m_ServerTransport = inspectedOriginal.m_ServerTransport;
   CloneState(inspectedOriginal, cloneHeaders, cloneCorrelation);
 }
예제 #3
0
파일: RequestMsg.cs 프로젝트: itadapter/nfx
 /// <summary>
 /// This .ctor is handy for message inspectors.
 /// Creates a substitute message for the original one with new values.
 /// Binding-specific context is cloned and headers/correlation data are cloned conditionaly
 /// </summary>
 public RequestAnyMsg(RequestMsg inspectedOriginal,
     TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance, object[] args,
     bool cloneHeaders = true, bool cloneCorrelation = true)
     : base(inspectedOriginal, contract, method, oneWay, instance, cloneHeaders, cloneCorrelation)
 {
     m_Arguments = args;
 }
예제 #4
0
 //static .ctor
 static AuthServiceClient()
 {
     var t = typeof(IAuthService);
     s_ts_CONTRACT = new TypeSpec(t);
     s_ms_CloseSession = new MethodSpec(t.GetMethod("CloseSession", new Type[] { typeof(Guid) }));
     s_ms_CreateSession = new MethodSpec(t.GetMethod("CreateSession", new Type[] { typeof(long) }));
     s_ms_GetSessionUser = new MethodSpec(t.GetMethod("GetSessionUser", new Type[] { typeof(Guid) }));
 }
예제 #5
0
 //static .ctor
 static TestContractAClient()
 {
     var t = typeof(NFX.NUnit.Glue.ITestContractA);
      s_ts_CONTRACT = new TypeSpec(t);
      @s_ms_Method1_0 = new MethodSpec(t.GetMethod("Method1", new Type[]{ typeof(@System.@Int32) }));
      @s_ms_Method2_1 = new MethodSpec(t.GetMethod("Method2", new Type[]{ typeof(@System.@Int32) }));
      @s_ms_Sleeper_2 = new MethodSpec(t.GetMethod("Sleeper", new Type[]{ typeof(@System.@Int32) }));
 }
예제 #6
0
 /// <summary>
 /// Constructs request message from method information and arguments for call invocation. 
 /// This constructor is slower as it uses reflection
 /// </summary>
 protected RequestMsg(MethodInfo method, Guid? instance) : base()
 {
     m_Contract = new TypeSpec(method.DeclaringType);
     m_Method = new MethodSpec(method);
     m_OneWay = Attribute.IsDefined(method, typeof(OneWayAttribute));
     
     m_RemoteInstance = instance;
 }
예제 #7
0
 //static .ctor
 static JokeContractClient()
 {
     var t = typeof(@BusinessLogic.@IJokeContract);
      s_ts_CONTRACT = new TypeSpec(t);
      @s_ms_Echo_0 = new MethodSpec(t.GetMethod("Echo", new Type[]{ typeof(@System.@String) }));
      @s_ms_UnsecureEcho_1 = new MethodSpec(t.GetMethod("UnsecureEcho", new Type[]{ typeof(@System.@String) }));
      @s_ms_UnsecEchoMar_2 = new MethodSpec(t.GetMethod("UnsecEchoMar", new Type[]{ typeof(@System.@String) }));
      @s_ms_SimpleWorkAny_3 = new MethodSpec(t.GetMethod("SimpleWorkAny", new Type[]{ typeof(@System.@String), typeof(@System.@Int32), typeof(@System.@Int32), typeof(@System.@Boolean), typeof(@System.@Double) }));
      @s_ms_SimpleWorkMar_4 = new MethodSpec(t.GetMethod("SimpleWorkMar", new Type[]{ typeof(@System.@String), typeof(@System.@Int32), typeof(@System.@Int32), typeof(@System.@Boolean), typeof(@System.@Double) }));
      @s_ms_DBWork_5 = new MethodSpec(t.GetMethod("DBWork", new Type[]{ typeof(@System.@String), typeof(@System.@Int32), typeof(@System.@Int32) }));
      @s_ms_Notify_6 = new MethodSpec(t.GetMethod("Notify", new Type[]{ typeof(@System.@String) }));
      @s_ms_ObjectWork_7 = new MethodSpec(t.GetMethod("ObjectWork", new Type[]{ typeof(@System.@Object) }));
 }
예제 #8
0
            public mapping SpecToMethodInfos(MethodSpec spec)
            {
                mapping result;
                if (methodMap.TryGetValue(spec, out result)) return result;

                throw new ServerContractException(StringConsts.GLUE_ENDPOINT_MSPEC_NOT_FOUND_ERROR.Args( ServerEndPoint.Name, 
                                                                                                         Contract.FullName,
                                                                                                         spec.ToString()));
            }
예제 #9
0
            public serverImplementer(ServerHandler handler, ServerEndPoint sep, Type contract)
            {
                Handler = handler;
                ServerEndPoint = sep;
                Contract = contract;
                   
                var implementers = sep.ContractServers.Where(ts => contract.IsAssignableFrom(ts)).ToArray();

                if (implementers.Length==0)
                throw new ServerContractException(string.Format(StringConsts.GLUE_ENDPOINT_CONTRACT_NOT_IMPLEMENTED_ERROR, sep.Name, contract.FullName));

                if (implementers.Length>1)
                {
                      handler.WriteLog(LogSrc.Server, 
                                       MessageType.Warning,  
                                       string.Format(StringConsts.GLUE_ENDPOINT_CONTRACT_MANY_SERVERS_WARNING, contract.FullName, sep.Name),
                                       from: "serverImplementer"); 
                }

                Implementation = implementers[0];

                //pre-alloc Contract/Implementation method infos
                var intfMapping = Implementation.GetInterfaceMap(Contract);
                foreach(var miContract in Contract.GetMethods())
                {
                  var mspec = new MethodSpec(miContract);
                  var miImpl = intfMapping.TargetMethods.FirstOrDefault( tmi => new MethodSpec(tmi).Equals( mspec ));
                  if (miImpl==null)
                    throw new ServerContractException(StringConsts.GLUE_ENDPOINT_CONTRACT_INTF_MAPPING_ERROR.Args( sep.Name, 
                                                                                                                   contract.FullName,
                                                                                                                   miContract.Name,
                                                                                                                   Implementation.FullName));
                  var fBody = getFBody(miContract);
                  methodMap.Add(mspec, new mapping(miContract, miImpl, fBody));//todo DODELAT Functor!
                }

                var lifeCycle = Contract.GetCustomAttributes(typeof(LifeCycleAttribute), false).FirstOrDefault() as LifeCycleAttribute;
                if (lifeCycle!=null)
                {
                    InstanceMode = lifeCycle.Mode;
                    InstanceTimeoutMs = lifeCycle.TimeoutMs;
                }

                if (InstanceTimeoutMs==0) InstanceTimeoutMs = DEFAULT_INSTANCE_TIMEOUT_MS;

                ThreadSafe = Attribute.IsDefined(Implementation, typeof(ThreadSafeAttribute), false);

                AuthenticationSupport =  Attribute.IsDefined(Contract, typeof(AuthenticationSupportAttribute), false);

                SupportsGlueCtor = Implementation.GetConstructor(ServerHandler.GLUE_CTOR_SIGNATURE) != null;


            }
        public void MethodSpec_3()
        {
            var s1 = new MethodSpec(typeof(NFX.Registry<NFX.ServiceModel.Service>).GetMethod("Register"));
            var s2 = new MethodSpec(typeof(NFX.MiscUtils).GetMethod("ToSecondsSinceUnixEpochStart"));

            Console.WriteLine(s1);
            Console.WriteLine(s2);

            Assert.AreNotEqual(s1, s2);
            Assert.AreNotEqual( s1.GetHashCode(), s2.GetHashCode());
        }
예제 #11
0
 public RequestMsg_IJokeContract_UnsecEchoMar(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance)
     : base(contract, method, oneWay, instance)
 {
 }
예제 #12
0
 static LoginServiceClient()
 {
     var t = typeof(ILoginService);
     s_ts_CONTRACT = new TypeSpec(t);
     s_ms_Login_0 = new MethodSpec(t.GetMethod("Login", new Type[] { typeof(string) }));
 }
예제 #13
0
 //static .ctor
 static TestContractBClient()
 {
     var t = typeof(NFX.NUnit.Glue.ITestContractB);
      s_ts_CONTRACT = new TypeSpec(t);
      @s_ms_SetPersonOfTheDay_0 = new MethodSpec(t.GetMethod("SetPersonOfTheDay", new Type[]{ typeof(@NFX.@NUnit.@Glue.@PersonData) }));
      @s_ms_GetPersonOfTheDay_1 = new MethodSpec(t.GetMethod("GetPersonOfTheDay", new Type[]{  }));
      @s_ms_GetName_2 = new MethodSpec(t.GetMethod("GetName", new Type[]{  }));
      @s_ms_GetName_3 = new MethodSpec(t.GetMethod("GetName", new Type[]{ typeof(@System.@Int32) }));
      @s_ms_GetName_4 = new MethodSpec(t.GetMethod("GetName", new Type[]{ typeof(@System.@Int32), typeof(@System.@Nullable<@System.@DateTime>) }));
      @s_ms_GetNameMar_100 = new MethodSpec(t.GetMethod("GetNameMar", new Type[]{ typeof(@System.@Int32) }));
      @s_ms_GetPersonalData_5 = new MethodSpec(t.GetMethod("GetPersonalData", new Type[]{ typeof(@System.@Int32[]) }));
      @s_ms_GetPersonalData_6 = new MethodSpec(t.GetMethod("GetPersonalData", new Type[]{ typeof(@System.@Int32[]), typeof(@System.@Boolean), typeof(@System.@Decimal) }));
      @s_ms_GetDailyStatuses_7 = new MethodSpec(t.GetMethod("GetDailyStatuses", new Type[]{ typeof(@System.@Int32) }));
      @s_ms_SummarizeAndFinish_8 = new MethodSpec(t.GetMethod("SummarizeAndFinish", new Type[]{  }));
 }
예제 #14
0
 public RequestMsg_ITestContractB_GetNameMar(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance)
     : base(contract, method, oneWay, instance)
 {
 }
예제 #15
0
 static ChatServiceClient()
 {
     var t = typeof(IChatService);
     s_ts_CONTRACT = new TypeSpec(t);
     s_ms_PutMessage_0 = new MethodSpec(t.GetMethod("PutMessage", new Type[] { typeof(Guid), typeof(string) }));
 }
예제 #16
0
 static MessageServiceClient()
 {
     var t = typeof(IMessageRequestService);
     s_ts_CONTRACT = new TypeSpec(t);
     s_ms_RequestMessages_0 = new MethodSpec(t.GetMethod("RequestMessages", new Type[] { typeof(Guid), typeof(int) }));
 }
예제 #17
0
파일: RequestMsg.cs 프로젝트: uzbekdev1/nfx
 /// <summary>
 /// Constructs request message from pre-computed  specs obtained by reflection.
 /// This constructor is the fastest as it does not use reflection
 /// </summary>
 public RequestAnyMsg(TypeSpec contract, MethodSpec method, bool oneWay, Guid?instance, object[] args) : base(contract, method, oneWay, instance)
 {
     m_Arguments = args;
 }
예제 #18
0
파일: RequestMsg.cs 프로젝트: uzbekdev1/nfx
 /// <summary>
 /// This .ctor is handy for message inspectors.
 /// Creates a substitute message for the original one with new values.
 /// Binding-specific context is cloned and headers/correlation data are cloned conditionaly
 /// </summary>
 public RequestAnyMsg(RequestMsg inspectedOriginal,
                      TypeSpec contract, MethodSpec method, bool oneWay, Guid?instance, object[] args,
                      bool cloneHeaders = true, bool cloneCorrelation = true) : base(inspectedOriginal, contract, method, oneWay, instance, cloneHeaders, cloneCorrelation)
 {
     m_Arguments = args;
 }
        public void MethodSpec_1()
        {
            var s1 = new MethodSpec(typeof(NFX.Registry<NFX.ServiceModel.Service>).GetMethod("Register"));
            var s2 = new MethodSpec(typeof(NFX.Registry<NFX.ServiceModel.Service>).GetMethod("Register"));

            Console.WriteLine(s1);
            Console.WriteLine(s2);

            Assert.AreEqual(s1, s2);
            Assert.AreEqual( s1.GetHashCode(), s2.GetHashCode());
        }
예제 #20
0
파일: RequestMsg.cs 프로젝트: itadapter/nfx
 /// <summary>
 /// Constructs request message from pre-computed  specs obtained by reflection.
 /// This constructor is the fastest as it does not use reflection
 /// </summary>
 public RequestAnyMsg(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance, object[] args)
     : base(contract, method, oneWay, instance)
 {
     m_Arguments = args;
 }
 static RegistrationServiceClient()
 {
     var t = typeof(IRegistrationService);
     s_ts_CONTRACT = new TypeSpec(t);
     s_ms_Register_0 = new MethodSpec(t.GetMethod("Register", new Type[] { typeof(string) }));
 }
예제 #22
0
 //static .ctor
 static TelemetryReceiverClient()
 {
     var t = typeof(NFX.Instrumentation.Telemetry.ITelemetryReceiver);
      s_ts_CONTRACT = new TypeSpec(t);
      @s_ms_Send_0 = new MethodSpec(t.GetMethod("Send", new Type[]{ typeof(@System.@String), typeof(@NFX.@Instrumentation.@Datum) }));
 }
        public void MethodSpec_2()
        {
            var s1 = new MethodSpec(typeof(NFX.Registry<NFX.ServiceModel.Service>).GetMethod("Register"));
            var s2 = new MethodSpec(typeof(NFX.Registry<NFX.ServiceModel.Service>).GetMethod("Unregister", new Type[]{typeof(string)}));

            Console.WriteLine(s1);
            Console.WriteLine(s2);

            Assert.AreNotEqual(s1, s2);
            Assert.AreNotEqual( s1.GetHashCode(), s2.GetHashCode());
        }