private UserServiceFactory(string address, ServiceInfo serviceInfo, IUserServiceCallback userServiceCallback) { this.binding = CremaHost.CreateBinding(serviceInfo); this.endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/UserService"); this.instanceContext = new InstanceContext(userServiceCallback ?? (this)); if (Environment.OSVersion.Platform != PlatformID.Unix) { this.instanceContext.SynchronizationContext = SynchronizationContext.Current; } }
public static DataBaseCollectionServiceClient CreateServiceClient(string address, ServiceInfo serviceInfo, IDataBaseCollectionServiceCallback callback) { var binding = CremaHost.CreateBinding(serviceInfo); var endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/DataBaseCollectionService"); var instanceContext = new InstanceContext(callback ?? empty); if (Environment.OSVersion.Platform != PlatformID.Unix) { instanceContext.SynchronizationContext = SynchronizationContext.Current; } return(new DataBaseCollectionServiceClient(instanceContext, binding, endPointAddress)); }
public DomainContext(CremaHost cremaHost, string address, ServiceInfo serviceInfo) { this.cremaHost = cremaHost; this.userContext = cremaHost.UserContext; this.serviceDispatcher = new CremaDispatcher(this); var metaData = this.serviceDispatcher.Invoke(() => { var binding = CremaHost.CreateBinding(serviceInfo); var endPointAddress = new EndpointAddress($"net.tcp://{address}:{serviceInfo.Port}/DomainService"); var instanceContext = new InstanceContext(this); if (Environment.OSVersion.Platform != PlatformID.Unix) { instanceContext.SynchronizationContext = System.Threading.SynchronizationContext.Current; } this.service = new DomainServiceClient(instanceContext, binding, endPointAddress); this.service.Open(); if (this.service is ICommunicationObject service) { service.Faulted += Service_Faulted; } var result = this.service.Subscribe(this.cremaHost.AuthenticationToken); result.Validate(); #if !DEBUG this.timer = new Timer(30000); this.timer.Elapsed += Timer_Elapsed; this.timer.Start(); #endif return(result.Value); }); this.Initialize(metaData); this.cremaHost.DataBases.ItemsCreated += DataBases_ItemsCreated; this.cremaHost.DataBases.ItemsRenamed += DataBases_ItemsRenamed; this.cremaHost.DataBases.ItemsDeleted += DataBases_ItemDeleted; this.cremaHost.AddService(this); }