/// <summary> /// Creates a new RdlCommandGroup from the specified tagString. /// </summary> /// <param name="tagString">The string containing multiple commands that will become part of the new collection.</param> /// <returns>A new RdlCommandGroup instance containing the parsed commands.</returns> public static RdlCommandGroup FromString(string tagString) { RdlCommandGroup col = new RdlCommandGroup(); using (RdlTagReader reader = new RdlTagReader(tagString)) { RdlTag tag = null; while ((tag = reader.ReadTag()) != null) { if (tag.TagName.Equals(RdlTagName.CMD.ToString())) { col.Add((RdlCommand)tag); } else if (tag.TagName.Equals(RdlTagName.AUTH.ToString())) { col.AuthKey = (tag as RdlAuthKey).Key; col.AuthKeyType = (tag as RdlAuthKey).TypeName; } else { col.Tags.Add(tag); } } } return(col); }
public TagKey(RdlTag tag) { if (tag.TagName == RdlTagName.OBJ.ToString()) { if (tag.TypeName == RdlObjectTypeName.ACTOR.ToString()) { RdlObject obj = tag as RdlObject; this.Key = String.Concat(tag.TagName, tag.TypeName, obj.ID); } else if (tag.TypeName == RdlObjectTypeName.PROP.ToString()) { RdlProperty prop = tag as RdlProperty; this.Key = String.Concat(tag.TagName, tag.TypeName, prop.ID, prop.Name); } else { this.Key = tag.ToString(); } } else { this.Key = tag.ToString(); } }
/// <summary> /// Reads the next RdlTag and advances the reader. /// </summary> /// <returns>An RdlTag instance.</returns> public RdlTag ReadTag() { try { RdlTag tag = null; if (!String.IsNullOrEmpty(_s) && _pos < _length) { string tagName = null; string typeName = null; int quoteCount = 0; int argIndex = 0; object value = null; bool parsingTagName = false; bool parsingTypeName = false; bool parsingString = false; // Indicates a string value is being parsed, ignore special chars. // Start at the current position and find starting tag char. // {OBJ|PROP|5|2|"Json Value"|""{Name:"Test",Value:"Equals"}""} do { // If the start character is found and not parsing a string value then // start the tag. if (_s[_pos] == RdlTag.TagStartChar && quoteCount == 0 && !parsingString) { // Being parsing the tag name. parsingTagName = true; continue; } // If a quote character is found then a string is being parsed until the quote count is down to 0. if (_s[_pos] == _quote) { // When the first quote is found start parsing the string until an even number of quotes exist // and a separator or end char is found. if (quoteCount == 0) { parsingString = true; quoteCount++; continue; } else { quoteCount++; if ((quoteCount % 2) == 0) { // Even number of quotes, check the next char to see if it is a separator or end char. if ((_pos + 1) < _length) { if (_s[_pos + 1] == RdlTag.TagSeparatorChar || _s[_pos + 1] == RdlTag.TagEndChar) { parsingString = false; quoteCount = 0; continue; } } } } } if ((_pos + 1) == _length) { parsingString = false; } if ((_s[_pos] == RdlTag.TagSeparatorChar || (_s[_pos] == RdlTag.TagEndChar)) && !parsingString) { if (parsingTagName) { parsingTagName = false; parsingTypeName = true; } else if (parsingTypeName) { parsingTypeName = false; // Create the RdlTag instance. tag = RdlTagConverter.CreateTag(tagName, typeName); } else { // Value can be added to tag. if (tag != null) { if (argIndex < tag.Args.Count) { tag.Args[argIndex] = this.FormatValue(value); } else { tag.Args.Insert(argIndex, this.FormatValue(value)); } value = null; argIndex++; } } // If the end character is found the exit the loop. if (_s[_pos] == RdlTag.TagEndChar) { // Advance the position. _pos++; break; } continue; } // If made it to here then check to see if a value is being parsed. if (parsingTagName) { tagName = String.Concat(tagName, _s[_pos]); } else if (parsingTypeName) { typeName = String.Concat(typeName, _s[_pos]); } else { if (value == null) { value = _s[_pos]; } else { value = String.Concat(value, _s[_pos]); } } } while (_pos++ < _length); } return(tag); } catch (Exception ex) { throw (ex); } }