internal StatefulServiceReplicaAdapter( StatefulServiceContext context, IStatefulUserServiceReplica userServiceReplica) { this.serviceContext = context; this.traceId = ServiceTrace.GetTraceIdForReplica(context.PartitionId, context.ReplicaId); this.serviceHelper = new ServiceHelper(TraceType, this.traceId); this.servicePartition = null; this.replicaListeners = null; this.communicationListeners = null; this.endpointCollection = new ServiceEndpointCollection(); this.runAsynCancellationTokenSource = null; this.executeRunAsyncTask = null; this.userServiceReplica = userServiceReplica; this.userServiceReplica.Addresses = this.endpointCollection.ToReadOnlyDictionary(); // The state provider replica should ideally be initialized // here (this.stateProviderReplica.Initialize()) with ServiceContext. // However the initialize function takes in StatefulServiceInitializationParameter // and resides in the DATA layer. DATA layer lies below SERVICES layer // and is agnostic of services and ServiceContext lies in SERVICES layer. // For now state provider replica is initialized when runtime calls // IStatefulServiceReplica.Initialize(StatefulServiceInitializationParameters initializationParameters) this.stateProviderReplica = this.userServiceReplica.CreateStateProviderReplica(); }
internal StatelessServiceInstanceAdapter( StatelessServiceContext context, IStatelessUserServiceInstance userServiceInstance) { this.serviceContext = context; this.traceId = ServiceTrace.GetTraceIdForReplica(context.PartitionId, context.InstanceId); this.serviceHelper = new ServiceHelper(TraceType, this.traceId); this.servicePartition = null; this.instanceListeners = null; this.communicationListeners = null; this.endpointCollection = new ServiceEndpointCollection(); this.runAsynCancellationTokenSource = null; this.executeRunAsyncTask = null; this.userServiceInstance = userServiceInstance; this.userServiceInstance.Addresses = this.endpointCollection.ToReadOnlyDictionary(); }
/// <summary> /// Creates an instance of a service /// </summary> /// <param name="t">The type of the service to register</param> ServiceBase(Type t) { trace = new ServiceTrace(this); Type tt = GetType(); try { if (t == null) { foreach (Type it in tt.GetInterfaces()) { if (it != typeof(IService)) { if (typeof(IService).IsAssignableFrom(it)) { t = it; break; } } } } if (t == null) { throw new ArgumentException("No service interfaces has been defined", "t"); } license = LicenseManager.Validate(t, this); //if (license == null) //no license... propname = ServiceHost.GetPropertyName(t); ServiceHost.INSTANCE.Add(t, this); remoteobject = RemotingServices.Marshal(this, null, t); } catch (Exception ex) { Trace.WriteLine("{1}() : {0}", ex, tt); } }
internal static string GetTraceIdForReplica(Guid partitionId, long replicaId) { return(ServiceTrace.GetTraceIdForReplica(partitionId, replicaId)); }