public RdpPattern MakeChoice (RdpPattern p1, RdpPattern p2) { if (p1.PatternType == RelaxngPatternType.NotAllowed) return p2; if (p2.PatternType == RelaxngPatternType.NotAllowed) return p1; if (p1 == p2) return p1; // choice-leaves support if (p1.PatternType == RelaxngPatternType.Empty) return MakeChoiceLeaf (p2); if (p2.PatternType == RelaxngPatternType.Empty) return MakeChoiceLeaf (p1); if (p1.GetHashCode () > p2.GetHashCode ()) { RdpPattern tmp = p1; p1 = p2; p2 = tmp; } Hashtable p1Table = setupTable (typeof (RdpChoice), p1); if (p1Table [p2] == null) { RdpChoice c = new RdpChoice (p1, p2); c.setInternTable (this.patternPool); p1Table [p2] = c; } return (RdpChoice) p1Table [p2]; }
public RdpChoice MakeChoiceLeaf (RdpPattern p) { if (patternPool == null) // could be null for RdpElement etc. patternPool = new Hashtable (); Hashtable leaves = (Hashtable) patternPool [typeof (RdpEmpty)]; if (leaves == null) { leaves = new Hashtable (); patternPool [typeof (RdpEmpty)] = leaves; } RdpChoice leaf = leaves [p] as RdpChoice; if (leaf == null) { leaf = new RdpChoice (RdpEmpty.Instance, p); leaf.setInternTable (patternPool); leaves [p] = leaf; } return leaf; }