本文整理汇总了C#中ISymbol.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.Flatten方法的具体用法?C# ISymbol.Flatten怎么用?C# ISymbol.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISymbol
的用法示例。
在下文中一共展示了ISymbol.Flatten方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAllowedChildSymbol
public virtual void AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
bool changed = false;
foreach (ISymbol p in parent.Flatten().Where(p => !(p is GroupSymbol)))
changed |= AddAllowedChildSymbolToDictionaries(p, child, argumentIndex);
if (changed) {
ClearCaches();
OnChanged();
}
}
示例2: SetSubtreeCount
public virtual void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) {
var symbols = symbol.Flatten().Where(s => !(s is GroupSymbol));
if (symbols.Any(s => s.MinimumArity > minimumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
if (symbols.Any(s => s.MaximumArity < maximumSubtreeCount)) throw new ArgumentException("Invalid maximum subtree count " + maximumSubtreeCount + " for " + symbol);
foreach (ISymbol s in symbols)
SetSubTreeCountInDictionaries(s, minimumSubtreeCount, maximumSubtreeCount);
ClearCaches();
OnChanged();
}
示例3: RemoveSymbol
public virtual void RemoveSymbol(ISymbol symbol) {
foreach (var s in symbol.Flatten()) {
symbols.Remove(s.Name);
allowedChildSymbols.Remove(s.Name);
for (int i = 0; i < GetMaximumSubtreeCount(s); i++)
allowedChildSymbolsPerIndex.Remove(Tuple.Create(s.Name, i));
symbolSubtreeCount.Remove(s.Name);
foreach (var parent in Symbols) {
List<string> allowedChilds;
if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds))
allowedChilds.Remove(s.Name);
for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) {
if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds))
allowedChilds.Remove(s.Name);
}
}
suppressEvents = true;
foreach (var groupSymbol in Symbols.OfType<GroupSymbol>())
groupSymbol.SymbolsCollection.Remove(symbol);
suppressEvents = false;
}
ClearCaches();
}
示例4: AddSymbol
public virtual void AddSymbol(ISymbol symbol) {
if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined.");
foreach (var s in symbol.Flatten()) {
symbols.Add(s.Name, s);
int maxSubTreeCount = Math.Min(s.MinimumArity + 1, s.MaximumArity);
symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, maxSubTreeCount));
}
ClearCaches();
}
示例5: ChangeDuplicateSymbolNames
private void ChangeDuplicateSymbolNames(ISymbol symbol) {
foreach (var s in symbol.Flatten()) {
var originalSymbolName = s.Name;
int i = 1;
while (Content.ContainsSymbol(s)) {
s.Name = originalSymbolName + i;
i++;
}
}
}
示例6: UpdateGrammerConstraintsForClonedSymbol
private void UpdateGrammerConstraintsForClonedSymbol(ISymbol symbol, Cloner cloner) {
foreach (var s in symbol.Flatten().Where(x => !(x is GroupSymbol))) {
if (!cloner.ClonedObjectRegistered(s)) throw new InvalidOperationException();
var clone = cloner.Clone(s);
Content.SetSubtreeCount(clone, Content.GetMinimumSubtreeCount(s), Content.GetMaximumSubtreeCount(s));
foreach (var childSymbol in Content.GetAllowedChildSymbols(s)) {
var newChildSymbol = childSymbol;
if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol);
Content.AddAllowedChildSymbol(clone, newChildSymbol);
}
for (int i = 0; i < Content.GetMaximumSubtreeCount(s); i++) {
foreach (var childSymbol in Content.GetAllowedChildSymbols(s, i)) {
var newChildSymbol = childSymbol;
if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol);
Content.AddAllowedChildSymbol(clone, newChildSymbol, i);
}
}
}
}
示例7: DeregisterSymbolEvents
private void DeregisterSymbolEvents(ISymbol symbol) {
foreach (var s in symbol.Flatten()) {
s.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
s.NameChanged -= new EventHandler(Symbol_NameChanged);
var groupSymbol = s as GroupSymbol;
if (groupSymbol != null) DeregisterGroupSymbolEvents(groupSymbol);
else s.Changed -= new EventHandler(Symbol_Changed);
}
}