Esempio n. 1
0
        /// <summary>
        /// Creates a copy of the current CdmCollection.
        /// </summary>
        public CdmCollection <T> Copy(ResolveOptions resOpt, CdmObject host = null)
        {
            var copy = new CdmCollection <T>(this.Ctx, this.Owner, this.DefaultType);

            foreach (var element in this.AllItems)
            {
                copy.Add((T)element.Copy(resOpt));
            }
            return(copy);
        }
        internal static CdmCollection <T> ListCopy <T>(ResolveOptions resOpt, CdmObject owner, CdmCollection <T> source) where T : CdmObject
        {
            if (source == null)
            {
                return(null);
            }
            CdmCollection <T> casted = new CdmCollection <T>(source.Ctx, owner, source.DefaultType);

            foreach (CdmObject element in source)
            {
                casted.Add(element != null ? (dynamic)element.Copy(resOpt) : null);
            }
            return(casted);
        }
Esempio n. 3
0
        internal void SetParent(ResolveOptions resOpt, CdmAttributeContext parent)
        {
            // will need a working reference to this as the parent
            CdmObjectReferenceBase parentRef = this.Ctx.Corpus.MakeObject <CdmObjectReferenceBase>(CdmObjectType.AttributeContextRef, parent.AtCorpusPath, true);

            if (this.Name != null)
            {
                this.AtCorpusPath = parent.AtCorpusPath + "/" + this.Name;
            }
            parentRef.ExplicitReference = parent;
            // setting this will let the 'localize references' code trace from any document back to where the parent is defined
            parentRef.DocCreatedIn = parent.DocCreatedIn;
            CdmCollection <CdmObject> parentContents = parent.Contents;

            parentContents.Add(this);
            this.Parent = parentRef;
        }