Exemplo n.º 1
0
            int IComparer.Compare(Object x, Object y)
            {
                MetaDictionaryItem itemX = x as MetaDictionaryItem;
                MetaDictionaryItem itemY = y as MetaDictionaryItem;

                return(string.Compare(itemY.Value, itemX.Value, true));
            }
Exemplo n.º 2
0
        public void Move(int oldIndex, int newIndex)
        {
            if (oldIndex < 0 && oldIndex >= this.Count)
            {
                throw new ArgumentOutOfRangeException("oldIndex");
            }
            if (newIndex < 0 && newIndex >= this.Count)
            {
                throw new ArgumentOutOfRangeException("newIndex");
            }

            MetaDictionaryItem item = this[oldIndex];

            this.InnerList.RemoveAt(oldIndex);

            if (newIndex == this.Count)
            {
                this.InnerList.Add(item);
            }
            else
            {
                this.InnerList.Insert(newIndex, item);
            }

            ReindexItems();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the specified default value.
        /// </summary>
        /// <param name="DefaultValue">The default value.</param>
        /// <param name="Value">The value.</param>
        /// <param name="DefaultTag">The default tag.</param>
        /// <param name="Tag">The tag.</param>
        /// <returns></returns>
        internal int Add(string defaultValue, string value, object defaultTag, object tag)
        {
            SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image);

            spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag);

            SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image);

            spTag.Value = SqlHelper.Null2DBNull(tag);

            SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4);

            Retval.Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"),
                                      new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId),
                                      //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)),
                                      //new SqlParameter("@DefaultValue", value),
                                      //spDefaultTag,
                                      new SqlParameter("@Value", value),
                                      spTag,
                                      new SqlParameter("@Index", this.Count),
                                      Retval
                                      );

            MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, this.Count);

            return(this.InnerList.Add(retVal));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public void Insert(int index, MetaDictionaryItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            this.Insert(index, item.DefaultValue, item.Value, item.DefaultTag, item.Tag);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public int Add(MetaDictionaryItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            return(this.Add(item.DefaultValue, item.Value, item.DefaultTag, item.Tag));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Deletes the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        public void Delete(MetaDictionaryItem item)
        {
            if (this.InnerList.Contains(item))
            {
                this.DeleteAt(this.InnerList.IndexOf(item));
                return;
            }

            throw new ArgumentException("Could noy find MetaDictionaryItem.", "item");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Deletes at.
        /// </summary>
        /// <param name="Index">The index.</param>
        public void DeleteAt(int index)
        {
            MetaDictionaryItem item = this[index];

            SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_DeleteMetaDictionary"),
                                      new SqlParameter("@MetaDictionaryId", item.Id)
                                      );

            this.InnerList.RemoveAt(index);

            // Decrease Index
            ReindexItems();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Reloads the meta dictionary.
        /// </summary>
        void ReloadMetaDictionary()
        {
            using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaDictionary"),
                                                                  new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId)))
            {
                while (reader.Read())
                {
                    MetaDictionaryItem newItem = new MetaDictionaryItem(reader);
                    this.InnerList.Add(newItem);
                }
                reader.Close();
            }

            // ReIndex
            ReindexItems();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Adds the specified default value.
        /// </summary>
        /// <param name="DefaultValue">The default value.</param>
        /// <param name="Value">The value.</param>
        /// <param name="DefaultTag">The default tag.</param>
        /// <param name="Tag">The tag.</param>
        /// <returns></returns>
        internal void Insert(int index, string defaultValue, string value, object defaultTag, object tag)
        {
            if (index < 0 && index >= this.Count)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image);

            spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag);

            SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image);

            spTag.Value = SqlHelper.Null2DBNull(tag);

            SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4);

            Retval.Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"),
                                      new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId),
                                      //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)),
                                      //new SqlParameter("@DefaultValue", value),
                                      //spDefaultTag,
                                      new SqlParameter("@Value", value),
                                      spTag,
                                      new SqlParameter("@Index", index),
                                      Retval
                                      );

            MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, index);

            this.InnerList.Insert(index, retVal);

            ReindexItems();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Reloads the meta dictionary.
        /// </summary>
        void ReloadMetaDictionary()
        {
            using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaDictionary"),
                      new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId)))
            {
                while (reader.Read())
                {
                    MetaDictionaryItem newItem = new MetaDictionaryItem(reader);
                    this.InnerList.Add(newItem);
                }
                reader.Close();
            }

            // ReIndex
            ReindexItems();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds the specified default value.
        /// </summary>
        /// <param name="DefaultValue">The default value.</param>
        /// <param name="Value">The value.</param>
        /// <param name="DefaultTag">The default tag.</param>
        /// <param name="Tag">The tag.</param>
        /// <returns></returns>
        internal void Insert(int index, string defaultValue, string value, object defaultTag, object tag)
        {
            if (index < 0 && index >= this.Count)
                throw new ArgumentOutOfRangeException("index");

            SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image);
            spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag);

            SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image);
            spTag.Value = SqlHelper.Null2DBNull(tag);

            SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4);
            Retval.Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"),
                new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId),
                //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)),
                //new SqlParameter("@DefaultValue", value),
                //spDefaultTag,
                new SqlParameter("@Value", value),
                spTag,
                new SqlParameter("@Index", index),
                Retval
                );

            MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, index);

            this.InnerList.Insert(index, retVal);

            ReindexItems();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds the specified default value.
        /// </summary>
        /// <param name="DefaultValue">The default value.</param>
        /// <param name="Value">The value.</param>
        /// <param name="DefaultTag">The default tag.</param>
        /// <param name="Tag">The tag.</param>
        /// <returns></returns>
        internal int Add(string defaultValue, string value, object defaultTag, object tag)
        {
            SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image);
            spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag);

            SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image);
            spTag.Value = SqlHelper.Null2DBNull(tag);

            SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4);
            Retval.Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"),
                new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId),
                //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)),
                //new SqlParameter("@DefaultValue", value),
                //spDefaultTag,
                new SqlParameter("@Value", value),
                spTag,
                new SqlParameter("@Index", this.Count),
                Retval
                );

            MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, this.Count);

            return this.InnerList.Add(retVal);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public void Insert(int index, MetaDictionaryItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            this.Insert(index, item.DefaultValue, item.Value, item.DefaultTag, item.Tag);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Deletes the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        public void Delete(MetaDictionaryItem item)
        {
            if (this.InnerList.Contains(item))
            {
                this.DeleteAt(this.InnerList.IndexOf(item));
                return;
            }

            throw new ArgumentException("Could noy find MetaDictionaryItem.", "item");
        }
Exemplo n.º 15
0
        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public int Add(MetaDictionaryItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            return this.Add(item.DefaultValue, item.Value, item.DefaultTag, item.Tag);
        }