本文整理匯總了C#中System.Xml.XmlNode.NodeGet方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlNode.NodeGet方法的具體用法?C# XmlNode.NodeGet怎麽用?C# XmlNode.NodeGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.NodeGet方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoadXML
override protected void LoadXML(XmlNode cXmlNode)
{
if (null == cXmlNode || _bInitialized)
return;
_sRestartFile = cXmlNode.AttributeValueGet("restart", false);
XmlNode[] aNodeChilds = cXmlNode.NodesGet("process", false);
if (null != aNodeChilds)
{
List<Process> aProcesses = new List<Process>();
for (int nIndx = 0; aNodeChilds.Length > nIndx; nIndx++)
{
aProcesses.Add(new Process()
{
sName = aNodeChilds[nIndx].AttributeValueGet("name"),
sOwner = aNodeChilds[nIndx].AttributeValueGet("owner"),
sArguments = aNodeChilds[nIndx].AttributeValueGet("arguments", false)
});
}
_aProcesses = aProcesses.ToArray();
}
XmlNode cXNBlender = cXmlNode.NodeGet("blender", false);
if (null != cXNBlender)
{
_cBlender = new Blender() { sPath = cXNBlender.AttributeValueGet("path"), sTasks = cXNBlender.AttributeValueGet("tasks"), nQueue = (cXNBlender.AttributeValueGet("queue", false) ?? "1").ToByte() };
if (!System.IO.File.Exists(_cBlender.sPath) || !System.IO.Directory.Exists(_cBlender.sTasks))
throw new Exception("cannot find blender executable or tasks folder[" + _cBlender.sPath +"][" + _cBlender.sTasks + "]");
}
}
示例2: Parse
static public Text Parse(XmlNode cXmlNode)
{
Text cRetVal = new Text();
XmlNode cNodeFont = cXmlNode.NodeGet("font");
cRetVal.cFont = new System.Drawing.Font(cNodeFont.AttributeValueGet("name"), cNodeFont.AttributeGet<int>("size"), cNodeFont.AttributeGet<System.Drawing.FontStyle>("style"));
cRetVal.nTopOffset = cNodeFont.AttributeGet<short>("offset", false);
if (cRetVal.nTopOffset == short.MaxValue)
cRetVal.nTopOffset = 0;
cXmlNode = cNodeFont.NodeGet("color");
cRetVal.stColor = System.Drawing.Color.FromArgb(cXmlNode.AttributeGet<byte>("alpha"), cXmlNode.AttributeGet<byte>("red"), cXmlNode.AttributeGet<byte>("green"), cXmlNode.AttributeGet<byte>("blue"));
if (null != (cXmlNode = cNodeFont.NodeGet("border", false)))
{
cRetVal.nBorderWidth = cXmlNode.AttributeValueGet("width").ToFloat();
cXmlNode = cXmlNode.NodeGet("color");
cRetVal.stColorBorder = System.Drawing.Color.FromArgb(cXmlNode.AttributeGet<byte>("alpha"), cXmlNode.AttributeGet<byte>("red"), cXmlNode.AttributeGet<byte>("green"), cXmlNode.AttributeGet<byte>("blue"));
}
return cRetVal;
}
示例3: LoadXML
override protected void LoadXML(XmlNode cXmlNode)
{
if (null == cXmlNode || _bInitialized)
return;
XmlNode cNodeChild = cXmlNode.NodeGet("database", false);
if(null == cNodeChild)
cNodeChild = cXmlNode.NodeGet("common/database", false);
if (null == cNodeChild)
return;
if (null != cNodeChild.Attributes["server"])
{
_cDBCredentials = new DB.Credentials();
_cDBCredentials.sServer = cNodeChild.AttributeValueGet("server");
_cDBCredentials.nPort = cNodeChild.AttributeGet<int>("port");
_cDBCredentials.sDatabase = cNodeChild.AttributeValueGet("name");
_cDBCredentials.sUser = cNodeChild.AttributeValueGet("user");
_cDBCredentials.sPassword = cNodeChild.AttributeValueGet("password");
_cDBCredentials.nTimeout = cNodeChild.AttributeGet<int>("timeout");
}
if (null != cNodeChild.Attributes["bytea"])
_eByteaOutput = cNodeChild.AttributeGet<ByteaOutput>("bytea");
}
示例4: LoadXML
override public void LoadXML(XmlNode cXmlNode)
{
if (null == cXmlNode)
return;
base.LoadXML(cXmlNode);
if((sFile = cXmlNode.AttributeValueGet("file", false)).IsNullOrEmpty())
throw new Exception("указано некорректное значение атрибута file плагина [TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
if((sClass = cXmlNode.AttributeValueGet("class", false)).IsNullOrEmpty())
throw new Exception("указано некорректное значение атрибута class плагина [TPL:" + cXmlNode.BaseURI + "]"); //TODO LANG
if (null != (cXmlNode = cXmlNode.NodeGet("data", false)))
sData = cXmlNode.OuterXml;
}
示例5: LoadXML
override protected void LoadXML(XmlNode cXmlNode)
{
if (null == cXmlNode)
return;
try
{
_eLevel = cXmlNode.AttributeGet<Level>("level");
}
catch
{
_eLevel = Level.notice;
}
XmlNode cXmlNodeChild = cXmlNode.NodeGet("file", false);
if (null != cXmlNodeChild)
{
_cFile = new File();
_cFile.sPath = cXmlNodeChild.AttributeValueGet("path", false);
if (null != _cFile.sPath && !SIO.Path.IsPathRooted(_cFile.sPath))
_cFile.sPath = SIO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _cFile.sPath);
_cFile.sFilename = cXmlNodeChild.AttributeValueGet("name", false);
_cFile.bDate = cXmlNodeChild.AttributeGet<bool>("date", false);
_cFile.bPID = cXmlNodeChild.AttributeGet<bool>("pid", false);
}
cXmlNodeChild = cXmlNode.NodeGet("mail", false);
_ahMailTargets = null;
List<Regex> aExcludes = new List<Regex>();
if (null != cXmlNodeChild)
{
if (null == (_sMailSubjectPrefix = cXmlNodeChild.AttributeValueGet("subject", false)))
throw new Exception("не указан префикс темы сообщения электронной почты [" + cXmlNodeChild.Name + "][subject]"); //TODO LANG
_sMailSubjectPrefix = "[" + _sMailSubjectPrefix + "]";
if (null == (_sMailSource = cXmlNodeChild.AttributeValueGet("source", false)))
throw new Exception("не указан адрес отправителя сообщения электронной почты [" + cXmlNodeChild.Name + "][source]"); //TODO LANG
if (null == (_sMailServer = cXmlNodeChild.AttributeValueGet("server", false)))
throw new Exception("не указан сервер электронной почты [" + cXmlNodeChild.Name + "][server]"); //TODO LANG
if (null == (_sMailPassword = cXmlNodeChild.AttributeValueGet("password", false)))
throw new Exception("не указан пароль сервера электронной почты [" + cXmlNodeChild.Name + "][password]"); //TODO LANG
XmlNode[] aXmlNodes = cXmlNodeChild.NodesGet("targets/target", false);
if (null == aXmlNodes)
throw new Exception("не указаны адресаты электронной почты [" + cXmlNodeChild.Name + "][targets]"); //TODO LANG
_ahMailTargets = new Dictionary<Level, string>();
Level eLevel;
foreach (XmlNode cNode in aXmlNodes)
{
if (null != cNode.Attributes["level"])
{
try
{
eLevel = cNode.AttributeGet<Level>("level");
}
catch
{
throw new Exception("указан некорректный уровень для списка адресатов [" + cNode.Name + "]"); //TODO LANG
}
if (_ahMailTargets.ContainsKey(eLevel))
throw new Exception("указано несколько списков адресатов [" + eLevel + "][" + cNode.Name + "]"); //TODO LANG
_ahMailTargets.Add(eLevel, cNode.InnerText);
}
}
if (null != (aXmlNodes = cXmlNodeChild.NodesGet("excludes/pattern", false)))
{
foreach (XmlNode cNode in aXmlNodes)
{
if (!cNode.InnerXml.IsNullOrEmpty())
aExcludes.Add(new Regex(cNode.InnerXml, RegexOptions.IgnoreCase | RegexOptions.Singleline));
}
}
}
_aExcludes = aExcludes.ToArray();
}
示例6: Yandex
static public Data Yandex(XmlNode cXmlNode)
{
Data cRetVal = null;
if (null != cXmlNode)
{
cRetVal = new Data();
string sCode = cXmlNode.NodeGet("weather_condition").AttributeValueGet("code").ToLower();
#region condition
switch (sCode)
{
case "cloudy-thunderstorms-with-wet-snow":
cRetVal.eType = Type.Clouds | Type.RainHeavy; //weather_icn_bkn_+ra_d_pal_c
break;
case "cloudy":
case "thin-high-clouds":
cRetVal.eType = Type.Clouds; //weather_icn_bkn_d_pal_c
break;
case "cloudy-and-showers":
case "cloudy-and-wet-snow-showers":
case "cloudy-and-rain":
case "cloudy-thunderstorms-with-rain":
case "cloudy-and-light-rain":
case "cloudy-and-light-wet-snow":
case "cloudy-thunderstorms-with-snow":
cRetVal.eType = Type.Clouds | Type.Rain; //weather_icn_bkn_-ra_d_pal_c
break;
case "cloudy-and-snow":
cRetVal.eType = Type.Clouds | Type.SnowMore; //weather_icn_bkn_sn_d_pal_c
break;
case "cloudy-and-snow-showers":
case "cloudy-and-wet-snow":
case "cloudy-and-light-snow":
cRetVal.eType = Type.Clouds | Type.Snow; //weather_icn_bkn_-sn_d_pal_c
break;
case "intermittent-heavy-drizzle":
case "intermittent-heavy-rain":
case "rain-showers":
case "violent-rain-showers":
case "continuous-heavy-rain":
case "moderate-to-heavy-rain-showers":
case "light-rain-showers":
case "funnel-clouds-within-sight":
case "squalls-within-sight-but-no-precipitation-falling-at-station":
cRetVal.eType = Type.CloudsHeavy | Type.RainHeavy; //weather_icn_ovc_+ra_pal_c
break;
case "heavy-drifting-snow-above-eye-level":
cRetVal.eType = Type.CloudsHeavy | Type.SnowHeavy; //weather_icn_ovc_+sn_pal_c
break;
case "freezing-rain":
case "hail-showers":
case "heavy-thunderstorm-with-hail":
case "moderate-to-heavy-freezing-drizzle":
case "moderate-to-heavy-hail-showers":
case "moderate-to-heavy-freezing-rain":
case "light-snow-ice-pellet-showers":
case "light-hail-showers":
case "light-freezing-rain":
case "light-snow-showers":
case "snow-grains":
cRetVal.eType = Type.CloudsHeavy | Type.Hail; //weather_icn_ovc_gr_pal_c
break;
case "visibility-reduced-by-smoke":
case "mist":
case "clouds-dissolving":
case "mostly-clear":
case "state-of-sky-unchanged":
case "mostly-clear-slight-possibility-of-rain":
case "mostly-clear-slight-possibility-of-snow":
case "mostly-clear-slight-possibility-of-wet-snow":
case "overcast":
case "clouds-developing":
case "partly-cloudy":
case "widespread-dust-in-suspension-not-raised-by-wind":
case "dust-or-sand-raised-by-wind":
case "dust-or-sand-storm-within-sight-but-not-at-station":
case "slight-to-moderate-duststorm-decreasing-in-intensity":
case "slight-to-moderate-duststorm-increasing-in-intensity":
case "slight-to-moderate-duststorm-no-change":
case "well-developed-dust-or-sand-whirls":
case "severe-duststorm-decreasing-in-intensity":
case "severe-duststorm-increasing-in-intensity":
case "severe-duststorm-no-change":
cRetVal.eType = Type.CloudsHeavy; //weather_icn_ovc_pal_c
break;
case "patches-of-fog":
case "continuous-shallow-fog":
case "fog":
case "fog-at-a-distance":
case "fog-sky-visible-becoming-thicker":
case "fog-sky-visible-no-change":
case "fog-sky-visible-thinning":
case "patches-of-shallow-fog":
case "fog-depositing-rime-sky-visible":
cRetVal.eType = Type.Fog; //weather_icn_ovc_fg_pal_c
break;
case "fog-sky-not-visible-becoming-thicker":
case "fog-sky-not-visible-no-change":
case "fog-sky-not-visible-thinning":
case "fog-depositing-rime-sky-not-visible":
cRetVal.eType = Type.FogMore; //weather_icn_ovc_+fg_pal_c
//.........這裏部分代碼省略.........
示例7: LoadXML
override protected void LoadXML(XmlNode cXmlNode)
{
if (null == cXmlNode || _bInitialized)
return;
_nCUDAVersion = cXmlNode.NodeGet("cuda").AttributeGet<byte>("version");
}
示例8: LoadXML
override protected void LoadXML(XmlNode cXmlNode)
{
(new Logger()).WriteWarning("________________load XML begin");
if (null == cXmlNode)
return;
XmlNode cXmlNodeChild;
XmlNode[] aXmlNodeChilds;
XmlNode cXmlNodeClient = cXmlNode.NodeGet("clients/scr", false);
if (null != cXmlNodeClient)
{
#region presets
aXmlNodeChilds = cXmlNodeClient.NodesGet("presets/preset");
_cClientSCR = new Clients.SCR();
List<Clients.SCR.Preset> aPresets = new List<Clients.SCR.Preset>();
Clients.SCR.Preset cPreset;
foreach (XmlNode cXmlNodePreset in aXmlNodeChilds)
{
cPreset = new Clients.SCR.Preset();
cPreset.sName = cXmlNodePreset.AttributeValueGet("name");
cPreset.nID = cXmlNodePreset.AttributeIDGet("id");
cPreset.sFolder = cXmlNodePreset.AttributeValueGet("folder");
cPreset.sChannel = cXmlNodePreset.AttributeValueGet("channel");
cPreset.sCaption = cXmlNodePreset.AttributeValueGet("caption");
if (0 < aPresets.Count(o => (cPreset.nID == o.nID || cPreset.sName == o.sName) && cPreset.sChannel == o.sChannel))
throw new Exception("пресет указан повторно [channel:" + cPreset.sChannel + "][id:" + cPreset.nID + "][name:" + cPreset.sName + "][" + cXmlNodePreset.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG
aPresets.Add(cPreset);
}
_cClientSCR.aPresets = aPresets.ToArray();
#endregion
#region plaques
aXmlNodeChilds = cXmlNodeClient.NodesGet("plaques/plaque");
List<Clients.SCR.Plaque> aPlaques = new List<Clients.SCR.Plaque>();
Clients.SCR.Plaque cPlaque;
foreach (XmlNode cXmlNodePreset in aXmlNodeChilds)
{
cPlaque = new Clients.SCR.Plaque();
cPlaque.nPresetID = cXmlNodePreset.AttributeGet<int>("id_preset", false);
cPlaque.bOpened = cXmlNodePreset.AttributeGet<bool>("opened", false);
cPlaque.nHeight = cXmlNodePreset.AttributeGet<ushort>("height", false);
aPlaques.Add(cPlaque);
}
_cClientSCR.aPlaques = aPlaques.ToArray();
#endregion
#region templates
XmlNode cXmlNodeTemplates = cXmlNodeClient.NodeGet("templates");
if (null != (cXmlNodeChild = cXmlNodeTemplates.NodeGet("masks", false)))
{
_cClientSCR.sTemplateChannelMask = cXmlNodeChild.AttributeValueGet("channel", false) ?? "";
_cClientSCR.sTemplatePresetMask = cXmlNodeChild.AttributeValueGet("preset", false) ?? "";
}
aXmlNodeChilds = cXmlNodeTemplates.NodesGet("template");
List<Clients.SCR.Template> aTemplates = new List<Clients.SCR.Template>();
Clients.SCR.Template cTemplate = null;
foreach (XmlNode cXmlNodeTemplate in aXmlNodeChilds)
{
cTemplate = new Clients.SCR.Template();
cTemplate.eBind = cXmlNodeTemplate.AttributeGet<Clients.SCR.Template.Bind>("bind");
if (0 < aTemplates.Count(o => o.eBind == cTemplate.eBind))
throw new Exception("шаблон с указанной привязкой уже был добавлен [" + cTemplate.eBind + "][" + cXmlNodeTemplate.Name + "][" + cXmlNodeClient.Name + "]"); //TODO LANG
cTemplate.sFile = cXmlNodeTemplate.AttributeValueGet("file");
if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("scale_video", false)))
{
short x, y;
ushort w, h;
string sAspect;
x = cXmlNodeChild.AttributeGet<short>("x", false);
y = cXmlNodeChild.AttributeGet<short>("y", false);
w = cXmlNodeChild.AttributeGet<ushort>("width", false);
h = cXmlNodeChild.AttributeGet<ushort>("height", false);
sAspect = cXmlNodeChild.AttributeValueGet("pixel_aspect_ratio", false);
if (0 == w || 0 == h)
cTemplate.stScaleVideo = Area.stEmpty;
else
cTemplate.stScaleVideo = new Area(x, y, w, h);
if (null != sAspect)
cTemplate.nPixelAspectRatio = float.Parse(sAspect.Replace('.', ','));
}
if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("offsets", false)))
cTemplate.aOffsets = GetOffsets(cXmlNodeChild.NodesGet("offset"));
if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("conflicts", false)))
cTemplate.aConflicts = GetConflicts(cXmlNodeChild.NodesGet("conflict"));
if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("preset_parameters", false)))
cTemplate.aParameters = GetParameters(cXmlNodeChild.NodesGet("parameters"));
if (null != (cXmlNodeChild = cXmlNodeTemplate.NodeGet("player_parameters", false)))
cTemplate.aParameters = GetPlayerParameters(cXmlNodeChild.NodesGet("parameters"));
aTemplates.Add(cTemplate);
}
_cClientSCR.aTemplates = aTemplates.ToArray();
#endregion
XmlNode cXmlNodeAutomation = cXmlNodeClient.NodeGet("automation", false);
sClipStartStopAutomationFile = cXmlNodeAutomation.AttributeValueGet("file", false);
nFrameDuration_ms = cXmlNodeAutomation.AttributeGet<int>("frame_ms", false);
nStopOffset = cXmlNodeAutomation.AttributeGet<int>("stop_offset", false);
XmlNode cXmlNodeOthers = cXmlNodeClient.NodeGet("others", false);
nQueuesCompensation = cXmlNodeOthers.AttributeGet<int>("queues_compensation", false);
sPlayerLogFolder = cXmlNodeOthers.AttributeValueGet("player_log", false);
}
}