public void BuildUp(IBuilderContext context) { if (context.Existing == null) { // build up dependencies var behavior = context.NewBuildUp <DIServiceBehavior <TInterface, TImplementation> >(); // create new DIServiceHost var serviceHost = new DIServiceHost <TInterface, TImplementation>(behavior); // add behaviors to ServiceHost foreach (var behaviorType in behaviors) { var newBehavior = context.NewBuildUp(new NamedTypeBuildKey(behaviorType)) as IServiceBehavior; serviceHost.Description.Behaviors.Add(newBehavior); } // add service endpoints to ServiceHost endpoints.ForEach(s => serviceHost.AddServiceEndpoint(s.Type, s.Binding, s.Address)); context.Existing = serviceHost; } }
public void OnStop() { _servieHost.Close(); _servieHost = null; }
public void OnStart() { SetServiceType(); _servieHost = new DIServiceHost(this.ServiceType, new List <Uri>().ToArray()); _servieHost.Open(); }