Beispiel #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;
 }
Beispiel #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);
 }
Beispiel #3
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>
 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;
 }
Beispiel #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) }));
 }
Beispiel #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) }));
 }
Beispiel #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;
 }
Beispiel #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) }));
 }
Beispiel #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()));
            }
Beispiel #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());
        }
Beispiel #11
0
 public RequestMsg_IJokeContract_UnsecEchoMar(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance)
     : base(contract, method, oneWay, instance)
 {
 }
 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) }));
 }
Beispiel #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[]{  }));
 }
Beispiel #14
0
 public RequestMsg_ITestContractB_GetNameMar(TypeSpec contract, MethodSpec method, bool oneWay, Guid? instance)
     : base(contract, method, oneWay, instance)
 {
 }
Beispiel #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) }));
 }
 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) }));
 }
Beispiel #17
0
 /// <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;
 }
Beispiel #18
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>
 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());
        }
Beispiel #20
0
 /// <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) }));
 }
 //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());
        }