public virtual async Task <Endpoint?> HostEndpointAsync(Type Key) { var ret = default(Endpoint); if (!FactoryCache.ContainsKey(Key)) { var ChildOptions = new Endpoint( Options.Provider, Options.Host, Options.Port, Guid.NewGuid().ToString() ); var Handler = Activator.CreateInstance(Key); if (Handler is { } V1) { var NewProvider = new IpcServer(ChildOptions, V1); var HostingLocation = await NewProvider.StartHostingAsync() .DefaultAwait() ; FactoryCache[Key] = NewProvider; EndpointCache[Key] = HostingLocation; ret = HostingLocation; } } else { ret = EndpointCache[Key]; } return(ret); }
public async Task SelfHostingAsync() { var Endpoint = new Endpoint(ProtocolProvider.Default, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); var Server = new IpcServer(Endpoint, new RemoteObject()); await Server.StartHostingAsync(); var Provider = new NamedPipeProtocolProvider(); var Client = await Provider.ConnectAsync <IRemoteObject>(Endpoint); await Client.HostingProcessIdAsync(); }