本文整理匯總了C#中System.Xml.XPath.XPathNavigator.GetAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# XPathNavigator.GetAttribute方法的具體用法?C# XPathNavigator.GetAttribute怎麽用?C# XPathNavigator.GetAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.GetAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Parse
public static ChannelLink Parse(XPathNavigator navigator)
{
ChannelLink result = null;
Guid channelId = Guid.Empty;
string id = navigator.GetAttribute("id", String.Empty);
if (!String.IsNullOrEmpty(id))
{
channelId = new Guid(id);
}
int mpChannelId = -1;
string mpId = navigator.GetAttribute("mpId", String.Empty);
if (!String.IsNullOrEmpty(id))
{
mpChannelId = Int32.Parse(mpId);
}
if (channelId != Guid.Empty
&& mpChannelId >= 0)
{
string channelName = navigator.GetAttribute("name", String.Empty);
ChannelType channelType;
string type = navigator.GetAttribute("type", String.Empty);
if (String.IsNullOrEmpty(type))
{
channelType = ChannelType.Television;
}
else
{
channelType = (ChannelType)Enum.Parse(typeof(ChannelType), type);
}
string mpChannelName = navigator.GetAttribute("mpName", String.Empty);
result = new ChannelLink(channelType, channelId, channelName, mpChannelId, mpChannelName);
}
return result;
}
示例2: ToPowerInfo
public PowerLocalInfo ToPowerInfo(XPathNavigator powerElement)
{
var name = powerElement.GetAttribute("Name", "");
var powerId = powerElement.GetAttribute("Id", "");
var math = _character.SelectNodes(string.Format("calculations/power[@name='{0}']", name)).Item(0).Value;
return new PowerLocalInfo(name, powerId, math);
}
示例3: LoadFromXPathNavigator
public static MaterialDefinition LoadFromXPathNavigator(XPathNavigator navigator)
{
if (navigator == null)
{
return null;
}
MaterialDefinition materialDefinition = new MaterialDefinition();
//name
materialDefinition.Name = navigator.GetAttribute("Name", string.Empty);
materialDefinition.NameHash = Cryptography.JenkinsOneAtATime(materialDefinition.Name);
//type
materialDefinition.Type = navigator.GetAttribute("Type", string.Empty);
materialDefinition.TypeHash = Cryptography.JenkinsOneAtATime(materialDefinition.Type);
//draw styles
XPathNodeIterator entries = navigator.Select("./Array[@Name='DrawStyles']/Object[@Class='DrawStyle']");
while (entries.MoveNext())
{
DrawStyle drawStyle = DrawStyle.LoadFromXPathNavigator(entries.Current);
if (drawStyle != null)
{
materialDefinition.DrawStyles.Add(drawStyle);
}
}
return materialDefinition;
}
示例4: TagOptions
//=====================================================================
/// <summary>
/// Constructor
/// </summary>
/// <param name="tag">The tag node</param>
public TagOptions(XPathNavigator tag)
{
startTag = tag.GetAttribute("startTag", String.Empty);
endTag = tag.GetAttribute("endTag", String.Empty);
tagAttributes = tag.GetAttribute("attributes", String.Empty);
matchRules = tag.Select("Match");
endTags = new Stack<string>();
}
示例5: GetArgsFormating
static Func<IEnumerable<Argument>, string> GetArgsFormating(XPathNavigator argsNode)
{
string accumulator = argsNode.GetAttribute("accumulator", string.Empty);
string start = argsNode.GetAttribute("start", string.Empty);
string end = argsNode.GetAttribute("end", string.Empty);
string general = argsNode.GetAttribute("general", string.Empty);
return GetArgsFormating(accumulator, start, end, general);
}
示例6: ESentTargetDictionary
//=====================================================================
/// <summary>
/// Constructor
/// </summary>
/// <param name="component">The build component that owns the dictionary. This is useful for logging
/// messages during initialization.</param>
/// <param name="configuration">The target dictionary configuration</param>
/// <returns>A target dictionary instance that uses a simple in-memory
/// <see cref="Dictionary{TKey, TValue}"/> instance to store the targets.</returns>
public ESentTargetDictionary(BuildComponentCore component, XPathNavigator configuration) :
base(component, configuration)
{
bool noReload = false;
int localCacheSize;
string cachePath = configuration.GetAttribute("cachePath", String.Empty);
if(String.IsNullOrWhiteSpace(cachePath))
throw new ArgumentException("The cachePath attribute must contain a value", "configuration");
string cacheSize = configuration.GetAttribute("localCacheSize", String.Empty);
if(String.IsNullOrWhiteSpace(cacheSize) || !Int32.TryParse(cacheSize, out localCacheSize))
localCacheSize = 1000;
// This is a slightly modified version of Managed ESENT that provides the option to serialize
// reference types. In this case, we don't care about potential issues of persisted copies not
// matching the original if modified as they are never updated once written to the cache. We can
// also turn off column compression for a slight performance increase since it doesn't benefit the
// binary data that is serialized.
PersistentDictionaryFile.AllowReferenceTypeSerialization = true;
index = new PersistentDictionary<string, Target>(cachePath, false)
{ LocalCacheSize = localCacheSize };
string noReloadValue = configuration.GetAttribute("noReload", String.Empty);
// If noReload is true, skip reloading the dictionary if it contains any data. This is used on
// project targets to prevent reloading the data in the reference build if already loaded by the
// conceptual build.
if(!String.IsNullOrWhiteSpace(noReloadValue) && Boolean.TryParse(noReloadValue, out noReload) &&
noReload && index.Count != 0)
return;
// Loading new targets can take a while so issue a diagnostic message as an alert
int filesToLoad = 0;
foreach(string file in Directory.EnumerateFiles(this.DirectoryPath, this.FilePattern, this.Recurse ?
SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
if((this.NamespaceFileFilter.Count == 0 || this.NamespaceFileFilter.Contains(
Path.GetFileName(file))) && !this.ContainsKey("N:" + Path.GetFileNameWithoutExtension(file)))
filesToLoad++;
// The time estimate is a ballpark figure and depends on the system
if(filesToLoad != 0)
{
component.WriteMessage(MessageLevel.Diagnostic, "{0} file(s) need to be added to the ESENT " +
"reflection target cache database. Indexing them will take about {1:N0} minute(s), " +
"please be patient. Cache location: {2}", filesToLoad, Math.Ceiling(filesToLoad * 10 / 60.0),
cachePath);
// Limit the degree of parallelism or it overwhelms the ESENT version store
this.LoadTargetDictionary(3);
}
}
示例7: SettingsMapping
public SettingsMapping (XPathNavigator nav)
{
_sectionTypeName = nav.GetAttribute ("sectionType", String.Empty);
_mapperTypeName = nav.GetAttribute ("mapperType", String.Empty);
EnumConverter cvt = new EnumConverter (typeof (SettingsMappingPlatform));
_platform = (SettingsMappingPlatform) cvt.ConvertFromInvariantString (nav.GetAttribute ("platform", String.Empty));
LoadContents (nav);
}
示例8: ReadXml
public void ReadXml(XPathNavigator node, XmlResolver resolver) {
if (node.NodeType == XPathNodeType.Element) {
if (node.MoveToFirstAttribute()) {
do {
switch (node.LocalName) {
case "media-type":
this.MediaType = node.Value;
break;
case "boundary":
this.Boundary = node.Value;
break;
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToChild(XPathNodeType.Element)) {
XPathHttpMultipartItem currentItem = null;
do {
if (node.NamespaceURI == XPathHttpClient.Namespace) {
switch (node.LocalName) {
case "header":
if (currentItem == null)
currentItem = new XPathHttpMultipartItem();
currentItem.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
break;
case "body":
if (currentItem == null)
currentItem = new XPathHttpMultipartItem();
currentItem.Body = new XPathHttpBody();
currentItem.Body.ReadXml(node, resolver);
this.Items.Add(currentItem);
currentItem = null;
break;
}
}
} while (node.MoveToNext(XPathNodeType.Element));
node.MoveToParent();
}
}
}
示例9: View
public View(XPathNavigator view, XPathNavigator mainView, IXmlNamespaceResolver resolver)
{
this._id = view.GetAttribute("id", String.Empty);
this._type = view.GetAttribute("type", String.Empty);
if (this._id == mainView.GetAttribute("virtualViewId", String.Empty))
view = mainView;
this._label = view.GetAttribute("label", String.Empty);
this._headerText = ((string)(view.Evaluate("string(c:headerText)", resolver)));
_group = view.GetAttribute("group", String.Empty);
_showInSelector = !((view.GetAttribute("showInSelector", String.Empty) == "false"));
}
示例10: HxfGeneratorComponent
public HxfGeneratorComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {
// get configuration data
inputValue = configuration.GetAttribute("input", String.Empty);
if (!String.IsNullOrEmpty(inputValue)) inputValue = Environment.ExpandEnvironmentVariables(inputValue);
outputValue = configuration.GetAttribute("output", String.Empty);
if (!String.IsNullOrEmpty(outputValue)) outputValue = Environment.ExpandEnvironmentVariables(outputValue);
// subscribe to component events
assembler.ComponentEvent += new EventHandler(FileCreatedHandler);
}
示例11: GetPageInfoFromNavigator
private static PageInfo GetPageInfoFromNavigator(XPathNavigator matchingPageNode)
{
// Create the PageInfo from the element navigator.
var pageInfo = new PageInfo {
Id = int.Parse(matchingPageNode.GetAttribute("id", string.Empty)),
Slug = matchingPageNode.GetAttribute("slug", string.Empty),
Title = matchingPageNode.GetAttribute("title", string.Empty),
Content = HttpUtility.HtmlDecode(matchingPageNode.Value)
};
return pageInfo;
}
示例12: ActionGroup
public ActionGroup(XPathNavigator actionGroup, IXmlNamespaceResolver resolver)
: this()
{
this._scope = actionGroup.GetAttribute("scope", String.Empty);
this._headerText = actionGroup.GetAttribute("headerText", String.Empty);
this._id = actionGroup.GetAttribute("id", String.Empty);
_flat = (actionGroup.GetAttribute("flat", String.Empty) == "true");
XPathNodeIterator actionIterator = actionGroup.Select("c:action", resolver);
while (actionIterator.MoveNext())
if (Controller.UserIsInRole(actionIterator.Current.GetAttribute("roles", String.Empty)))
this.Actions.Add(new Action(actionIterator.Current, resolver));
}
示例13: ProjectFile
/// <summary>
/// Initializes a new instance of the <see cref="ProjectFile"/> class.
/// </summary>
/// <param name="nodeFromProject">The x path navigator.</param>
public ProjectFile(XPathNavigator nodeFromProject)
{
if (nodeFromProject == null)
{
throw new ArgumentNullException("nodeFromProject", @"Cannot create project file as the XML passed was null.");
}
_relativePath = nodeFromProject.GetAttribute(@"RelPath", string.Empty);
string buildAction = nodeFromProject.GetAttribute(@"BuildAction", string.Empty);
_buildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction);
}
示例14: Initialize
//=====================================================================
/// <inheritdoc />
public override void Initialize(XPathNavigator configuration)
{
inputFile = configuration.GetAttribute("input", String.Empty);
if(!String.IsNullOrEmpty(inputFile))
inputFile = Environment.ExpandEnvironmentVariables(inputFile);
outputFilename = configuration.GetAttribute("output", String.Empty);
if(!String.IsNullOrEmpty(outputFilename))
outputFilename = Environment.ExpandEnvironmentVariables(outputFilename);
// Subscribe to component events
base.BuildAssembler.ComponentEvent += FileCreatedHandler;
}
示例15: GetBrowser
private static Browser GetBrowser(XPathNavigator objNav)
{
Browser objBrowser = new Browser();
objBrowser.Contains = objNav.GetAttribute("contains", "");
objBrowser.Name = objNav.GetAttribute("nm", "");
string strMinVersion = objNav.GetAttribute("minversion", "");
//If Not String.IsNullOrEmpty(strMinVersion) Then '.NET 2.0 specific
// HACK : Modified to not error if object is null.
//if (strMinVersion.Length > 0)
if (!String.IsNullOrEmpty(strMinVersion))
{
objBrowser.MinVersion = double.Parse(strMinVersion);
}
return objBrowser;
}