/// <summary> /// Register a service interface on the server /// </summary> /// <param name="t">The interface of the service</param> /// <param name="instance">Instance of a class implementing the service</param> public void RegisterService(Type t, object instance) { services[t.Name] = instance; types[t.Name] = t; IpcStream.ScanInterfaceForTypes(t, KnownTypes); }
/// <summary> /// Register a service interface on the server /// </summary> /// <typeparam name="T">The interface of the service</typeparam> /// <param name="instance">Instance of a class implementing the service</param> public void RegisterService <T>(T instance) { if (!(instance is T)) { throw new InvalidOperationException("Instance must implement service interface"); } services[typeof(T).Name] = instance; types[typeof(T).Name] = typeof(T); IpcStream.ScanInterfaceForTypes(typeof(T), KnownTypes); }
/// <summary> /// Scans the service interface and builds proxy class /// </summary> /// <typeparam name="T">Service interface, must equal server-side</typeparam> /// <returns>Proxy class for remote calls</returns> public T GetServiceProxy <T>() { IpcStream.ScanInterfaceForTypes(typeof(T), KnownTypes); return((T)_proxyGenerator.CreateInterfaceProxyWithoutTarget(typeof(T), new Proxy <T>(this))); }