public void Apply(PluginContext context) { if (!context.Cancel) { OnApply(context); } }
protected override void OnApply(PluginContext context) { // convert to the discovery service metadata for future sending announcement message var metadatas = new List<EndpointDiscoveryMetadata>(); foreach (var discoverable in context.DiscoverableServiceEndpoints) { var endpoint = discoverable.Endpoint; var extensions = discoverable.Extensions; var metadata = EndpointDiscoveryMetadata.FromServiceEndpoint(endpoint); foreach (var extension in extensions) { metadata.Extensions.Add(extension); } metadatas.Add(metadata); } // start the task send the heart beat periodly _heartbeatTask = Task.Factory.StartNew(() => HeartBeat(metadatas, context.AnnouncementEndpoint)); base.OnApply(context); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { var disServiceEndpoints = new List<PluginContext.DiscoverableServiceEndpoint>(); // apply the service discovery behavior opertaion _serviceDiscoveryBehavior.ApplyDispatchBehavior(serviceDescription, serviceHostBase); // add the additional information into the endpoint metadata extension through the endpoint discovery binding for each endpoints foreach (var endpoint in serviceDescription.Endpoints) { var endpointDiscoveryBehavior = new EndpointDiscoveryBehavior(); // check if the contract or endpoint should be ignored // set the extensions endpoint.SetExtensions(endpointDiscoveryBehavior, behavior => behavior.Extensions, _ignoredContractTypeNames, _ignoredEndpoints); endpoint.Behaviors.Add(endpointDiscoveryBehavior); // save the plugin context disServiceEndpoints.Add(new PluginContext.DiscoverableServiceEndpoint(endpoint, endpointDiscoveryBehavior.Extensions)); } // invoke the plugins var context = new PluginContext(disServiceEndpoints, _announcementEndpoint); foreach (var plugin in _plugins) { plugin.Apply(context); } }
protected virtual void OnApply(PluginContext context) { }