protected virtual XmlDocument GetXmlDocument(ServiceHostBase serviceHost) { if (serviceHost == null) { throw new ArgumentNullException(nameof(serviceHost)); } ServiceHealthModel model = new ServiceHealthModel(serviceHost, this.ServiceStartTime); return(SerializeToXml <ServiceHealthModel>(model)); }
protected virtual ServiceHealthSectionCollection GetServiceHealthSections(ServiceHostBase serviceHost) { if (serviceHost == null) { throw new ArgumentNullException(nameof(serviceHost)); } ServiceHealthSectionCollection serviceHealthSections = new ServiceHealthSectionCollection(); ServiceHealthModel serviceHealthModel = new ServiceHealthModel(serviceHost, this.ServiceStartTime); #region Service Properties ServiceHealthSection serviceProperties = serviceHealthSections.CreateSection(SR.GetString(SR.ServiceHealthBehavior_WCFServiceProperties), "#0C5DA4", "#ffffff"); ServiceHealthDataCollection servicePropertiesCollection = serviceProperties.CreateElementsCollection(); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ServiceName), serviceHealthModel.ServiceProperties.Name); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_State), FormatCommunicationState(serviceHealthModel.ServiceProperties.State)); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ServiceType), serviceHealthModel.ServiceProperties.ServiceTypeName); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_InstanceContextMode), serviceHealthModel.ServiceProperties.InstanceContextMode?.ToString()); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ConcurrencyMode), serviceHealthModel.ServiceProperties.ConcurrencyMode?.ToString()); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_BaseAddresses), serviceHealthModel.ServiceProperties.BaseAddresses); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ServiceThrottles), FormatServiceThrottle(serviceHealthModel.ServiceProperties.ServiceThrottle)); servicePropertiesCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ServiceBehaviors), serviceHealthModel.ServiceProperties.ServiceBehaviorNames); #endregion #region Process Information ServiceHealthSection processInformation = serviceHealthSections.CreateSection(SR.GetString(SR.ServiceHealthBehavior_ProcessInformation), "#2C4079", "#ffffff"); ServiceHealthDataCollection processInformationCollection = processInformation.CreateElementsCollection(); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ProcessName), serviceHealthModel.ProcessInformation.ProcessName); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ProcessBitness), serviceHealthModel.ProcessInformation.Bitness.ToString()); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ProcessRunningSince), serviceHealthModel.ProcessInformation.ProcessStartDate.ToString()); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ServiceRunningSince), serviceHealthModel.ProcessInformation.ServiceStartDate.ToString()); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Uptime), serviceHealthModel.ProcessInformation.Uptime.ToString(TimeSpanFormat)); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_GCMode), serviceHealthModel.ProcessInformation.GCMode); processInformationCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Threads), FormatThreads(serviceHealthModel.ProcessInformation.Threads)); #endregion #region Endpoints if (serviceHealthModel.ServiceEndpoints != null && serviceHealthModel.ServiceEndpoints.Length > 0) { ServiceHealthSection endpointsSection = serviceHealthSections.CreateSection(SR.GetString(SR.ServiceHealthBehavior_Endpoints), "#3e7185", "#ffffff"); foreach (ServiceHealthModel.ServiceEndpointModel serviceEndpoint in serviceHealthModel.ServiceEndpoints) { ServiceHealthDataCollection endpointCollection = endpointsSection.CreateElementsCollection(); endpointCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Address), serviceEndpoint.Address); endpointCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Binding), serviceEndpoint.BindingName); endpointCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Contract), serviceEndpoint.ContractName); endpointCollection.Add(SR.GetString(SR.ServiceHealthBehavior_EndpointBehaviors), serviceEndpoint.BehaviorNames); } } #endregion #region Channel Dispatchers if (serviceHealthModel.ChannelDispatchers != null && serviceHealthModel.ChannelDispatchers.Length > 0) { ServiceHealthSection channelDispatcherSection = serviceHealthSections.CreateSection(SR.GetString(SR.ServiceHealthBehavior_ChannelDispatchers), "#406BE8", "#ffffff"); foreach (ServiceHealthModel.ChannelDispatcherModel channelDispatcher in serviceHealthModel.ChannelDispatchers) { ServiceHealthDataCollection channelDispatcherCollection = channelDispatcherSection.CreateElementsCollection(); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ListenerUri), channelDispatcher.ListenerUri); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ListenerState), FormatCommunicationState(channelDispatcher.ListenerState)); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Binding), channelDispatcher.BindingName); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_State), FormatCommunicationState(channelDispatcher.State)); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_MessageEncoder), channelDispatcher.MessageEncoder); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_Contract), channelDispatcher.ContractName); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_IsSystemEndpoint), channelDispatcher.IsSystemEndpoint.ToString()); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_ChannelTimeouts), FormatCommunicationTimeouts(channelDispatcher.CommunicationTimeouts)); channelDispatcherCollection.Add(SR.GetString(SR.ServiceHealthBehavior_MessageInspectors), channelDispatcher.MessageInspectors); } } #endregion return(serviceHealthSections); }