private static object CreateRemoteObservable(QbservableProtocol protocol, object instance, Type dataType) { var sink = protocol.GetOrAddSink(protocol.CreateClientDuplexSinkInternal); int id = 0; id = sink.RegisterObservableCallback(serverId => Subscribe(sink, new DuplexCallbackId(id, serverId), instance, dataType)); return(Activator.CreateInstance(typeof(DuplexCallbackObservable <>).MakeGenericType(dataType), id)); }
private static object CreateRemoteEnumerable(QbservableProtocol protocol, IEnumerable instance, Type dataType) { var sink = protocol.GetOrAddSink(protocol.CreateClientDuplexSinkInternal); int id = 0; id = sink.RegisterEnumerableCallback(instance.GetEnumerator); return(Activator.CreateInstance(typeof(DuplexCallbackEnumerable <>).MakeGenericType(dataType), id)); }
private DuplexCallback(QbservableProtocol protocol, Func <int, object[], object> callback) { this.id = protocol .GetOrAddSink(protocol.CreateClientDuplexSinkInternal) .RegisterInvokeCallback(arguments => callback(this.id, arguments)); }