internal InvalidAttributeValueException(XmlNode n, AttributeRegex ar) : base(string.Format("The element at {0} has an invalid value for the attribute {1}, expected {2}", new string[] { Utility.FindXPath(n), ar.Name, ar.Reg.ToString() })) { }
/// <summary> /// Parses the attribute on the line /// </summary> /// <param name="line">The line to parse</param> /// <returns>The <see cref="AttributeDefinition"/> of the found attribute, or <c>null</c> if the line does not contain an attribute</returns> public AttributeDefinition ParseLine(string line) { if (line == null) { throw new ArgumentNullException("line"); } else if (line.Length < 5) { // 5 = [A()] return(null); } Match m = AttributeRegex.Match(line); if (!m.Success) { return(null); } AttributeDefinition ad = new AttributeDefinition(); if (SupportsNamespaces) { ad.NamespacePrefix = m.Groups["nsPrefix"].Value; if (ad.NamespacePrefix != null) { ad.NamespacePrefix = ad.NamespacePrefix.Replace(NamespaceSeparatorToken, ".").TrimEnd('.'); } } ad.Name = m.Groups["attribute"].Value; foreach (Capture c in m.Groups["arg"].Captures) { ad.Arguments.Add(c.Value); } foreach (Capture c in m.Groups["name"].Captures) { ad.NamedArguments.Add(new NamedAttributeArgument(c.Value)); } CaptureCollection values = m.Groups["value"].Captures; for (int i = 0; i < values.Count; i++) { ad.NamedArguments[i].Value = values[i].Value; } ad.Comment = m.Groups["comment"].Value; return(ad); }
public static void ExtractEditedClasses() { Directory.CreateDirectory("../../../Structures/Savegame/Generated/Edited"); foreach (var file in Directory.GetFiles("../../../Structures/Savegame/Generated/Content").ToArray()) { var text = File.ReadAllText(file); var countAttributes = AttributeRegex.Matches(text).Count; var countObjects = ObjectRegex.Matches(text).Count; var countLists = ListObjectRegex.Matches(text).Count; if (countAttributes != countObjects + countLists) { var newFilename = "../../../Structures/Savegame/Generated/Edited/" + Path.GetFileName(file); File.Move(file, newFilename); } } }
protected override void AddAttribute(Type attributeType) { AttrMap[attributeType] = new AttributeRegex(attributeType, ConstructNameRegex(attributeType), RegexOptions.None); }
protected override void AddAttribute(Type attributeType) { AttrMap[attributeType] = new AttributeRegex(attributeType, ConstructRegex(attributeType), RegexOptions.IgnoreCase); }