bool TryCreateMatchingExtension(BindingElement bindingElement, ExtensionElementCollection collection, bool allowDerivedTypes, string assemblyName, out BindingElementExtensionElement result) { result = null; foreach (ExtensionElement element in collection) { BindingElementExtensionElement bindingElementExtension = Activator.CreateInstance(Type.GetType(element.Type, true)) as BindingElementExtensionElement; if (null == bindingElementExtension) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidExtensionType, element.Type, assemblyName, ConfigurationStrings.BindingElementExtensions))); } bool isMatch; if (allowDerivedTypes) { isMatch = bindingElementExtension.BindingElementType.IsAssignableFrom(bindingElement.GetType()); } else { isMatch = bindingElementExtension.BindingElementType.Equals(bindingElement.GetType()); } if (isMatch) { result = bindingElementExtension; return true; } } return false; }
private bool TryCreateMatchingExtension(BindingElement bindingElement, ExtensionElementCollection collection, bool allowDerivedTypes, string assemblyName, out BindingElementExtensionElement result) { result = null; foreach (ExtensionElement element in collection) { bool flag; BindingElementExtensionElement element2 = Activator.CreateInstance(System.Type.GetType(element.Type, true)) as BindingElementExtensionElement; if (element2 == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidExtensionType", new object[] { element.Type, assemblyName, "bindingElementExtensions" }))); } if (allowDerivedTypes) { flag = element2.BindingElementType.IsAssignableFrom(bindingElement.GetType()); } else { flag = element2.BindingElementType.Equals(bindingElement.GetType()); } if (flag) { result = element2; return true; } } return false; }