本文整理汇总了C#中System.HasAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# System.HasAttribute方法的具体用法?C# System.HasAttribute怎么用?C# System.HasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.HasAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItemErrorInfo
internal static string GetItemErrorInfo(System.Xml.XmlElement xmlItem)
{
string s = "";
if (xmlItem.HasAttribute("assembly"))
s = s + xmlItem.GetAttribute("assembly");
if (xmlItem.HasAttribute("class"))
s = s + xmlItem.GetAttribute("class");
return s;
}
示例2: ParsingContext
public ParsingContext(System.Xml.XmlElement node, ParsingContext parent)
{
this.parent = parent;
if (node.HasAttribute("templateNs"))
TemplateNamespace = node.GetAttribute("templateNs");
if (node.HasAttribute("ns"))
Namespace = node.GetAttribute("ns");
if (node.HasAttribute("dictionary"))
Dictionary = node.GetAttribute("dictionary");
if (node.HasAttribute("name"))
setName(new QName(node.GetAttribute("name"), Namespace));
}
示例3: Parse
public virtual Field Parse(System.Xml.XmlElement element, ParsingContext context)
{
if (element.HasAttribute("name"))
{
QName templateName = element.HasAttribute("templateNs") ? new QName(element.GetAttribute("name"), element.GetAttribute("templateNs")) : new QName(element.GetAttribute("name"), "");
if (context.TemplateRegistry.IsDefined(templateName))
return new StaticTemplateReference(context.TemplateRegistry.get_Renamed(templateName));
context.ErrorHandler.Error(Error.FastConstants.D8_TEMPLATE_NOT_EXIST, "The template \"" + templateName + "\" was not found.");
return null;
}
return DynamicTemplateReference.INSTANCE;
}
示例4: Configure
public override void Configure(System.Xml.XmlElement element)
{
// Reflect some of the necessary protected methods on the SimpleCache class that are needed
Type type = typeof(SimpleCache);
getCachedItemMethod = type.GetMethod("GetCachedItem", BindingFlags.Instance | BindingFlags.NonPublic);
purgeMethod = type.GetMethod("Purge", BindingFlags.Instance | BindingFlags.NonPublic);
// Instantiate and configure the SimpleCache instance to be used for the local cache
cache = new SimpleCache();
cache.Configure(element);
// Allow the base CacheBase class to configure itself
base.Configure(element);
// Check for and configure the queue
if (element.HasAttribute("path"))
{
string path = element.GetAttribute("path");
if (MessageQueue.Exists(path))
{
queue = new MessageQueue(path);
queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(CachedItem) });
// Start the listener thread
listen = true;
listenThread = new Thread(new ThreadStart(Listen));
listenThread.IsBackground = true;
listenThread.Start();
}
else
{
throw new ConfigurationErrorsException("The specified queue path (" + path + ") does not exist.");
}
}
}
示例5: Parse
public override Field Parse(System.Xml.XmlElement fieldNode, bool optional, ParsingContext context)
{
Operator.Operator operator_Renamed = Operator.Operator.NONE;
string defaultValue = null;
string key = null;
string ns = "";
System.Xml.XmlElement operatorElement = GetOperatorElement(fieldNode);
if (operatorElement != null)
{
if (operatorElement.HasAttribute("value"))
defaultValue = operatorElement.GetAttribute("value");
operator_Renamed = Operator.Operator.GetOperator(operatorElement.Name);
if (operatorElement.HasAttribute("key"))
key = operatorElement.GetAttribute("key");
if (operatorElement.HasAttribute("ns"))
ns = operatorElement.GetAttribute("ns");
if (operatorElement.HasAttribute("dictionary"))
context.Dictionary = operatorElement.GetAttribute("dictionary");
}
FASTType type = GetType(fieldNode, context);
var scalar = new Scalar(GetName(fieldNode, context), type, operator_Renamed, type.GetValue(defaultValue), optional);
if (fieldNode.HasAttribute("id"))
scalar.Id = fieldNode.GetAttribute("id");
if (key != null)
scalar.Key = new QName(key, ns);
scalar.Dictionary = context.Dictionary;
ParseExternalAttributes(fieldNode, scalar);
return scalar;
}
示例6: SharingNode
public SharingNode(Microsoft.Samples.FeedSync.Feed i_Feed, System.Xml.XmlElement i_SharingXmlElement)
{
m_Feed = i_Feed;
m_XmlElement = i_SharingXmlElement;
if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.SINCE_ATTRIBUTE))
m_Since = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.SINCE_ATTRIBUTE);
if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.UNTIL_ATTRIBUTE))
m_Until = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.SINCE_ATTRIBUTE);
if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.EXPIRES_ATTRIBUTE))
{
string Expires = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.EXPIRES_ATTRIBUTE);
System.DateTime ExpiresDateTime;
if (System.DateTime.TryParse(Expires, out ExpiresDateTime))
m_Expires = ExpiresDateTime;
}
string XPathQuery = System.String.Format
(
"{0}:{1}",
m_Feed.FeedSyncNamespacePrefix,
Microsoft.Samples.FeedSync.Constants.RELATED_ELEMENT_NAME
);
System.Xml.XmlNodeList RelatedNodeList = i_SharingXmlElement.SelectNodes
(
XPathQuery,
m_Feed.XmlNamespaceManager
);
foreach (System.Xml.XmlElement RelatedNodeXmlElement in RelatedNodeList)
{
Microsoft.Samples.FeedSync.RelatedNode RelatedNode = Microsoft.Samples.FeedSync.RelatedNode.CreateFromXmlElement
(
this,
RelatedNodeXmlElement
);
m_RelatedNodeList.Add(RelatedNode);
}
}
示例7: Configure
public override void Configure(System.Xml.XmlElement element)
{
base.Configure(element);
if (element.HasAttribute("availableMemoryLimit"))
{
availableMemoryLimit = Single.Parse(element.GetAttribute("availableMemoryLimit"));
}
else
{
availableMemoryLimit = 96.0f;
}
if (element.HasAttribute("miserInterval"))
{
miserInterval = TimeSpan.Parse(element.GetAttribute("miserInterval"));
}
else
{
miserInterval = TimeSpan.FromMinutes(1);
}
XmlElement volatileElement = (XmlElement) element.SelectSingleNode("volatileCache");
if (volatileElement.HasAttribute("type"))
{
Type type = Type.GetType(volatileElement.GetAttribute("type"));
volatileCache = (CacheBase) type.Assembly.CreateInstance(type.FullName);
volatileCache.Configure(volatileElement);
}
XmlElement persistentElement = (XmlElement) element.SelectSingleNode("persistentCache");
if (persistentElement.HasAttribute("type"))
{
Type type = Type.GetType(persistentElement.GetAttribute("type"));
persistentCache = (CacheBase) type.Assembly.CreateInstance(type.FullName);
persistentCache.Configure(persistentElement);
}
Type cacheBaseType = typeof(CacheBase);
getCachedItemMethod = cacheBaseType.GetMethod("GetCachedItem", BindingFlags.Instance | BindingFlags.NonPublic);
purgeMethod = cacheBaseType.GetMethod("Purge", BindingFlags.Instance | BindingFlags.NonPublic);
miserTimer = new Timer(new TimerCallback(MiserTimerCallback), null, miserInterval, miserInterval);
}
示例8: Parse
public override Field Parse(System.Xml.XmlElement templateElement, bool optional, ParsingContext context)
{
var messageTemplate = new MessageTemplate(getTemplateName(templateElement, context), ParseFields(templateElement, context));
ParseMore(templateElement, messageTemplate, context);
if (loadTemplateIdFromAuxId && templateElement.HasAttribute("id"))
{
try
{
int templateId = System.Int32.Parse(templateElement.GetAttribute("id"));
context.TemplateRegistry.Register(templateId, messageTemplate);
}
catch (System.FormatException)
{
context.TemplateRegistry.Define(messageTemplate);
}
}
else
context.TemplateRegistry.Define(messageTemplate);
return messageTemplate;
}
示例9: LoadXml
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Algorithm"))
{
this.algorithm = xmlElement.GetAttribute("Algorithm");
}
else
{
this.algorithm = "";
}
xmlNodeList = xmlElement.SelectNodes("XPath");
if (xmlNodeList.Count != 0)
{
this.xpath = xmlNodeList.Item(0).InnerText;
}
else
{
this.xpath = "";
}
}
示例10: LoadXml
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("URI"))
{
this.uriAttribute = xmlElement.GetAttribute("URI");
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:Issuer", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.issuer = xmlNodeList.Item(0).InnerText;
}
xmlNodeList = xmlElement.SelectNodes("xsd:IssueTime", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.issueTime = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Local);
}
xmlNodeList = xmlElement.SelectNodes("xsd:Number", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.number = long.Parse(xmlNodeList.Item(0).InnerText);
}
}
示例11: LoadXml
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);
xmlNodeList = xmlElement.SelectNodes("xsd:CertRefs", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.certRefs = new CertRefs();
this.certRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
}
}
示例12: SyncNode
private SyncNode(Microsoft.Samples.FeedSync.FeedItemNode i_FeedItemNode, System.Xml.XmlElement i_SyncNodeXmlElement)
{
m_FeedItemNode = i_FeedItemNode;
m_XmlElement = i_SyncNodeXmlElement;
m_ID = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.ID_ATTRIBUTE);
m_Updates = System.Convert.ToInt32(m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.UPDATES_ATTRIBUTE));
if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE))
m_Deleted = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE) == "true");
if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE))
m_NoConflicts = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE) == "true");
string XPathQuery = System.String.Format
(
"{0}:{1}",
m_FeedItemNode.Feed.FeedSyncNamespacePrefix,
Microsoft.Samples.FeedSync.Constants.HISTORY_ELEMENT_NAME
);
System.Xml.XmlNodeList HistoryNodeList = i_SyncNodeXmlElement.SelectNodes
(
XPathQuery,
i_FeedItemNode.Feed.XmlNamespaceManager
);
foreach (System.Xml.XmlElement HistoryNodeXmlElement in HistoryNodeList)
{
Microsoft.Samples.FeedSync.HistoryNode HistoryNode = Microsoft.Samples.FeedSync.HistoryNode.CreateFromXmlElement
(
this,
HistoryNodeXmlElement
);
m_HistoryNodeList.Add(HistoryNode);
}
if (!m_NoConflicts)
{
XPathQuery = System.String.Format
(
"{0}:{1}",
m_FeedItemNode.Feed.FeedSyncNamespacePrefix,
Microsoft.Samples.FeedSync.Constants.CONFLICTS_ELEMENT_NAME
);
m_ConflictsNodeXmlElement = (System.Xml.XmlElement)i_SyncNodeXmlElement.SelectSingleNode
(
XPathQuery,
m_FeedItemNode.Feed.XmlNamespaceManager
);
if (m_ConflictsNodeXmlElement != null)
{
System.Xml.XmlNodeList FeedItemXmlNodeList = m_ConflictsNodeXmlElement.SelectNodes
(
m_FeedItemNode.Feed.FeedItemXPathQuery,
m_FeedItemNode.Feed.XmlNamespaceManager
);
foreach (System.Xml.XmlElement ConflictFeedItemNodeXmlElement in FeedItemXmlNodeList)
{
Microsoft.Samples.FeedSync.FeedItemNode ConflictFeedItemNode = this.CreateConflictItemNodeFromXmlElement(ConflictFeedItemNodeXmlElement);
string Key = System.String.Format
(
"{0}{1}{2}",
ConflictFeedItemNode.SyncNode.Updates,
ConflictFeedItemNode.SyncNode.TopMostHistoryNode.Sequence,
ConflictFeedItemNode.SyncNode.TopMostHistoryNode.By
);
if (ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime != null)
Key += ((System.DateTime)ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime);
if (!m_ConflictNodeList.ContainsKey(Key))
m_ConflictNodeList.Add(Key, ConflictFeedItemNode);
}
}
}
}
示例13: RelatedNode
private RelatedNode(Microsoft.Samples.FeedSync.SharingNode i_SharingNode, System.Xml.XmlElement i_RelatedNodeXmlElement)
{
bool InvalidXmlElement =
(i_RelatedNodeXmlElement.LocalName != Microsoft.Samples.FeedSync.Constants.RELATED_ELEMENT_NAME) ||
(i_RelatedNodeXmlElement.NamespaceURI != Microsoft.Samples.FeedSync.Constants.FEEDSYNC_XML_NAMESPACE_URI);
if (InvalidXmlElement)
throw new System.Exception("Invalid xml element!");
m_SharingNode = i_SharingNode;
m_XmlElement = i_RelatedNodeXmlElement;
string RelatedNodeType = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.TYPE_ATTRIBUTE);
switch (RelatedNodeType)
{
case Microsoft.Samples.FeedSync.Constants.RELATED_TYPE_AGGREGATED:
{
m_RelatedNodeType = Microsoft.Samples.FeedSync.RelatedNode.RelatedNodeTypes.Aggregated;
break;
}
case Microsoft.Samples.FeedSync.Constants.RELATED_TYPE_COMPLETE:
{
m_RelatedNodeType = Microsoft.Samples.FeedSync.RelatedNode.RelatedNodeTypes.Complete;
break;
}
default:
{
throw new System.ArgumentException("Unknown related node type: " + RelatedNodeType);
}
}
m_Link = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.LINK_ATTRIBUTE);
if (i_RelatedNodeXmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.TITLE_ATTRIBUTE))
m_Title = i_RelatedNodeXmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.TITLE_ATTRIBUTE);
}
示例14: LoadXml
/// <summary>
/// Load state from an XML element
/// </summary>
/// <param name="xmlElement">XML element containing new state</param>
public void LoadXml(System.Xml.XmlElement xmlElement)
{
XmlNamespaceManager xmlNamespaceManager;
XmlNodeList xmlNodeList;
IEnumerator enumerator;
XmlElement iterationXmlElement;
HashDataInfo newHashDataInfo;
if (xmlElement == null)
{
throw new ArgumentNullException("xmlElement");
}
if (xmlElement.HasAttribute("Id"))
{
this.id = xmlElement.GetAttribute("Id");
}
else
{
this.id = "";
}
xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
xmlNamespaceManager.AddNamespace("xades", XadesSignedXml.XadesNamespaceUri);
this.hashDataInfoCollection.Clear();
xmlNodeList = xmlElement.SelectNodes("xades:HashDataInfo", xmlNamespaceManager);
enumerator = xmlNodeList.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
iterationXmlElement = enumerator.Current as XmlElement;
if (iterationXmlElement != null)
{
newHashDataInfo = new HashDataInfo();
newHashDataInfo.LoadXml(iterationXmlElement);
this.hashDataInfoCollection.Add(newHashDataInfo);
}
}
}
finally
{
IDisposable disposable = enumerator as IDisposable;
if (disposable != null)
{
disposable.Dispose();
}
}
xmlNodeList = xmlElement.SelectNodes("xades:EncapsulatedTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
this.xmlTimeStamp = null;
}
else
{
xmlNodeList = xmlElement.SelectNodes("xades:XMLTimeStamp", xmlNamespaceManager);
if (xmlNodeList.Count != 0)
{
this.xmlTimeStamp = new XMLTimeStamp();
this.xmlTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
this.encapsulatedTimeStamp = null;
}
else
{
throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp missing");
}
}
}
示例15: ParseMore
protected internal static void ParseMore(System.Xml.XmlElement groupElement, Group group, ParsingContext context)
{
group.ChildNamespace = context.Namespace;
if (groupElement.HasAttribute("id"))
group.Id = groupElement.GetAttribute("id");
group.TypeReference = GetTypeReference(groupElement);
ParseExternalAttributes(groupElement, group);
}