📄 recordlistt.cs
字号:
/** Copyright (c) 2006, All-In-One Creations, Ltd.* All rights reserved.* * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:* * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.* * Neither the name of All-In-One Creations, Ltd. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**//** * Project: emergetk: stateful web framework for the masses * File name: RecordListT.cs * Description: A generic friendly wrapper to RecordList. * * Author: Ben Joldersma * */using System;using System.Collections;using System.Collections.Generic;using System.Web;using System.Reflection;using System.Data;namespace EmergeTk.Model{ public delegate void RecordListHandler<T>(RecordList<T> list) where T : AbstractRecord, new(); /// <summary> /// Summary description for RecordList. /// </summary> public class RecordList<T> : IRecordList, IRecordList<T> where T : AbstractRecord, new() { private RecordList list; public RecordList() { list = new RecordList(); list.RecordType = typeof(T); } #region IList Members public bool IsReadOnly { get { // TODO: Add RecordList.IsReadOnly getter implementation return false; } } public Type RecordType { get { return typeof(T); } set { throw new System.NotSupportedException("Cannot set type on a generic recordlist."); } } public T this[int index] { get { return list[index] as T; } set { list[index] = value; } } public bool Live { get { return list.Live; } set { list.Live = value; } } public void RemoveAt(int index) { list.RemoveAt(index); } public void Insert(int index, T value) { list.Insert( index, value ); } public List<SortInfo> Sorts { get { return list.Sorts; } set { list.Sorts = value; } } public List<FilterInfo> Filters { get { return list.Filters; } set { list.Filters = value; } } public void Remove(T value) { list.Remove(value); } public bool Contains(T value) { return list.Contains(value); } public void Clear() { list.Clear(); } public int IndexOf(T value) { return list.IndexOf(value); } public void Add(T value) { list.Add(value); } public T NewRow() { return list.NewRow<T>() as T; } public int Count { get { return list.Count; } } #endregion public void Sort() { list.Sort(); } public void AddFilter(FilterInfo filterInfo) { list.AddFilter(filterInfo); } public void Filter() { list.Filter(); } public string[] ToStringArray() { return list.ToStringArray(); } public string[] ToStringArray(string property) { return list.ToStringArray(property); } public string[] ToIdArray() { return list.ToIdArray(); } public void Save() { list.Save(); } public void Delete() { list.Delete(); } public void Delete(T value) { list.Delete(value); } public void DeleteAt(int index) { list.DeleteAt(index); } public string toJSON(JSON.Type transportType, List<DataGridColumn> columns, int pageIndex, int pageSize ) { return list.toJSON(transportType, columns, pageIndex, pageSize); } //Events public event RecordHandler OnRecordChanged { add { list.OnRecordChanged += value; } remove { list.OnRecordChanged -= value; } } public event RecordHandler OnRecordRemoved { add { list.OnRecordRemoved += value; } remove { list.OnRecordRemoved -= value; } } public event RecordHandler OnRecordAdded { add { list.OnRecordAdded += value; } remove { list.OnRecordAdded -= value; } } public IEnumerator<AbstractRecord> GetEnumerator() { return list.GetEnumerator(); } #region IRecordList Members AbstractRecord IRecordList.this[int index] { get { return list[index]; } set { list[index] = value; } } public void Add(AbstractRecord value) { list.Add(value); } public bool Contains(AbstractRecord value) { return list.Contains(value); } public int IndexOf(AbstractRecord value) { return list.IndexOf(value); } public void Insert(int index, AbstractRecord value) { list.Insert(index, value); } public AbstractRecord NewRow<N>() where N : AbstractRecord,new() { return list.NewRow<T>(); } public void Remove(AbstractRecord value) { list.Remove(value); } public void Delete(AbstractRecord value) { list.Delete(value); } #endregion #region IComparable Members public int CompareTo(object obj) { return list.CompareTo(obj); } #endregion }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -