本文整理汇总了C#中System.Xml.XmlNode.TryCheckValue方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.TryCheckValue方法的具体用法?C# XmlNode.TryCheckValue怎么用?C# XmlNode.TryCheckValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.TryCheckValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessBonus
//.........这里部分代码省略.........
types =
KnowledgeSkill.KnowledgeTypes.Where(x => bonusNode.SelectNodes($"notgroup[. = '{x.Value}']").Count == 0).ToList();
}
else
{
types = KnowledgeSkill.KnowledgeTypes;
}
frmSelectItem select = new frmSelectItem();
select.DropdownItems = KnowledgeSkill.KnowledgeSkillsWithCategory(types.Select(x => x.Value).ToArray());
select.ShowDialog();
if (select.DialogResult == DialogResult.Cancel)
{
return false;
}
name = select.SelectedItem;
}
else if (bonusNode["name"] != null)
{
name = bonusNode["name"].InnerText;
}
else
{
//TODO some kind of error handling
Log.Error(new[] {bonusNode.OuterXml, "Missing pick or name"});
return false;
}
_strSelectedValue = name;
KnowledgeSkill skill = new KnowledgeSkill(_objCharacter, name);
bool knowsoft = bonusNode.TryCheckValue("require", "skilljack");
if (knowsoft)
{
_objCharacter.SkillsSection.KnowsoftSkills.Add(skill);
if (_objCharacter.SkillsoftAccess)
{
_objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
}
}
else
{
_objCharacter.SkillsSection.KnowledgeSkills.Add(skill);
}
CreateImprovement(name, objImprovementSource, strSourceName, Improvement.ImprovementType.SkillBase, strUnique, val);
CreateImprovement(skill.Id.ToString(), objImprovementSource, strSourceName,
Improvement.ImprovementType.SkillKnowledgeForced, strUnique);
}
if (bonusNode.LocalName == "knowledgeskilllevel")
{
//Theoretically life modules, right now we just give out free points and let people sort it out themselves.
//Going to be fun to do the real way, from a computer science perspective, but i don't feel like using 2 weeks on that now
int val = bonusNode["val"] != null ? ValueToInt(bonusNode["val"].InnerText, intRating) : 1;
CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", val);
}
if (bonusNode.LocalName == "knowledgeskillpoints")
{
CreateImprovement("", objImprovementSource, strSourceName, Improvement.ImprovementType.FreeKnowledgeSkills, "", ValueToInt(bonusNode.InnerText,Convert.ToInt32(bonusNode.Value)));
示例2: IsValid
/// <summary>
/// Retuns weither a quality is valid on said Character
/// THIS IS A WIP AND ONLY CHECKS QUALITIES. REQUIRED POWERS, METATYPES AND OTHERS WON'T BE CHECKED
/// ConflictingQualities will only contain existing Qualities and won't contain required but missing Qualities
/// </summary>
/// <param name="objCharacter">The Character</param>
/// <param name="objXmlQuality">The XmlNode describing the quality</param>
/// <param name="reason">The reason the quality is not valid</param>
/// <param name="conflictingQualities">List of Qualities that conflicts with this Quality</param>
/// <returns>Is the Quality valid on said Character</returns>
public static bool IsValid(Character objCharacter, XmlNode objXmlQuality, out QualityFailureReason reason, out List<Quality> conflictingQualities)
{
conflictingQualities = new List<Quality>();
reason = QualityFailureReason.Allowed;
//If limit are not present or no, check if same quality exists
if (!objXmlQuality.TryCheckValue("limit", "no"))
{
foreach (Quality objQuality in objCharacter.Qualities)
{
if (objQuality.QualityId == objXmlQuality["id"].InnerText)
{
reason |= QualityFailureReason.LimitExceeded; //QualityFailureReason is a flag enum, meaning each bit represents a different thing
//So instead of changing it, |= adds rhs to list of reasons on lhs, if it is not present
conflictingQualities.Add(objQuality);
}
}
}
if (objXmlQuality["required"] != null)
{
if (objXmlQuality["required"]["oneof"] != null)
{
if (objXmlQuality["required"]["oneof"]["quality"] != null)
{
XmlNodeList objXmlRequiredList = objXmlQuality.SelectNodes("required/oneof/quality");
//Add to set for O(N log M) runtime instead of O(N * M)
//like it matters...
HashSet<String> qualityRequired = new HashSet<String>();
foreach (XmlNode node in objXmlRequiredList)
{
qualityRequired.Add(node.InnerText);
}
bool blnFound = false;
foreach (Quality quality in objCharacter.Qualities)
{
if (qualityRequired.Contains(quality.Name))
{
blnFound = true;
break;
}
}
if (!blnFound)
{
reason |= QualityFailureReason.RequiredSingle;
}
}
if (objXmlQuality["required"]["oneof"]["metatype"] != null)
{
XmlNodeList objXmlRequiredList = objXmlQuality.SelectNodes("required/oneof/metatype");
bool blnFound = false;
foreach (XmlNode node in objXmlRequiredList)
{
if (node.InnerText == objCharacter.Metatype)
{
blnFound = true;
break;
}
}
if (!blnFound)
{
reason |= QualityFailureReason.MetatypeRequired;
}
}
}
if (objXmlQuality["required"]["allof"] != null)
{
XmlNodeList objXmlRequiredList = objXmlQuality.SelectNodes("required/allof/quality");
//Add to set for O(N log M) runtime instead of O(N * M)
HashSet<String> qualityRequired = new HashSet<String>();
foreach (XmlNode node in objXmlRequiredList)
{
qualityRequired.Add(node.InnerText);
}
foreach (Quality quality in objCharacter.Qualities)
{
if (qualityRequired.Contains(quality.Name))
{
qualityRequired.Remove(quality.Name);
}
}
//.........这里部分代码省略.........