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)); }
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(); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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"); }
/// <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(); }
/// <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(); }
/// <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(); }
/// <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(); }
/// <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(); }
/// <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); }
/// <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); }
/// <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"); }
/// <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); }