/// <summary> /// convert json to lq element /// </summary> /// <param name="element"></param> static void ReFormatLqElement(LiquidElement element) { LiquidAttribute childNodeAttr = null; LiquidAttribute nodeNameAttr = null; if (!element.HasOwnerDocument) { return; } LiquidDoc ownerdoc = element.OwnerDocument; int found_N = element.OwnerDocument.GetStringIndex("!n"); int found_C = element.OwnerDocument.GetStringIndex("!c"); foreach (LiquidAttribute att in element.GetAttributeIterForward()) { if (found_N != 0 && att.AttributeLocalNameIndex == found_N) //!n { element.Name = att.Value.ToString(); nodeNameAttr = att; } else if (found_C != 0 && att.AttributeLocalNameIndex == found_C) { childNodeAttr = att; } } //-------------------------------------- if (nodeNameAttr != null) { element.RemoveAttribute(nodeNameAttr); } //-------------------------------------- if (childNodeAttr != null) { if (childNodeAttr.Value is LiquidArray) { LiquidArray children = (LiquidArray)childNodeAttr.Value; foreach (object child in children.GetIterForward()) { if (child is LiquidElement) { ReFormatLqElement((LiquidElement)child); element.AppendChild((LiquidElement)child); } else { throw new NotSupportedException(); } } children.Clear(); element.RemoveAttribute(childNodeAttr); } } }
public object GetAttributeValue(string key) { LiquidAttribute found = GetAttributeElement(key); if (found != null) { return(found.Value); } else { return(null); } }
public void AppendAttribute(LiquidAttribute attr) { _attributeDic01.Add(attr.Name, attr); }
public void RemoveAttribute(LiquidAttribute attr) { _attributeDic01.Remove(attr.Name); }