本文整理汇总了C#中System.Xml.XmlNodeList.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeList.Cast方法的具体用法?C# XmlNodeList.Cast怎么用?C# XmlNodeList.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNodeList
的用法示例。
在下文中一共展示了XmlNodeList.Cast方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadCustomConfiguration
public override void LoadCustomConfiguration(XmlNodeList nodeList)
{
if (nodeList == null || nodeList.Count == 0)
{
throw new ConfigurationErrorsException("No configuration provided.");
}
var node = nodeList.Cast<XmlNode>().FirstOrDefault(x => x.LocalName == "trustedIssuerMetadata");
if (node == null)
{
throw new ConfigurationErrorsException("Expected 'trustedIssuerMetadata' element.");
}
var elem = node as XmlElement;
var name = elem.Attributes["issuerName"];
if (name == null || String.IsNullOrWhiteSpace(name.Value))
{
throw new ConfigurationErrorsException("Expected 'issuerName' attribute.");
}
var address = elem.Attributes["metadataAddress"];
if (address == null || String.IsNullOrWhiteSpace(address.Value))
{
throw new ConfigurationErrorsException("Expected 'metadataAddress' attribute.");
}
this.metadataAddress = new Uri(address.Value);
this.issuerName = name.Value;
}
开发者ID:Rameshcyadav,项目名称:Thinktecture.IdentityModel.45,代码行数:30,代码来源:MetadataBasedIssuerNameRegistry.cs
示例2: ConvertToDocuments
private static IEnumerable<IPublishedContent> ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing)
{
return xmlNodes.Cast<XmlNode>()
.Select(xmlNode => PublishedContentModelFactory.CreateModel(new XmlPublishedContent(xmlNode, isPreviewing)));
}
示例3: ToXElementList
private static IEnumerable<XElement> ToXElementList(XmlNodeList xmlNodeList) {
return xmlNodeList.Cast<XmlNode>().Select(GetXElement);
}
示例4: LoadCustomConfiguration
void LoadCustomConfiguration(XmlNodeList nodeList)
{
if (nodeList == null || nodeList.Count == 0)
{
throw new ConfigurationErrorsException("No configuration provided.");
}
var node = nodeList.Cast<XmlNode>().FirstOrDefault(x => x.LocalName == "metadataCache");
if (node == null)
{
throw new ConfigurationErrorsException("Expected 'metadataCache' element.");
}
var elem = node as XmlElement;
var protect = elem.Attributes["protect"];
if (protect != null)
{
if (protect.Value != "true" && protect.Value != "false")
{
throw new ConfigurationErrorsException("Expected 'protect' to be 'true' or 'false'.");
}
this.protect = protect.Value == "true";
}
var cacheType = elem.Attributes["cacheType"];
if (cacheType == null || String.IsNullOrWhiteSpace(cacheType.Value))
{
throw new ConfigurationErrorsException("Expected 'cacheType' attribute.");
}
var cacheDuration = elem.Attributes["cacheDuration"];
if (cacheDuration == null || String.IsNullOrWhiteSpace(cacheDuration.Value))
{
this.cacheDuration = DefaultCacheDuration;
}
else
{
if (!Int32.TryParse(cacheDuration.Value, out this.cacheDuration))
{
throw new ConfigurationErrorsException("Attribute 'cacheType' not a valid Int32.");
}
}
var type = Type.GetType(cacheType.Value);
var xmlCtor = type.GetConstructor(new Type[]{typeof(XmlNodeList)});
IMetadataCache cacheInstance = null;
if (xmlCtor != null)
{
cacheInstance = (IMetadataCache)Activator.CreateInstance(type, elem.ChildNodes);
}
else
{
cacheInstance = (IMetadataCache)Activator.CreateInstance(type);
}
SetCache(cacheInstance);
}
开发者ID:GaryMcAllister,项目名称:Thinktecture.IdentityModel.40,代码行数:57,代码来源:CachingMetadataBasedIssuerNameRegistry.cs
示例5: LoadCustomConfiguration
public override void LoadCustomConfiguration(XmlNodeList nodeList)
{
base.LoadCustomConfiguration(nodeList);
if (nodeList == null || nodeList.Count == 0)
{
throw new ConfigurationErrorsException("No configuration provided.");
}
var node = nodeList.Cast<XmlNode>().FirstOrDefault(x => x.LocalName == "metadataCache");
if (node == null)
{
throw new ConfigurationErrorsException("Expected 'metadataCache' element.");
}
var elem = node as XmlElement;
var protect = elem.Attributes["protect"];
if (protect != null)
{
if (protect.Value != "true" && protect.Value != "false")
{
throw new ConfigurationErrorsException("Expected 'protect' to be 'true' or 'false'.");
}
this.protect = protect.Value == "true";
}
var cacheType = elem.Attributes["cacheType"];
if (cacheType == null || String.IsNullOrWhiteSpace(cacheType.Value))
{
throw new ConfigurationErrorsException("Expected 'cacheType' attribute.");
}
var cacheDuration = elem.Attributes["cacheDuration"];
if (cacheDuration == null || String.IsNullOrWhiteSpace(cacheDuration.Value))
{
this.cacheDuration = DefaultCacheDuration;
}
else
{
if (!Int32.TryParse(cacheDuration.Value, out this.cacheDuration))
{
throw new ConfigurationErrorsException("Attribute 'cacheType' not a valid Int32.");
}
}
var cacheInstance = (IMetadataCache)Activator.CreateInstance(Type.GetType(cacheType.Value));
var config = cacheInstance as ICustomIdentityConfiguration;
if (config != null)
{
config.LoadCustomConfiguration(elem.ChildNodes);
}
SetCache(cacheInstance);
try
{
this.LoadMetadata();
}
catch (Exception ex)
{
throw new ConfigurationErrorsException(ex.ToString());
}
}
开发者ID:nhlatour,项目名称:Thinktecture.IdentityModel,代码行数:63,代码来源:CachingMetadataBasedIssuerNameRegistry.cs
示例6: ConvertToDocuments
private static IEnumerable<IPublishedContent> ConvertToDocuments(XmlNodeList xmlNodes)
{
return xmlNodes.Cast<XmlNode>().Select(xmlNode => new Models.XmlPublishedContent(xmlNode));
}
示例7: GetNames
private static IEnumerable<string> GetNames(XmlNodeList elements)
{
return elements.Cast<XmlElement>()
.Select(x => x.GetAttributeValue("name"));
}
示例8: ExtractGeography
private SqlGeography ExtractGeography(XmlNamespaceManager ns, XmlNodeList points, out DateTime? minDate)
{
minDate = null;
SqlGeography result = null;
if (points.Count < 2) return null;
string goodString = GetValidCoordinateString(points.Cast<XmlElement>().Select(f => GetCoordinate(ns, f)).ToList());
// Check for multiple points in the line
if (goodString.IndexOf(',') >= 0)
{
result = SqlGeography.STLineFromText(new SqlChars("LINESTRING(" + goodString + ")"), GeographyServices.SRID);
}
return result;
}
示例9: ParseCategories
private string[] ParseCategories(XmlNodeList xmlCategories)
{
return xmlCategories.Cast<XmlNode>().Select(n => GetAttributeStringValue(n, "slug")).ToArray();
}
示例10: GetDidYouMeans
private string GetDidYouMeans(XmlNodeList xmlNodeList)
{
var nodes = new List<XmlNode>(xmlNodeList.Cast<XmlNode>());
if (nodes.Count == 0)
return null;
nodes.OrderByDescending(node => double.Parse(node.Attributes["score"].Value, CultureInfo.InvariantCulture));
var didyoumeans = nodes.Select(node =>
$"\"{node.InnerText}\" (score: {Math.Round(double.Parse(node.Attributes["score"].Value, CultureInfo.InvariantCulture) * 100)}%)");
var firstItems = string.Join(", ", didyoumeans.Take(didyoumeans.Count() - 1));
string result;
if (didyoumeans.Count() > 1)
{
result = firstItems + " or " + didyoumeans.Last();
}
else
{
result = firstItems;
}
return result;
}