void FillBehaviorInfo(IServiceBehavior behavior, IWmiInstance existingInstance, out IWmiInstance instance) { Fx.Assert(null != existingInstance, ""); Fx.Assert(null != behavior, ""); instance = null; if (behavior is AspNetCompatibilityRequirementsAttribute) { instance = existingInstance.NewInstance("AspNetCompatibilityRequirementsAttribute"); AspNetCompatibilityRequirementsAttribute specificBehavior = (AspNetCompatibilityRequirementsAttribute)behavior; instance.SetProperty(AdministrationStrings.RequirementsMode, specificBehavior.RequirementsMode.ToString()); } else if (behavior is ServiceCredentials) { instance = existingInstance.NewInstance("ServiceCredentials"); ServiceCredentials specificBehavior = (ServiceCredentials)behavior; if (specificBehavior.ClientCertificate != null && specificBehavior.ClientCertificate.Certificate != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", specificBehavior.ClientCertificate.Certificate); instance.SetProperty(AdministrationStrings.ClientCertificate, result); } if (specificBehavior.IssuedTokenAuthentication != null && specificBehavior.IssuedTokenAuthentication.KnownCertificates != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "AllowUntrustedRsaIssuers: {0}\n", specificBehavior.IssuedTokenAuthentication.AllowUntrustedRsaIssuers); result += String.Format(CultureInfo.InvariantCulture, "CertificateValidationMode: {0}\n", specificBehavior.IssuedTokenAuthentication.CertificateValidationMode); result += String.Format(CultureInfo.InvariantCulture, "RevocationMode: {0}\n", specificBehavior.IssuedTokenAuthentication.RevocationMode); result += String.Format(CultureInfo.InvariantCulture, "TrustedStoreLocation: {0}\n", specificBehavior.IssuedTokenAuthentication.TrustedStoreLocation); foreach (X509Certificate2 certificate in specificBehavior.IssuedTokenAuthentication.KnownCertificates) { if (certificate != null) { result += String.Format(CultureInfo.InvariantCulture, "Known certificate: {0}\n", certificate.FriendlyName); } } result += String.Format(CultureInfo.InvariantCulture, "AudienceUriMode: {0}\n", specificBehavior.IssuedTokenAuthentication.AudienceUriMode); if (specificBehavior.IssuedTokenAuthentication.AllowedAudienceUris != null) { foreach (string str in specificBehavior.IssuedTokenAuthentication.AllowedAudienceUris) { if (str != null) { result += String.Format(CultureInfo.InvariantCulture, "Allowed Uri: {0}\n", str); } } } instance.SetProperty(AdministrationStrings.IssuedTokenAuthentication, result); } if (specificBehavior.Peer != null && specificBehavior.Peer.Certificate != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", specificBehavior.Peer.Certificate.ToString(true)); instance.SetProperty(AdministrationStrings.Peer, result); } if (specificBehavior.SecureConversationAuthentication != null && specificBehavior.SecureConversationAuthentication.SecurityContextClaimTypes != null) { string result = string.Empty; foreach (Type claimType in specificBehavior.SecureConversationAuthentication.SecurityContextClaimTypes) { if (claimType != null) { result += String.Format(CultureInfo.InvariantCulture, "ClaimType: {0}\n", claimType); } } instance.SetProperty(AdministrationStrings.SecureConversationAuthentication, result); } if (specificBehavior.ServiceCertificate != null && specificBehavior.ServiceCertificate.Certificate != null) { instance.SetProperty(AdministrationStrings.ServiceCertificate, specificBehavior.ServiceCertificate.Certificate.ToString()); } if (specificBehavior.UserNameAuthentication != null) { instance.SetProperty(AdministrationStrings.UserNameAuthentication, String.Format(CultureInfo.InvariantCulture, "{0}: {1}", AdministrationStrings.ValidationMode, specificBehavior.UserNameAuthentication.UserNamePasswordValidationMode.ToString())); } if (specificBehavior.WindowsAuthentication != null) { instance.SetProperty(AdministrationStrings.WindowsAuthentication, String.Format(CultureInfo.InvariantCulture, "{0}: {1}", AdministrationStrings.AllowAnonymous, specificBehavior.WindowsAuthentication.AllowAnonymousLogons.ToString())); } } else if (behavior is ServiceAuthorizationBehavior) { instance = existingInstance.NewInstance("ServiceAuthorizationBehavior"); ServiceAuthorizationBehavior specificBehavior = (ServiceAuthorizationBehavior)behavior; instance.SetProperty(AdministrationStrings.ImpersonateCallerForAllOperations, specificBehavior.ImpersonateCallerForAllOperations); instance.SetProperty(AdministrationStrings.ImpersonateOnSerializingReply, specificBehavior.ImpersonateOnSerializingReply); if (specificBehavior.RoleProvider != null) { instance.SetProperty(AdministrationStrings.RoleProvider, specificBehavior.RoleProvider.ToString()); } if (specificBehavior.ServiceAuthorizationManager != null) { instance.SetProperty(AdministrationStrings.ServiceAuthorizationManager, specificBehavior.ServiceAuthorizationManager.ToString()); } instance.SetProperty(AdministrationStrings.PrincipalPermissionMode, specificBehavior.PrincipalPermissionMode.ToString()); } else if (behavior is ServiceSecurityAuditBehavior) { instance = existingInstance.NewInstance("ServiceSecurityAuditBehavior"); ServiceSecurityAuditBehavior specificBehavior = (ServiceSecurityAuditBehavior)behavior; instance.SetProperty(AdministrationStrings.AuditLogLocation, specificBehavior.AuditLogLocation.ToString()); instance.SetProperty(AdministrationStrings.SuppressAuditFailure, specificBehavior.SuppressAuditFailure); instance.SetProperty(AdministrationStrings.ServiceAuthorizationAuditLevel, specificBehavior.ServiceAuthorizationAuditLevel.ToString()); instance.SetProperty(AdministrationStrings.MessageAuthenticationAuditLevel, specificBehavior.MessageAuthenticationAuditLevel.ToString()); } else if (behavior is ServiceBehaviorAttribute) { instance = existingInstance.NewInstance("ServiceBehaviorAttribute"); ServiceBehaviorAttribute serviceBehavior = (ServiceBehaviorAttribute)behavior; instance.SetProperty(AdministrationStrings.AddressFilterMode, serviceBehavior.AddressFilterMode.ToString()); instance.SetProperty(AdministrationStrings.AutomaticSessionShutdown, serviceBehavior.AutomaticSessionShutdown); instance.SetProperty(AdministrationStrings.ConcurrencyMode, serviceBehavior.ConcurrencyMode.ToString()); instance.SetProperty(AdministrationStrings.ConfigurationName, serviceBehavior.ConfigurationName); instance.SetProperty(AdministrationStrings.EnsureOrderedDispatch, serviceBehavior.EnsureOrderedDispatch); instance.SetProperty(AdministrationStrings.IgnoreExtensionDataObject, serviceBehavior.IgnoreExtensionDataObject); instance.SetProperty(AdministrationStrings.IncludeExceptionDetailInFaults, serviceBehavior.IncludeExceptionDetailInFaults); instance.SetProperty(AdministrationStrings.InstanceContextMode, serviceBehavior.InstanceContextMode.ToString()); instance.SetProperty(AdministrationStrings.MaxItemsInObjectGraph, serviceBehavior.MaxItemsInObjectGraph); instance.SetProperty(AdministrationStrings.Name, serviceBehavior.Name); instance.SetProperty(AdministrationStrings.Namespace, serviceBehavior.Namespace); instance.SetProperty(AdministrationStrings.ReleaseServiceInstanceOnTransactionComplete, serviceBehavior.ReleaseServiceInstanceOnTransactionComplete); instance.SetProperty(AdministrationStrings.TransactionAutoCompleteOnSessionClose, serviceBehavior.TransactionAutoCompleteOnSessionClose); instance.SetProperty(AdministrationStrings.TransactionIsolationLevel, serviceBehavior.TransactionIsolationLevel.ToString()); if (serviceBehavior.TransactionTimeoutSet) { instance.SetProperty(AdministrationStrings.TransactionTimeout, serviceBehavior.TransactionTimeoutTimespan); } instance.SetProperty(AdministrationStrings.UseSynchronizationContext, serviceBehavior.UseSynchronizationContext); instance.SetProperty(AdministrationStrings.ValidateMustUnderstand, serviceBehavior.ValidateMustUnderstand); } else if (behavior is ServiceDebugBehavior) { instance = existingInstance.NewInstance("ServiceDebugBehavior"); ServiceDebugBehavior specificBehavior = (ServiceDebugBehavior)behavior; if (null != specificBehavior.HttpHelpPageUrl) { instance.SetProperty(AdministrationStrings.HttpHelpPageUrl, specificBehavior.HttpHelpPageUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpHelpPageEnabled, specificBehavior.HttpHelpPageEnabled); if (null != specificBehavior.HttpsHelpPageUrl) { instance.SetProperty(AdministrationStrings.HttpsHelpPageUrl, specificBehavior.HttpsHelpPageUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpsHelpPageEnabled, specificBehavior.HttpsHelpPageEnabled); instance.SetProperty(AdministrationStrings.IncludeExceptionDetailInFaults, specificBehavior.IncludeExceptionDetailInFaults); } else if (behavior is ServiceMetadataBehavior) { instance = existingInstance.NewInstance("ServiceMetadataBehavior"); ServiceMetadataBehavior metadataBehavior = (ServiceMetadataBehavior)behavior; if (null != metadataBehavior.ExternalMetadataLocation) { instance.SetProperty(AdministrationStrings.ExternalMetadataLocation, metadataBehavior.ExternalMetadataLocation.ToString()); } instance.SetProperty(AdministrationStrings.HttpGetEnabled, metadataBehavior.HttpGetEnabled); if (null != metadataBehavior.HttpGetUrl) { instance.SetProperty(AdministrationStrings.HttpGetUrl, metadataBehavior.HttpGetUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpsGetEnabled, metadataBehavior.HttpsGetEnabled); if (null != metadataBehavior.HttpsGetUrl) { instance.SetProperty(AdministrationStrings.HttpsGetUrl, metadataBehavior.HttpsGetUrl.ToString()); } FillMetadataExporterInfo(instance, metadataBehavior.MetadataExporter); } else if (behavior is ServiceThrottlingBehavior) { instance = existingInstance.NewInstance("ServiceThrottlingBehavior"); ServiceThrottlingBehavior throttlingBehavior = (ServiceThrottlingBehavior)behavior; instance.SetProperty(AdministrationStrings.MaxConcurrentCalls, throttlingBehavior.MaxConcurrentCalls); instance.SetProperty(AdministrationStrings.MaxConcurrentSessions, throttlingBehavior.MaxConcurrentSessions); instance.SetProperty(AdministrationStrings.MaxConcurrentInstances, throttlingBehavior.MaxConcurrentInstances); } else if (behavior is ServiceTimeoutsBehavior) { instance = existingInstance.NewInstance("ServiceTimeoutsBehavior"); ServiceTimeoutsBehavior specificBehavior = (ServiceTimeoutsBehavior)behavior; instance.SetProperty(AdministrationStrings.TransactionTimeout, specificBehavior.TransactionTimeout); } else if (behavior is IWmiInstanceProvider) { IWmiInstanceProvider instanceProvider = (IWmiInstanceProvider)behavior; instance = existingInstance.NewInstance(instanceProvider.GetInstanceType()); instanceProvider.FillInstance(instance); } else { instance = existingInstance.NewInstance("Behavior"); } if (null != instance) { instance.SetProperty(AdministrationStrings.Type, behavior.GetType().FullName); } }
private void FillBehaviorInfo(IServiceBehavior behavior, IWmiInstance existingInstance, out IWmiInstance instance) { instance = null; if (behavior is AspNetCompatibilityRequirementsAttribute) { instance = existingInstance.NewInstance("AspNetCompatibilityRequirementsAttribute"); AspNetCompatibilityRequirementsAttribute attribute = (AspNetCompatibilityRequirementsAttribute)behavior; instance.SetProperty("RequirementsMode", attribute.RequirementsMode.ToString()); } else if (behavior is ServiceCredentials) { instance = existingInstance.NewInstance("ServiceCredentials"); ServiceCredentials credentials = (ServiceCredentials)behavior; if ((credentials.ClientCertificate != null) && (credentials.ClientCertificate.Certificate != null)) { string str = string.Empty + string.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", new object[] { credentials.ClientCertificate.Certificate }); instance.SetProperty("ClientCertificate", str); } if ((credentials.IssuedTokenAuthentication != null) && (credentials.IssuedTokenAuthentication.KnownCertificates != null)) { string str2 = (string.Empty + string.Format(CultureInfo.InvariantCulture, "AllowUntrustedRsaIssuers: {0}\n", new object[] { credentials.IssuedTokenAuthentication.AllowUntrustedRsaIssuers }) + string.Format(CultureInfo.InvariantCulture, "CertificateValidationMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.CertificateValidationMode })) + string.Format(CultureInfo.InvariantCulture, "RevocationMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.RevocationMode }) + string.Format(CultureInfo.InvariantCulture, "TrustedStoreLocation: {0}\n", new object[] { credentials.IssuedTokenAuthentication.TrustedStoreLocation }); foreach (X509Certificate2 certificate in credentials.IssuedTokenAuthentication.KnownCertificates) { if (certificate != null) { str2 = str2 + string.Format(CultureInfo.InvariantCulture, "Known certificate: {0}\n", new object[] { certificate.FriendlyName }); } } str2 = str2 + string.Format(CultureInfo.InvariantCulture, "AudienceUriMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.AudienceUriMode }); if (credentials.IssuedTokenAuthentication.AllowedAudienceUris != null) { foreach (string str3 in credentials.IssuedTokenAuthentication.AllowedAudienceUris) { if (str3 != null) { str2 = str2 + string.Format(CultureInfo.InvariantCulture, "Allowed Uri: {0}\n", new object[] { str3 }); } } } instance.SetProperty("IssuedTokenAuthentication", str2); } if ((credentials.Peer != null) && (credentials.Peer.Certificate != null)) { string str4 = string.Empty + string.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", new object[] { credentials.Peer.Certificate.ToString(true) }); instance.SetProperty("Peer", str4); } if ((credentials.SecureConversationAuthentication != null) && (credentials.SecureConversationAuthentication.SecurityContextClaimTypes != null)) { string str5 = string.Empty; foreach (System.Type type in credentials.SecureConversationAuthentication.SecurityContextClaimTypes) { if (type != null) { str5 = str5 + string.Format(CultureInfo.InvariantCulture, "ClaimType: {0}\n", new object[] { type }); } } instance.SetProperty("SecureConversationAuthentication", str5); } if ((credentials.ServiceCertificate != null) && (credentials.ServiceCertificate.Certificate != null)) { instance.SetProperty("ServiceCertificate", credentials.ServiceCertificate.Certificate.ToString()); } if (credentials.UserNameAuthentication != null) { instance.SetProperty("UserNameAuthentication", string.Format(CultureInfo.InvariantCulture, "{0}: {1}", new object[] { "ValidationMode", credentials.UserNameAuthentication.UserNamePasswordValidationMode.ToString() })); } if (credentials.WindowsAuthentication != null) { instance.SetProperty("WindowsAuthentication", string.Format(CultureInfo.InvariantCulture, "{0}: {1}", new object[] { "AllowAnonymous", credentials.WindowsAuthentication.AllowAnonymousLogons.ToString() })); } } else if (behavior is ServiceAuthorizationBehavior) { instance = existingInstance.NewInstance("ServiceAuthorizationBehavior"); ServiceAuthorizationBehavior behavior2 = (ServiceAuthorizationBehavior)behavior; instance.SetProperty("ImpersonateCallerForAllOperations", behavior2.ImpersonateCallerForAllOperations); if (behavior2.RoleProvider != null) { instance.SetProperty("RoleProvider", behavior2.RoleProvider.ToString()); } if (behavior2.ServiceAuthorizationManager != null) { instance.SetProperty("ServiceAuthorizationManager", behavior2.ServiceAuthorizationManager.ToString()); } instance.SetProperty("PrincipalPermissionMode", behavior2.PrincipalPermissionMode.ToString()); } else if (behavior is ServiceSecurityAuditBehavior) { instance = existingInstance.NewInstance("ServiceSecurityAuditBehavior"); ServiceSecurityAuditBehavior behavior3 = (ServiceSecurityAuditBehavior)behavior; instance.SetProperty("AuditLogLocation", behavior3.AuditLogLocation.ToString()); instance.SetProperty("SuppressAuditFailure", behavior3.SuppressAuditFailure); instance.SetProperty("ServiceAuthorizationAuditLevel", behavior3.ServiceAuthorizationAuditLevel.ToString()); instance.SetProperty("MessageAuthenticationAuditLevel", behavior3.MessageAuthenticationAuditLevel.ToString()); } else if (behavior is ServiceBehaviorAttribute) { instance = existingInstance.NewInstance("ServiceBehaviorAttribute"); ServiceBehaviorAttribute attribute2 = (ServiceBehaviorAttribute)behavior; instance.SetProperty("AddressFilterMode", attribute2.AddressFilterMode.ToString()); instance.SetProperty("AutomaticSessionShutdown", attribute2.AutomaticSessionShutdown); instance.SetProperty("ConcurrencyMode", attribute2.ConcurrencyMode.ToString()); instance.SetProperty("ConfigurationName", attribute2.ConfigurationName); instance.SetProperty("IgnoreExtensionDataObject", attribute2.IgnoreExtensionDataObject); instance.SetProperty("IncludeExceptionDetailInFaults", attribute2.IncludeExceptionDetailInFaults); instance.SetProperty("InstanceContextMode", attribute2.InstanceContextMode.ToString()); instance.SetProperty("MaxItemsInObjectGraph", attribute2.MaxItemsInObjectGraph); instance.SetProperty("Name", attribute2.Name); instance.SetProperty("Namespace", attribute2.Namespace); instance.SetProperty("ReleaseServiceInstanceOnTransactionComplete", attribute2.ReleaseServiceInstanceOnTransactionComplete); instance.SetProperty("TransactionAutoCompleteOnSessionClose", attribute2.TransactionAutoCompleteOnSessionClose); instance.SetProperty("TransactionIsolationLevel", attribute2.TransactionIsolationLevel.ToString()); if (attribute2.TransactionTimeoutSet) { instance.SetProperty("TransactionTimeout", attribute2.TransactionTimeoutTimespan); } instance.SetProperty("UseSynchronizationContext", attribute2.UseSynchronizationContext); instance.SetProperty("ValidateMustUnderstand", attribute2.ValidateMustUnderstand); } else if (behavior is ServiceDebugBehavior) { instance = existingInstance.NewInstance("ServiceDebugBehavior"); ServiceDebugBehavior behavior4 = (ServiceDebugBehavior)behavior; if (null != behavior4.HttpHelpPageUrl) { instance.SetProperty("HttpHelpPageUrl", behavior4.HttpHelpPageUrl.ToString()); } instance.SetProperty("HttpHelpPageEnabled", behavior4.HttpHelpPageEnabled); if (null != behavior4.HttpsHelpPageUrl) { instance.SetProperty("HttpsHelpPageUrl", behavior4.HttpsHelpPageUrl.ToString()); } instance.SetProperty("HttpsHelpPageEnabled", behavior4.HttpsHelpPageEnabled); instance.SetProperty("IncludeExceptionDetailInFaults", behavior4.IncludeExceptionDetailInFaults); } else if (behavior is ServiceMetadataBehavior) { instance = existingInstance.NewInstance("ServiceMetadataBehavior"); ServiceMetadataBehavior behavior5 = (ServiceMetadataBehavior)behavior; if (null != behavior5.ExternalMetadataLocation) { instance.SetProperty("ExternalMetadataLocation", behavior5.ExternalMetadataLocation.ToString()); } instance.SetProperty("HttpGetEnabled", behavior5.HttpGetEnabled); if (null != behavior5.HttpGetUrl) { instance.SetProperty("HttpGetUrl", behavior5.HttpGetUrl.ToString()); } instance.SetProperty("HttpsGetEnabled", behavior5.HttpsGetEnabled); if (null != behavior5.HttpsGetUrl) { instance.SetProperty("HttpsGetUrl", behavior5.HttpsGetUrl.ToString()); } this.FillMetadataExporterInfo(instance, behavior5.MetadataExporter); } else if (behavior is ServiceThrottlingBehavior) { instance = existingInstance.NewInstance("ServiceThrottlingBehavior"); ServiceThrottlingBehavior behavior6 = (ServiceThrottlingBehavior)behavior; instance.SetProperty("MaxConcurrentCalls", behavior6.MaxConcurrentCalls); instance.SetProperty("MaxConcurrentSessions", behavior6.MaxConcurrentSessions); instance.SetProperty("MaxConcurrentInstances", behavior6.MaxConcurrentInstances); } else if (behavior is ServiceTimeoutsBehavior) { instance = existingInstance.NewInstance("ServiceTimeoutsBehavior"); ServiceTimeoutsBehavior behavior7 = (ServiceTimeoutsBehavior)behavior; instance.SetProperty("TransactionTimeout", behavior7.TransactionTimeout); } else if (behavior is IWmiInstanceProvider) { IWmiInstanceProvider provider = (IWmiInstanceProvider)behavior; instance = existingInstance.NewInstance(provider.GetInstanceType()); provider.FillInstance(instance); } else { instance = existingInstance.NewInstance("Behavior"); } if (instance != null) { instance.SetProperty("Type", behavior.GetType().FullName); } }