本文整理汇总了C#中System.Xml.Serialization.XmlSerializerNamespaces.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializerNamespaces.ToArray方法的具体用法?C# XmlSerializerNamespaces.ToArray怎么用?C# XmlSerializerNamespaces.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlSerializerNamespaces
的用法示例。
在下文中一共展示了XmlSerializerNamespaces.ToArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlSerializerNamespaceResolver
public XmlSerializerNamespaceResolver(XmlSerializerNamespaces serializerNamespaces) {
serializerNamespaces.ToArray().ForEach(qns => {
if (!qns.IsEmpty) {
m_namespaces.Add(qns.Name, qns.Namespace);
}
});
}
示例2: Initialize
internal void Initialize (XmlWriter writer, XmlSerializerNamespaces nss)
{
this.writer = writer;
if (nss != null)
{
namespaces = new ArrayList ();
foreach (XmlQualifiedName ns in nss.ToArray())
if (ns.Name != "" && ns.Namespace != "")
namespaces.Add (ns);
}
}
示例3: WriteStartElement
protected void WriteStartElement (string name, string ns, Object o, bool writePrefixed, XmlSerializerNamespaces xmlns)
{
WriteStartElement (name, ns, o, writePrefixed, xmlns != null ? xmlns.ToArray () : null);
}
示例4: FromOpenSearchDescription
//---------------------------------------------------------------------------------------------------------------------
/// <summary>Creates an OpenSearchParameterValueSet instance based on the specified OpenSearch template and optional additional parameter information.</summary>
/// <returns>A new OpenSearchParameterValueSet instance.</returns>
/// <param name="template">An OpenSearch template URL.</param>
/// <param name="origParams">An array of objects containing parameter information as defined by the OpenSearch Parameter extension.</returns>
public static OpenSearchParameterValueSet FromOpenSearchDescription(string template, OpenSearchDescriptionUrlParameter[] origParams = null, XmlSerializerNamespaces namespaces = null)
{
OpenSearchParameterValueSet result = new OpenSearchParameterValueSet();
Dictionary<string, OpenSearchDescriptionUrlParameter> tempParameters = new Dictionary<string, OpenSearchDescriptionUrlParameter>();
Dictionary<string, string> tempNamespaces = null;
if (origParams != null) {
foreach (OpenSearchDescriptionUrlParameter origParam in origParams) tempParameters.Add(origParam.Name, origParam);
}
if (namespaces != null) {
result.nameTable = new NameTable();
tempNamespaces = new Dictionary<string, string>();
foreach (XmlQualifiedName qn in namespaces.ToArray()) {
tempNamespaces.Add(qn.Name, result.nameTable.Add(qn.Namespace));
}
}
// Make sure URL is valid
Match match = urlRegex.Match(template);
if (!match.Success) throw new OpenSearchException(String.Format("Invalid URL template: {0}", template));
// Split by query string parameter and add parameter definitions to the internal dictionaries:
// parameters can be settable (e.g. name={key}, name={prefix:key}) or fixed (name=value)
string[] items = match.Groups[1].Value.Split('&');
foreach (string item in items) {
Match match2 = parameterDefinitionRegex.Match(item);
if (!match2.Success) continue;
string name = match2.Groups[1].Value;
OpenSearchParameterDefinition paramDef;
if (match2.Groups[3].Success) { // parameter is settable
string identifier = match2.Groups[3].Value;
string identifierNamespaceUri = null, identifierLocalName = null;
if (tempNamespaces != null) {
string[] parts = identifier.Split(':');
if (parts.Length == 2) {
identifierNamespaceUri = tempNamespaces.ContainsKey(parts[0]) ? tempNamespaces[parts[0]] : null;
if (identifierNamespaceUri != null) identifierLocalName = parts[1];
}
}
paramDef = new OpenSearchParameterDefinition(name, identifier, identifierNamespaceUri, identifierLocalName, tempParameters.ContainsKey(name) ? tempParameters[name] : null);
result.parametersByIdentifier[identifier] = paramDef;
} else { // parameter is fixed
paramDef = new OpenSearchParameterDefinition(name);
result.values[paramDef] = new string[] {match2.Groups[2].Value};
}
result.parametersByName[paramDef.Name] = paramDef;
}
return result;
}
示例5: WriteStartElement
protected void WriteStartElement (string name, string ns, Object o, bool writePrefixed, XmlSerializerNamespaces xmlns)
{
if (xmlns == null)
throw new ArgumentNullException ("xmlns");
WriteStartElement (name, ns, o, writePrefixed, xmlns.ToArray ());
}
示例6: XmlSerializerNamespaces
public XmlSerializerNamespaces(XmlSerializerNamespaces namespaces)
: this(namespaces.ToArray())
{}
示例7: GetNamespace
private String GetNamespace( XmlSerializerNamespaces namespaces )
{
var sb = new StringBuilder();
foreach (XmlQualifiedName name in namespaces.ToArray())
{
sb.Append( name.Namespace );
}
return sb.ToString();
}
示例8: XmppSerializer
/// <summary>
/// Initializes a new instance of the <see cref = "XmppSerializer" /> class.
/// </summary>
/// <param name = "elementName">Name of the element.</param>
/// <param name = "schema">The schema.</param>
/// <param name = "prefix">The prefix.</param>
/// <param name = "defaultNamespace">The default namespace.</param>
/// <param name = "serializerType">Type of the serializer.</param>
private XmppSerializer(string elementName, string schema, string prefix, string defaultNamespace, Type serializerType)
{
this.elementName = elementName;
this.serializerType = serializerType;
this.schema = schema;
this.prefix = prefix;
this.defaultNamespace = defaultNamespace;
serializer = new XmlSerializer(serializerType);
nameTable = new NameTable();
nsMgr = new XmlNamespaceManager(nameTable);
context = new XmlParserContext(nameTable, nsMgr, null, XmlSpace.None);
namespaces = new XmlSerializerNamespaces();
namespaces.Add(prefix, defaultNamespace);
foreach (XmlQualifiedName name in namespaces.ToArray())
{
nsMgr.AddNamespace(name.Name, name.Namespace);
}
}