示例#1
0
 internal SyncAnswerCollection(AnswerCollection list)
     : base(Tag.Default)
 {
     rwLock = new System.Threading.ReaderWriterLock();
     collection = list;
 }
示例#2
0
            public override int AddRange(AnswerCollection x)
            {
                int result = 0;
                rwLock.AcquireWriterLock(timeout);

                try {
                    result = collection.AddRange(x);
                }
                finally {
                    rwLock.ReleaseWriterLock();
                }

                return result;
            }
示例#3
0
 internal ReadOnlyAnswerCollection(AnswerCollection list)
     : base(Tag.Default)
 {
     m_collection = list;
 }
示例#4
0
 public override int AddRange(AnswerCollection x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
示例#5
0
 /// <summary>
 ///		Initializes a new instance of the <c>AnswerCollection</c> class
 ///		that contains elements copied from the specified <c>AnswerCollection</c>.
 /// </summary>
 /// <param name="c">The <c>AnswerCollection</c> whose elements are copied to the new collection.</param>
 public AnswerCollection(AnswerCollection c)
 {
     m_array = new Answer[c.Count];
     AddRange(c);
 }
示例#6
0
 /// <summary>
 ///		Initializes a new instance of the <c>Enumerator</c> class.
 /// </summary>
 /// <param name="tc"></param>
 internal Enumerator(AnswerCollection tc)
 {
     m_collection = tc;
     m_index = -1;
     m_version = tc.m_version;
 }
示例#7
0
        /// <summary>
        ///		Creates a shallow copy of the <see cref="AnswerCollection"/>.
        /// </summary>
        public virtual object Clone()
        {
            AnswerCollection newColl = new AnswerCollection(m_count);
            Array.Copy(m_array, 0, newColl.m_array, 0, m_count);
            newColl.m_count = m_count;
            newColl.m_version = m_version;

            return newColl;
        }
示例#8
0
        /// <summary>
        ///		Adds the elements of another <c>AnswerCollection</c> to the current <c>AnswerCollection</c>.
        /// </summary>
        /// <param name="x">The <c>AnswerCollection</c> whose elements should be added to the end of the current <c>AnswerCollection</c>.</param>
        /// <returns>The new <see cref="AnswerCollection.Count"/> of the <c>AnswerCollection</c>.</returns>
        public virtual int AddRange(AnswerCollection x)
        {
            if (m_count + x.Count >= m_array.Length)
                EnsureCapacity(m_count + x.Count);

            Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
            m_count += x.Count;
            m_version++;

            return m_count;
        }
示例#9
0
 /// <summary>
 ///		Creates a synchronized (thread-safe) wrapper for a 
 ///     <c>AnswerCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>AnswerCollection</c> wrapper that is synchronized (thread-safe).
 /// </returns>
 public static AnswerCollection Synchronized(AnswerCollection list)
 {
     if(list==null)
         throw new ArgumentNullException("list");
     return new SyncAnswerCollection(list);
 }
示例#10
0
 /// <summary>
 ///		Creates a read-only wrapper for a 
 ///     <c>AnswerCollection</c> instance.
 /// </summary>
 /// <returns>
 ///     An <c>AnswerCollection</c> wrapper that is read-only.
 /// </returns>
 public static AnswerCollection ReadOnly(AnswerCollection list)
 {
     if(list==null)
         throw new ArgumentNullException("list");
     return new ReadOnlyAnswerCollection(list);
 }
示例#11
0
 public Question()
 {
     this.text = "";
     this.responses = 0;
     this.answers = new AnswerCollection();
 }