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 LifeCycleAttribute(ServerInstanceMode mode, int timeoutMs) { m_Mode = mode; m_TimeoutMs = timeoutMs; }
public LifeCycleAttribute(ServerInstanceMode mode) { m_Mode = mode; }
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; }