private static IEnumerable <SelectionEnum> getSelectionModes(IRhsEntity entity) { if (entity.IsSymbol()) { yield return(SelectionEnum.All); } else if (entity.IsGroup()) { RhsGroup group = entity.AsGroup(); if (group.Mode != RhsGroup.ModeEnum.Set) { yield return(SelectionEnum.All); } if (group.Mode.In(RhsGroup.ModeEnum.Altogether, RhsGroup.ModeEnum.Set)) { yield return(SelectionEnum.Individuals); } if (group.Repetition == RepetitionEnum.Option) { yield return(SelectionEnum.Skip); } } else { throw new NotImplementedException(); } }
internal RhsEntitySelector(IRhsEntity entity) { this.entity = entity; this.modeCounter = CycleCollection.Create(getSelectionModes(entity)); initIndexCounter(); // funny thing, index counter depends on mode counter // but sub-selectors just depends on elements, not on mode or index (of this/parent selector) subSelectors = entity.Elements.Select(it => new RhsEntitySelector(it)).ToArray(); }
internal RhsSymbol AsSingleSymbol() { IRhsEntity elem = elements.Single(); if (elem.IsSymbol()) { return(elem.AsSymbol()); } else { return(elem.AsGroup().Elements.Single().AsSymbol()); } }
public static RhsSymbol AsSymbol(this IRhsEntity __this__) { return((RhsSymbol)__this__); }
public static bool IsSymbol(this IRhsEntity __this__) { return(__this__ is RhsSymbol); }
public static bool IsGroup(this IRhsEntity __this__) { return(__this__ is RhsGroup); }
public static RhsGroup AsGroup(this IRhsEntity __this__) { return((RhsGroup)__this__); }