public void Initialize() { _interlocutor = new CordInterlocutorMock(); _contract = new CallBackContract(); OriginContractLinker.Link <ICallBackContract>(_contract, _interlocutor); }
private TContract CreateOriginContract(Transporter light) { var memebers = ProxyContractFactory.ParseContractInterface(typeof(TContract)); var dispatcher = _contractBuilder.ReceiveDispatcherFactory(); var inputMessages = memebers.GetMethods().Select(m => new MessageTypeInfo { ReturnType = m.Value.ReturnType, ArgumentTypes = m.Value.GetParameters().Select(p => p.ParameterType).ToArray(), MessageId = (short)m.Key }); var outputMessages = memebers.GetProperties().Select(m => new MessageTypeInfo { ArgumentTypes = ReflectionHelper.GetDelegateInfoOrNull(m.Value.PropertyType).ParameterTypes, ReturnType = ReflectionHelper.GetDelegateInfoOrNull(m.Value.PropertyType).ReturnType, MessageId = (short)m.Key }); var messenger = new Messenger( light, SerializerFactory.CreateDefault(_contractBuilder.UserSerializationRules.ToArray()), DeserializerFactory.CreateDefault(_contractBuilder.UserDeserializationRules.ToArray()), outputMessages: outputMessages.ToArray(), inputMessages: inputMessages.ToArray() ); var interlocutor = new Interlocutor(messenger, dispatcher, _contractBuilder.MaxAnswerTimeoutDelay); TContract contract = _contractBuilder.OriginContractFactory(light.Channel); OriginContractLinker.Link(contract, interlocutor); return(contract); }