internal SemanticKeyElement(string semanticKey) { _semanticKey = semanticKey; RuleElement ruleElement = new RuleElement(semanticKey); _ruleRef = new RuleRefElement(ruleElement, _semanticKey); base.Items.Add(ruleElement); base.Items.Add(_ruleRef); }
protected void Optimize(Collection <RuleElement> newRules) { SortedDictionary <int, Collection <BuilderElements> > sortedDictionary = new SortedDictionary <int, Collection <BuilderElements> >(); GetDictionaryElements(sortedDictionary); int[] array = new int[sortedDictionary.Keys.Count]; int num = array.Length - 1; foreach (int key in sortedDictionary.Keys) { array[num--] = key; } for (int i = 0; i < array.Length && array[i] >= 3; i++) { Collection <BuilderElements> collection = sortedDictionary[array[i]]; for (int j = 0; j < collection.Count; j++) { RuleElement ruleElement = null; RuleRefElement ruleRefElement = null; for (int k = j + 1; k < collection.Count; k++) { if (collection[j] == null || !collection[j].Equals(collection[k])) { continue; } BuilderElements builderElements = collection[k]; BuilderElements parent = builderElements.Parent; if (builderElements is SemanticKeyElement) { parent.Items[parent.Items.IndexOf(builderElements)] = collection[j]; } else { if (ruleElement == null) { ruleElement = new RuleElement(builderElements, "_"); newRules.Add(ruleElement); } if (ruleRefElement == null) { ruleRefElement = new RuleRefElement(ruleElement); collection[j].Parent.Items[collection[j].Parent.Items.IndexOf(collection[j])] = ruleRefElement; } parent.Items[builderElements.Parent.Items.IndexOf(builderElements)] = ruleRefElement; } builderElements.RemoveDictionaryElements(sortedDictionary); collection[k] = null; } } } }
public override bool Equals(object obj) { RuleRefElement ruleRefElement = obj as RuleRefElement; if (ruleRefElement == null) { return(false); } if (_semanticKey == ruleRefElement._semanticKey) { return(_rule.Equals(ruleRefElement._rule)); } return(false); }
internal void CloneItems(RuleRefElement builders) { _rule.CloneItems(builders._rule); }