public TInnerRelation Create(RelationBase nParent, RelationBase aParent, out bool isNew) { //lock (this.innerRelations) //{ TInnerRelation child = this.Get(nParent, aParent); isNew = child == null; if (isNew) { child = new TInnerRelation(); child.Initialize(nParent, aParent); Hashtable assocRelations; if (this.innerRelations.ContainsKey(nParent.Id)) { assocRelations = (Hashtable)this.innerRelations[nParent.Id]; } else { assocRelations = new Hashtable(); this.innerRelations.Add(nParent.Id, assocRelations); } assocRelations.Add(aParent.Id, child); } return(child); //} }
public RelationBase() { this.id = RelationBase.GenerateId(); #if WITH_CHILDREN this.nChildren = new List <InnerRelation>(); this.aChildren = new List <InnerRelation>(); #endif }
public string GenerateWithRecursion(RelationBase top) { if (top is RootRelation) return (top as RootRelation).Key; else { InnerRelation iRel = top as InnerRelation; return GenerateWithRecursion(iRel.NormParent) + ((RootRelation)iRel.AssocParent).Key; } }
internal void Initialize(RelationBase nParent, RelationBase aParent) { this.nParent = nParent; this.aParent = aParent; #if WITH_CHILDREN this.nParent.AddChild(this, true); this.aParent.AddChild(this, false); #endif }
public TInnerRelation Get(RelationBase nParent, RelationBase aParent) { TInnerRelation child = null; Hashtable assocRelations; if (this.innerRelations.ContainsKey(nParent.Id)) { assocRelations = (Hashtable)this.innerRelations[nParent.Id]; if (assocRelations.ContainsKey(aParent.Id)) { child = (TInnerRelation)assocRelations[aParent.Id]; } } return(child); }
public string Generate(RelationBase top) { StringBuilder text = new StringBuilder(); do { if (top is RootRelation) text.Insert(0, (top as RootRelation).Key); else { InnerRelation inner = top as InnerRelation; text.Insert(0, ((RootRelation)inner.AssocParent).Key); top = inner.NormParent; } } while (top is InnerRelation); text.Insert(0, ((RootRelation)top).Key); return text.ToString(); }
public TInnerRelation Create(RelationBase nParent, RelationBase aParent) { bool isNew; return(this.Create(nParent, aParent, out isNew)); }