public DuplexServiceRuntimeChannel(IChannel channel, DispatchRuntime runtime) : base(channel, runtime) { // setup callback ClientRuntimeChannel. var crt = runtime.CallbackClientRuntime; var cd = ContractDescriptionGenerator.GetCallbackContract(runtime.Type, crt.CallbackClientType); client = new ClientRuntimeChannel(crt, cd, this.DefaultOpenTimeout, this.DefaultCloseTimeout, channel, null, runtime.ChannelDispatcher.MessageVersion, this.RemoteAddress, null); }
IEnumerable <ContractDescription> GetServiceContractDescriptions() { List <ContractDescription> contracts = new List <ContractDescription> (); Dictionary <Type, ServiceContractAttribute> contractAttributes = ContractDescriptionGenerator.GetServiceContractAttributes(service_type); foreach (Type contract in contractAttributes.Keys) { contracts.Add(ContractDescriptionGenerator.GetContract(contract, service_type)); } return(contracts); }
public DuplexServiceRuntimeChannel(IChannel channel, DispatchRuntime runtime) : base(channel, runtime) { if (channel == null) { throw new ArgumentNullException("channel"); } // setup callback ClientRuntimeChannel. var crt = runtime.CallbackClientRuntime; if (crt == null) { throw new InvalidOperationException("The DispatchRuntime does not have CallbackClientRuntime"); } contract = ContractDescriptionGenerator.GetCallbackContract(runtime.Type, crt.CallbackClientType); client = new ClientRuntimeChannel(crt, contract, this.DefaultOpenTimeout, this.DefaultCloseTimeout, channel, null, runtime.ChannelDispatcher.MessageVersion, this.RemoteAddress, null); }
public static Type CreateCallbackProxyType(DispatchRuntime dispatchRuntime, Type callbackType) { var ed = dispatchRuntime.EndpointDispatcher; var channelDispatcher = ed.ChannelDispatcher; Type contractType = channelDispatcher != null?channelDispatcher.Host.ImplementedContracts.Values.First(hcd => hcd.Name == ed.ContractName && hcd.Namespace == ed.ContractNamespace).ContractType : dispatchRuntime.Type; var cd = ContractDescriptionGenerator.GetCallbackContract(contractType, callbackType); string modname = "dummy"; Type crtype = typeof(DuplexServiceRuntimeChannel); // public class __clientproxy_MyContract : ClientRuntimeChannel, [ContractType] CodeClass c = new CodeModule(modname).CreateClass( "__callbackproxy_" + cd.Name, crtype, new Type [] { callbackType }); // // public __callbackproxy_MyContract ( // IChannel channel, DispatchRuntime runtime) // : base (channel, runtime) // { // } // Type [] ctorargs = new Type [] { typeof(IChannel), typeof(DispatchRuntime) }; CodeMethod ctor = c.CreateConstructor( MethodAttributes.Public, ctorargs); CodeBuilder b = ctor.CodeBuilder; MethodBase baseCtor = crtype.GetConstructors( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) [0]; if (baseCtor == null) { throw new Exception("INTERNAL ERROR: DuplexServiceRuntimeChannel.ctor() was not found."); } b.Call( ctor.GetThis(), baseCtor, new CodeArgumentReference(typeof(IChannel), 1, "arg0"), new CodeArgumentReference(typeof(DispatchRuntime), 2, "arg1")); return(CreateProxyTypeOperations(crtype, c, cd)); }
internal void InitializeServiceEndpoint(bool isCallback, Type serviceType, ServiceEndpoint se) { this.ContractFilter = GetContractFilter(se.Contract); this.DispatchRuntime.Type = serviceType; //Build the dispatch operations DispatchRuntime db = this.DispatchRuntime; if (!isCallback && se.Contract.CallbackContractType != null) { var ccd = ContractDescriptionGenerator.GetCallbackContract(db.Type, se.Contract.CallbackContractType); db.CallbackClientRuntime = ccd.CreateClientRuntime(); db.CallbackClientRuntime.CallbackClientType = ccd.ContractType; } foreach (OperationDescription od in se.Contract.Operations) { if (!db.Operations.Contains(od.Name)) { PopulateDispatchOperation(db, od); } } }
public WebScriptServiceHostFactory() { ContractDescriptionGenerator.RegisterGetOperationContractAttributeExtender(WebAttributesOCEExtender); }