static void ConfigSoapExtensionTypes(XmlNode section, ArrayList extensions) { if (section.Attributes != null && section.Attributes.Count != 0) { ThrowException("Unrecognized attribute", section); } XmlNodeList nodes = section.ChildNodes; foreach (XmlNode child in nodes) { XmlNodeType ntype = child.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) { continue; } if (ntype != XmlNodeType.Element) { ThrowException("Only elements allowed", child); } string name = child.Name; if (name == "add") { string seType = AttValue("type", child, false); string priority = AttValue("priority", child); string group = AttValue("group", child); if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } WSExtensionConfig wse = new WSExtensionConfig(); Exception e = wse.SetType(seType); if (e != null) { ThrowException(e.Message, child); } e = wse.SetPriority(priority); if (e != null) { ThrowException(e.Message, child); } e = wse.SetGroup(group); if (e != null) { ThrowException(e.Message, child); } extensions.Add(wse); continue; } ThrowException("Unexpected element", child); } }
static void ConfigFormatExtensionTypes(XmlNode section, WSConfig config) { if (section.Attributes != null && section.Attributes.Count != 0) { ThrowException("Unrecognized attribute", section); } XmlNodeList nodes = section.ChildNodes; foreach (XmlNode child in nodes) { XmlNodeType ntype = child.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) { continue; } if (ntype != XmlNodeType.Element) { ThrowException("Only elements allowed", child); } string name = child.Name; if (name == "add") { string typeName = AttValue("name", child, false); if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } try { config.FormatExtensionTypes.Add(Type.GetType(typeName, true)); } catch (Exception e) { ThrowException(e.Message, child); } continue; } ThrowException("Unexpected element", child); } }
static void ThrowException(string message, XmlNode node) { HandlersUtil.ThrowException(message, node); }
static void ConfigProtocols(XmlNode section, WSConfig config) { if (section.Attributes != null && section.Attributes.Count != 0) { ThrowException("Unrecognized attribute", section); } XmlNodeList nodes = section.ChildNodes; foreach (XmlNode child in nodes) { XmlNodeType ntype = child.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) { continue; } if (ntype != XmlNodeType.Element) { ThrowException("Only elements allowed", child); } string name = child.Name; string error; if (name == "add") { string protoName = AttValue("name", child, false); if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } if (!config.AddProtocol(protoName, out error)) { ThrowException(error, child); } continue; } if (name == "remove") { string protoName = AttValue("name", child, false); if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } if (!config.RemoveProtocol(protoName, out error)) { ThrowException(error, child); } continue; } if (name == "clear") { if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } config.ClearProtocol(); continue; } ThrowException("Unexpected element", child); } }
public object Create(object parent, object context, XmlNode section) { WSConfig config = new WSConfig(parent as WSConfig, context); if (section.Attributes != null && section.Attributes.Count != 0) { ThrowException("Unrecognized attribute", section); } XmlNodeList nodes = section.ChildNodes; foreach (XmlNode child in nodes) { XmlNodeType ntype = child.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) { continue; } if (ntype != XmlNodeType.Element) { ThrowException("Only elements allowed", child); } string name = child.Name; if (name == "protocols") { ConfigProtocols(child, config); continue; } if (name == "soapExtensionTypes") { ConfigSoapExtensionTypes(child, config.ExtensionTypes); continue; } if (name == "soapExtensionReflectorTypes") { ConfigSoapExtensionTypes(child, config.ExtensionReflectorTypes); continue; } if (name == "soapExtensionImporterTypes") { ConfigSoapExtensionTypes(child, config.ExtensionImporterTypes); continue; } if (name == "serviceDescriptionFormatExtensionTypes") { ConfigFormatExtensionTypes(child, config); continue; } if (name == "wsdlHelpGenerator") { string href = AttValue("href", child, false); if (child.Attributes != null && child.Attributes.Count != 0) { HandlersUtil.ThrowException("Unrecognized attribute", child); } config.ConfigFilePath = context as string; config.WsdlHelpPage = href; continue; } ThrowException("Unexpected element", child); } return(config); }