コード例 #1
0
        /// <summary>
        /// Makes a shallow copy of the current YariMediaTypeCollection.
        /// as the parent object.
        /// </summary>
        /// <returns>YariMediaTypeCollection</returns>
        public YariMediaTypeCollection Clone()
        {
            YariMediaTypeCollection clonedYariMediaType = new YariMediaTypeCollection(count);

            lock (this)
            {
                foreach (YariMediaType item in this)
                {
                    clonedYariMediaType.Add(item);
                }
            }
            return(clonedYariMediaType);
        }
コード例 #2
0
        /// <summary>
        /// Makes a deep copy of the current YariMediaType.
        /// </summary>
        /// <param name="isolation">Placeholders are used to isolate the
        /// items in the YariMediaTypeCollection from their children.</param>
        public YariMediaTypeCollection Copy(bool isolated)
        {
            YariMediaTypeCollection isolatedCollection = new YariMediaTypeCollection(count);

            lock (this)
            {
                if (isolated)
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(YariMediaTypeArray[i].NewPlaceHolder());
                    }
                }
                else
                {
                    for (int i = 0; i < count; i++)
                    {
                        isolatedCollection.Add(YariMediaTypeArray[i].Copy());
                    }
                }
            }
            return(isolatedCollection);
        }
コード例 #3
0
ファイル: YariMediaTypeManager.cs プロジェクト: rahodges/Amns
        public YariMediaTypeCollection GetCollection(int topCount, string whereClause, string sortClause)
        {
            StringBuilder           query;
            Database                database;
            DbCommand               dbCommand;
            IDataReader             r;
            YariMediaTypeCollection yariMediaTypeCollection;


            query = new StringBuilder("SELECT ");

            if (topCount > 0)
            {
                query.Append("TOP ");
                query.Append(topCount);
                query.Append(" ");
            }

            foreach (string columnName in InnerJoinFields)
            {
                query.Append("kitYari_MediaTypes.");
                query.Append(columnName);
                query.Append(",");
            }

            //
            // Remove trailing comma
            //
            query.Length--;
            query.Append(" FROM kitYari_MediaTypes ");
            //
            // Render where clause
            //
            if (whereClause != string.Empty)
            {
                query.Append(" WHERE ");
                query.Append(whereClause);
            }

            //
            // Render sort clause
            //
            if (sortClause != string.Empty)
            {
                query.Append(" ORDER BY ");
                query.Append(sortClause);
            }

            //
            // Render final semicolon
            //
            query.Append(";");
            database  = DatabaseFactory.CreateDatabase();
            dbCommand = database.GetSqlStringCommand(query.ToString());
                        #if DEBUG
            try
            {
                r = database.ExecuteReader(dbCommand);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                throw(new Exception(msg + " --- Query: " + query.ToString()));
            }
                        #else
            r = database.ExecuteReader(dbCommand);
                        #endif

            yariMediaTypeCollection = new YariMediaTypeCollection();

            while (r.Read())
            {
                YariMediaType yariMediaType = ParseFromReader(r, 0, 1);

                yariMediaTypeCollection.Add(yariMediaType);
            }

            return(yariMediaTypeCollection);
        }