示例#1
0
 public void Apply(PluginContext context)
 {
     if (!context.Cancel)
     {
         OnApply(context);
     }
 }
示例#2
0
 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);
 }
示例#3
0
 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);
     }
 }
示例#4
0
 protected virtual void OnApply(PluginContext context)
 {
 }