本文整理汇总了C#中System.Xml.XmlNamespaceManager.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNamespaceManager.Cast方法的具体用法?C# XmlNamespaceManager.Cast怎么用?C# XmlNamespaceManager.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNamespaceManager
的用法示例。
在下文中一共展示了XmlNamespaceManager.Cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NameValueCollection
/// <summary>Transforms the current request in a collection of corresponding key-value pairs.</summary>
/// <returns>The collection of key-value pairs.</returns>
NameValueCollection Ows.IRequest.ToKeyValuePairs()
{
var ret = new NameValueCollection();
ret.Add( "request", "GetRecords" );
ret.Add( "service", HttpUtility.UrlEncode(this.Content.service) );
ret.Add( "version", HttpUtility.UrlEncode(this.Content.version) );
// namespace
var namespaceManager = new XmlNamespaceManager( new NameTable() );
XNamespace dn = this.Untyped.GetDefaultNamespace();
if( dn != XNamespace.None )
namespaceManager.AddNamespace( string.Empty, dn.NamespaceName );
var namespaces = from at in this.Untyped.Attributes()
where at.IsNamespaceDeclaration
select new {
Prefix = at.Parent.GetPrefixOfNamespace( at.Value ),
Uri = at.Value
};
namespaces.ToList().ForEach( n => namespaceManager.AddNamespace( n.Prefix, n.Uri ) );
ret.Add(
"namespace",
string.Join(
",",
namespaceManager.Cast<string>()
.Where( s => !string.IsNullOrEmpty(namespaceManager.LookupNamespace( s ?? string.Empty )))
.Select( s => string.Concat( "xmlns(", !string.IsNullOrEmpty(s) ? string.Concat( s, "=" ) : string.Empty, HttpUtility.UrlEncode(namespaceManager.LookupNamespace( s ?? string.Empty )), ")" ) )
)
);
if( !string.IsNullOrEmpty( this.resultType) )
ret.Add( "resulttype", HttpUtility.UrlEncode(this.resultType) );
if( this.requestId != null )
ret.Add( "requestid", HttpUtility.UrlEncode(this.requestId.ToString()) );
if( !string.IsNullOrEmpty( this.outputFormat ) )
ret.Add( "outputformat", HttpUtility.UrlEncode(this.outputFormat) );
if( outputSchema != null )
ret.Add( "outputschema", HttpUtility.UrlEncode(outputSchema.ToString()) );
if (startPosition!=1)
ret.Add( "startposition", this.startPosition.ToString( "F0", CultureInfo.InvariantCulture ) );
if (maxRecords!=10)
ret.Add( "maxrecords", this.maxRecords.ToString( "F0", CultureInfo.InvariantCulture ) );
var query=this.AbstractQuery as Query;
if( query != null )
{
var tnElement=Content.AbstractQuery.Untyped.Attribute("typeNames");
if (tnElement!=null)
ret.Add("typenames", string.Join(",", tnElement.Value.Split(' ').Select( s => HttpUtility.UrlEncode(s))));
if ( query.Untyped.Elements("{http://www.opengis.net/cat/csw/2.0.2}ElementSetName").Any<XElement>() && !string.IsNullOrEmpty(query.ElementSetName.TypedValue))
ret.Add( "elementsetname", HttpUtility.UrlEncode(query.ElementSetName.TypedValue) );
if ((query.ElementName!=null) && (query.ElementName.Count>0))
{
var elementNames=from el in query.Untyped.Descendants()
where el.Name=="{http://www.opengis.net/cat/csw/2.0.2}ElementName"
select HttpUtility.UrlEncode(el.Value);
ret.Add("elementname", string.Join(",", elementNames));
}
if (query.Untyped.Element("{http://www.opengis.net/cat/csw/2.0.2}Constraint")!=null)
{
if (query.Constraint.Untyped.Element("{http://www.opengis.net/ogc}Filter")!=null)
{
ret.Add( "constraintlanguage", "FILTER" );
ret.Add( "constraint", HttpUtility.UrlEncode(query.Constraint.Filter.Untyped.ToString(SaveOptions.OmitDuplicateNamespaces)));
} else if (!string.IsNullOrWhiteSpace(query.Constraint.CqlText))
{
ret.Add( "constraintlanguage", "CQL_TEXT" );
ret.Add( "constraint", string.Concat("\"", HttpUtility.UrlEncode(query.Constraint.CqlText), "\"" ));
}
if (!string.IsNullOrEmpty(query.Constraint.version))
ret.Add("constraint_language_version", query.Constraint.version);
}
}
return ret;
}