///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="coverlet"></param> /// <returns></returns> public void Merge(DCssPropertyCollection merged) { System.Diagnostics.Debug.Assert(merged != null); for (int index = 0, count = merged.m_propertyList.Count; index < count; ++index) { AddFirst(merged.m_propertyList[index]); } }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="input"></param> /// <returns></returns> public DCssPropertyCollection ResolvePropertyList(string input) { System.Diagnostics.Debug.Assert(input != null); DCssPropertyCollection result = new DCssPropertyCollection(); ResolvePropertyList(input, result); return(result); }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="coverlet"></param> /// <returns></returns> public void Merge(DCssPropertyCollection merged) { System.Diagnostics.Debug.Assert(merged != null); for(int index = 0, count = merged.m_propertyList.Count; index < count; ++index) AddFirst(merged.m_propertyList[index]); }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="input"></param> /// <returns></returns> public void ResolvePropertyList(string input, DCssPropertyCollection result) { System.Diagnostics.Debug.Assert(input != null); System.Diagnostics.Debug.Assert(result != null); PropertyListTokenType type = PropertyListTokenType.Name; int index = 0; string name = "", value = ""; while (index < input.Length) // PropertyList: S* declaration? [ ';' S* declaration? ]*; { // declaration: DELIM? property S* ':' S* value; int startIndex = 0; if (type == PropertyListTokenType.Name) { startIndex = input.IndexOfAny(":=".ToCharArray(), index); } else if (type == PropertyListTokenType.Value) { startIndex = input.IndexOf(';', index); } if (type == PropertyListTokenType.Name && startIndex != -1 && startIndex - index > 0 && (input[startIndex].Equals(':') || input[startIndex].Equals('='))) { name = input.Substring(index, startIndex - index); name = name.Trim(CHtmlUtil.WhiteSpaceCharsArray); if (name.Length > 0 && CHtmlUtil.ExistWhiteSpaceChar(name) == false) { type = PropertyListTokenType.Value; } } else if (type == PropertyListTokenType.Value && startIndex != -1 && startIndex - index > 0 && input[startIndex].Equals(';')) { value = input.Substring(index, startIndex - index); value = value.Trim(CHtmlUtil.WhiteSpaceCharsArray); if (value.Length > 0) { DCssProperty property = new DCssProperty(name, value); result.AddLast(property); } type = PropertyListTokenType.Name; } else if (type == PropertyListTokenType.Value && startIndex == -1) { value = input.Substring(index); value = value.Trim(CHtmlUtil.WhiteSpaceCharsArray); if (value.Length > 0) { DCssProperty property = new DCssProperty(name, value); result.AddLast(property); } type = PropertyListTokenType.Name; } else { type = PropertyListTokenType.Name; } if (startIndex == -1) { index = input.Length; } else { index = startIndex + 1; } } }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="input"></param> /// <returns></returns> public DCssPropertyCollection ResolvePropertyList(string input) { System.Diagnostics.Debug.Assert(input != null); DCssPropertyCollection result = new DCssPropertyCollection(); ResolvePropertyList(input, result); return result; }
///////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="input"></param> /// <returns></returns> public void ResolvePropertyList(string input, DCssPropertyCollection result) { System.Diagnostics.Debug.Assert(input != null); System.Diagnostics.Debug.Assert(result != null); PropertyListTokenType type = PropertyListTokenType.Name; int index = 0; string name = "", value = ""; while(index < input.Length) // PropertyList: S* declaration? [ ';' S* declaration? ]*; { // declaration: DELIM? property S* ':' S* value; int startIndex = 0; if(type == PropertyListTokenType.Name) startIndex = input.IndexOfAny(":=".ToCharArray(), index); else if(type == PropertyListTokenType.Value) startIndex = input.IndexOf(';', index); if(type == PropertyListTokenType.Name && startIndex != -1 && startIndex - index > 0 && (input[startIndex].Equals(':') || input[startIndex].Equals('='))) { name = input.Substring(index, startIndex - index); name = name.Trim(CHtmlUtil.WhiteSpaceCharsArray); if(name.Length > 0 && CHtmlUtil.ExistWhiteSpaceChar(name) == false) type = PropertyListTokenType.Value; } else if(type == PropertyListTokenType.Value && startIndex != -1 && startIndex - index > 0 && input[startIndex].Equals(';')) { value = input.Substring(index, startIndex - index); value = value.Trim(CHtmlUtil.WhiteSpaceCharsArray); if(value.Length > 0) { DCssProperty property = new DCssProperty(name, value); result.AddLast(property); } type = PropertyListTokenType.Name; } else if(type == PropertyListTokenType.Value && startIndex == -1) { value = input.Substring(index); value = value.Trim(CHtmlUtil.WhiteSpaceCharsArray); if(value.Length > 0) { DCssProperty property = new DCssProperty(name, value); result.AddLast(property); } type = PropertyListTokenType.Name; } else type = PropertyListTokenType.Name; if(startIndex == -1) index = input.Length; else index = startIndex + 1; } }