Ejemplo n.º 1
0
        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);
            //}
        }
Ejemplo n.º 2
0
        public RelationBase()
        {
            this.id = RelationBase.GenerateId();
#if WITH_CHILDREN
            this.nChildren = new List <InnerRelation>();
            this.aChildren = new List <InnerRelation>();
#endif
        }
Ejemplo n.º 3
0
 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;
     }
 }
Ejemplo n.º 4
0
        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
        }
Ejemplo n.º 5
0
        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
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        public TInnerRelation Create(RelationBase nParent, RelationBase aParent)
        {
            bool isNew;

            return(this.Create(nParent, aParent, out isNew));
        }