コード例 #1
0
        public CdmObjectBase(CdmCorpusContext ctx)
        {
            if (ctx?.Corpus != null)
            {
                // when loading imports asynchronously, multiple objects may be created at the same time so multiple objects
                // can inadvertently get the same ID. Adding a lock here ensures that the global id variable is incremented
                // and then that value is set to the object ID before that same process can happen for another object
                bool lockTaken = false;
                try
                {
                    // acquire spinlock
                    ctx.Corpus.spinLock.Enter(ref lockTaken);
                    this.Id = CdmCorpusDefinition.NextId();
                }
                finally
                {
                    // release spinlock
                    if (lockTaken)
                    {
                        ctx.Corpus.spinLock.Exit();
                    }
                }
            }

            this.Ctx = ctx;
        }
コード例 #2
0
ファイル: CdmObjectBase.cs プロジェクト: ppothnis/CDM-1
 public CdmObjectBase(CdmCorpusContext ctx)
 {
     this.Id  = CdmCorpusDefinition.NextId();
     this.Ctx = ctx;
     if (ctx != null)
     {
         this.DocCreatedIn = (ctx as ResolveContext).CurrentDoc;
     }
 }
コード例 #3
0
 public CdmObjectBase(CdmCorpusContext ctx)
 {
     this.Id  = CdmCorpusDefinition.NextId();
     this.Ctx = ctx;
 }