Example #1
0
        }//end InitializeVariables()

        //
        //
        //
        // ****         Create Copy()               ****
        //
        public static Market CreateCopy(Market instrToCopy)
        {
            Market newInstr = Market.Create(instrToCopy.Name);

            instrToCopy.CopyTo(newInstr);
            return(newInstr);
        }//CreateCopy().
Example #2
0
        //
        //
        #endregion//Constructors


        #region no Properties
        // *****************************************************************
        // ****                     Properties                          ****
        // *****************************************************************
        //
        //
        #endregion//Properties


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        // ****                 CopyTo()                    ****
        //
        /// <summary>
        /// After the book hub obtains the write lock for the next writable book,
        /// it can copy this book to that one.
        /// Note: In practice, it doesn't need to get a read lock on this book, if
        /// its the only thread that can get a write lock.
        /// Called by the BookHub only.
        /// </summary>
        /// <param name="aWriteLockedBook">A book already locked for writing</param>
        public virtual void CopyTo(Book aWriteLockedBook)
        {
            foreach (int id in this.Instruments.Keys)
            {
                Market myContract = this.Instruments[id];     // my instrument
                Market aContract;                             // instrument in book to copy over.
                if (!aWriteLockedBook.Instruments.TryGetValue(id, out aContract))
                {
                    aContract = Market.CreateCopy(myContract);
                    aWriteLockedBook.Instruments.Add(id, aContract);
                }
                else
                {
                    myContract.CopyTo(aContract);
                }
            }
        }//end CopyTo().