/// <summary> /// Gets all descendant items with the specified name. /// </summary> /// <returns>All descendant items with the specified name.</returns> public IEnumerable <StageItem> Descendants(string name) { StageItem current = this; StageContainer curElement = this; while (true) { if (curElement == null || curElement._tailChild == null) { while (current != this && current == current.parent._tailChild) { current = current.parent; } if (current == this) { break; } current = current.next; } else { current = curElement._tailChild.next; } if (current.name == name) { yield return(current); } curElement = current as StageContainer; } }
public IEnumerable <StageItem> Descendants() { StageContainer stageContainer = null; StageItem stageItem = stageContainer; StageContainer stageContainer1 = stageContainer; while (true) { if (stageContainer1 != null) { if (stageContainer1._tailChild == null) { goto Label2; } stageItem = stageContainer1._tailChild.next; goto Label0; } Label2: while (stageItem != stageContainer && stageItem == stageItem.parent._tailChild) { stageItem = stageItem.parent; } if (stageItem == stageContainer) { break; } stageItem = stageItem.next; Label0: yield return(stageItem); stageContainer1 = stageItem as StageContainer; } yield break; goto Label2; }
/// <summary> /// Gets all descendants of a particular type. /// </summary> /// <typeparam name="T">The type of descendant.</typeparam> /// <returns>All descendants of the specified type.</returns> public IEnumerable <T> Descendants <T>() where T : StageItem { StageItem current = this; StageContainer curElement = this; while (true) { if (curElement == null || curElement._tailChild == null) { while (current != this && current == current.parent._tailChild) { current = current.parent; } if (current == this) { break; } current = current.next; } else { current = curElement._tailChild.next; } var el = current as T; if (el != null) { yield return(el); } curElement = current as StageContainer; } }
public static void AddValue(this StageContainer parent, string name, object value, bool onlyIfNotNull = true) { if (onlyIfNotNull && value == null) { return; } parent.Add(SerializationMaster.Stage(name, value)); }
public static void AddTextValue(this StageContainer parent, string name, string value, bool onlyIfNotNullOrEmpty = true) { if (onlyIfNotNullOrEmpty && string.IsNullOrEmpty(value)) { return; } parent.Add(SerializationMaster.ToStageValue(name, value)); }
public IEnumerable <StageItem> Items() { StageContainer stageContainer = null; if (stageContainer._tailChild == null) { yield break; } StageItem stageItem = stageContainer._tailChild; do { stageItem = stageItem.next; yield return(stageItem); }while (stageItem != stageContainer._tailChild); }
public IEnumerable <StageElement> Elements() { StageContainer stageContainer = null; if (stageContainer._tailChild == null) { yield break; } StageItem stageItem = stageContainer._tailChild; do { stageItem = stageItem.next; StageElement stageElement = stageItem as StageElement; if (stageElement == null) { continue; } yield return(stageElement); }while (stageItem != stageContainer._tailChild); }
public IEnumerable <T> Descendants <T>() where T : StageItem { StageContainer stageContainer = null; StageItem stageItem = stageContainer; StageContainer stageContainer1 = stageContainer; while (true) { if (stageContainer1 != null) { if (stageContainer1._tailChild == null) { goto Label2; } stageItem = stageContainer1._tailChild.next; goto Label0; } Label2: while (stageItem != stageContainer && stageItem == stageItem.parent._tailChild) { stageItem = stageItem.parent; } if (stageItem == stageContainer) { break; } stageItem = stageItem.next; Label0: T t = (T)(stageItem as T); if (t != null) { yield return(t); } stageContainer1 = stageItem as StageContainer; } yield break; goto Label2; }
public IEnumerable <StageItem> Descendants(string name) { StageElement stageElement = null; StageItem stageItem = stageElement; StageContainer stageContainer = stageElement; while (true) { if (stageContainer != null) { if (stageContainer._tailChild == null) { goto Label2; } stageItem = stageContainer._tailChild.next; goto Label0; } Label2: while (stageItem != stageElement && stageItem == stageItem.parent._tailChild) { stageItem = stageItem.parent; } if (stageItem == stageElement) { break; } stageItem = stageItem.next; Label0: if (stageItem.name == name) { yield return(stageItem); } stageContainer = stageItem as StageContainer; } yield break; goto Label2; }