[Mono-dev] Removing #region and #endregion from source code`
Daniel Morgan
monodanmorg at yahoo.com
Fri Sep 26 17:11:55 EDT 2008
Raja,
Please do not remove #region and #endregion from source code files. Just because your favorite text editor does not support #region does not give your the right to remove these. My favorite text editor does support #region.
Thanks,
Daniel
--- On Fri, 9/26/08, Raja R Harinath (rharinath at novell.com) <mono-patches-list at lists.ximian.com> wrote:
> From: Raja R Harinath (rharinath at novell.com) <mono-patches-list at lists.ximian.com>
> Subject: [Mono-patches] r114232 - trunk/mcs/class/System.Data/System.Data
> To: mono-patches at lists.ximian.com, ximian.monolist at gmail.com, mono-svn-patches-garchive-20758 at googlegroups.com
> Date: Friday, September 26, 2008, 4:00 PM
> Author: raja
> Date: 2008-09-26 16:00:41 -0400 (Fri, 26 Sep 2008)
> New Revision: 114232
>
> Modified:
> trunk/mcs/class/System.Data/System.Data/ChangeLog
> trunk/mcs/class/System.Data/System.Data/DataView.cs
> Log:
> * DataView.cs: Convert into a partial class and sequester
> interface-implementations and NET_2_0 pieces into separate
> parts.
>
> Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
> ===================================================================
> ---
> trunk/mcs/class/System.Data/System.Data/ChangeLog 2008-09-26
> 20:00:05 UTC (rev 114231)
> +++
> trunk/mcs/class/System.Data/System.Data/ChangeLog 2008-09-26
> 20:00:41 UTC (rev 114232)
> @@ -1,3 +1,8 @@
> +2008-09-27 Raja R Harinath <harinath at hurrynot.org>
> +
> + * DataView.cs: Convert into a partial class and sequester
> + interface-implementations and NET_2_0 pieces into
> separate parts.
> +
> 2008-09-16 brandin claar <brandin.claar at gmail.com>
> Raja R Harinath <harinath at hurrynot.org>
>
>
> Modified:
> trunk/mcs/class/System.Data/System.Data/DataView.cs
> ===================================================================
> ---
> trunk/mcs/class/System.Data/System.Data/DataView.cs 2008-09-26
> 20:00:05 UTC (rev 114231)
> +++
> trunk/mcs/class/System.Data/System.Data/DataView.cs 2008-09-26
> 20:00:41 UTC (rev 114232)
> @@ -35,12 +35,7 @@
> [DefaultEvent ("PositionChanged")]
> [DefaultProperty ("Table")]
> [DesignerAttribute
> ("Microsoft.VSDesigner.Data.VS.DataViewDesigner,
> "+ Consts.AssemblyMicrosoft_VSDesigner,
> "System.ComponentModel.Design.IDesigner")]
> -#if NET_2_0
> - public class DataView : MarshalByValueComponent,
> IBindingList, IList, ICollection, IEnumerable, ITypedList,
> ISupportInitialize, IBindingListView,
> ISupportInitializeNotification
> -#else
> - public class DataView : MarshalByValueComponent,
> IBindingList, IList, ICollection, IEnumerable, ITypedList,
> ISupportInitialize
> -#endif
> - {
> + public partial class DataView : MarshalByValueComponent,
> IEnumerable, ISupportInitialize {
> internal DataTable dataTable;
> string rowFilter = String.Empty;
> IExpression rowFilterExpr;
> @@ -50,9 +45,6 @@
> DataColumn [] sortColumns;
> internal DataViewRowState rowState;
> internal DataRowView[] rowCache = new DataRowView [0];
> -#if NET_2_0
> - private bool dataViewInitialized = true;
> -#endif
>
> // BeginInit() support
> bool isInitPhase;
> @@ -80,8 +72,6 @@
> private DataViewManager dataViewManager;
> internal static ListChangedEventArgs ListResetEventArgs
> = new ListChangedEventArgs (ListChangedType.Reset,-1,-1);
>
> - #region Constructors
> -
> public DataView ()
> {
> rowState = DataViewRowState.CurrentRows;
> @@ -118,10 +108,7 @@
> rowState = RowState;
> Open ();
> }
> - #endregion // Constructors
>
> - #region PublicProperties
> -
> [DataCategory ("Data")]
> #if !NET_2_0
> [DataSysDescription ("Indicates whether this
> DataView and the user interface associated with it allows
> deletes.")]
> @@ -343,16 +330,6 @@
> }
> }
>
> -#if NET_2_0
> - [Browsable (false)]
> - public bool IsInitialized {
> - get { return dataViewInitialized; }
> - }
> -#endif
> - #endregion // PublicProperties
> -
> - #region PublicMethods
> -
> public virtual DataRowView AddNew ()
> {
> if (!IsOpen)
> @@ -402,11 +379,11 @@
> initRowState = RowStateFilter;
>
> isInitPhase = true;
> -#if NET_2_0
> - dataViewInitialized = false;
> -#endif
> + DataViewInitialized (false);
> }
>
> + partial void DataViewInitialized (bool value);
> +
> public void CopyTo (Array array, int index)
> {
> if (index + rowCache.Length > array.Length)
> @@ -436,27 +413,6 @@
> row.Row.Delete ();
> }
>
> -#if NET_2_0
> - public virtual bool Equals (DataView dv)
> - {
> - if (this == dv)
> - return true;
> - if (!(this.Table == dv.Table && this.Sort ==
> dv.Sort &&
> - this.RowFilter == dv.RowFilter &&
> - this.RowStateFilter == dv.RowStateFilter &&
> - this.AllowEdit == dv.AllowEdit &&
> - this.AllowNew == dv.AllowNew &&
> - this.AllowDelete == dv.AllowDelete &&
> - this.Count == dv.Count))
> - return false;
> -
> - for (int i = 0; i < Count; ++i)
> - if (!this [i].Equals (dv [i]))
> - return false;
> - return true;
> - }
> -#endif
> -
> public void EndInit ()
> {
> isInitPhase = false;
> @@ -473,10 +429,7 @@
>
> UpdateIndex (true);
>
> -#if NET_2_0
> - dataViewInitialized = true;
> - DataViewInitialized ();
> -#endif
> + DataViewInitialized (true);
> }
>
> public int Find (object key)
> @@ -532,18 +485,12 @@
> return dataRowViews.GetEnumerator ();
> }
>
> - #endregion // PublicMethods
> -
> [DataCategory ("Data")]
> #if !NET_2_0
> [DataSysDescription ("Indicates that the data
> returned by this DataView has somehow changed.")]
> #endif
> public event ListChangedEventHandler ListChanged;
>
> -#if NET_2_0
> - public event EventHandler Initialized;
> -#endif
> -
> [Browsable (false)]
> #if !NET_2_0
> [DataSysDescription ("Indicates whether the view is
> open. ")]
> @@ -717,19 +664,6 @@
> OnListChanged (new ListChangedEventArgs
> (ListChangedType.ItemDeleted, newIndex, -1));
> }
>
> -#if NET_2_0
> - private void DataViewInitialized ()
> - {
> - EventArgs e = new EventArgs ();
> - OnDataViewInitialized (e);
> - }
> -
> - private void OnDataViewInitialized (EventArgs e)
> - {
> - if (null != Initialized)
> - Initialized (this, e);
> - }
> -#endif
> protected virtual void ColumnCollectionChanged (object
> sender, CollectionChangeEventArgs e)
> {
> // UpdateIndex() is not invoked here (even if the sort
> @@ -789,88 +723,6 @@
> OnListChanged (new ListChangedEventArgs
> (ListChangedType.Reset, -1, -1 ));
> }
>
> -#if NET_2_0
> - public DataTable ToTable ()
> - {
> - return this.ToTable (Table.TableName, false, new
> string[] {});
> - }
> -
> - public DataTable ToTable (string tableName)
> - {
> - return this.ToTable (tableName, false, new string[]
> {});
> - }
> -
> - public DataTable ToTable (bool isDistinct, params
> string[] columnNames)
> - {
> - return this.ToTable (Table.TableName, isDistinct,
> columnNames);
> - }
> -
> - public DataTable ToTable (string tablename, bool
> isDistinct, params string[] columnNames)
> - {
> - if (columnNames == null)
> - throw new ArgumentNullException
> ("columnNames", "'columnNames'
> argument cannot be null.");
> -
> - DataTable newTable = new DataTable (tablename);
> -
> - DataColumn[] columns;
> - ListSortDirection[] sortDirection = null;
> - if (columnNames.Length != 0) {
> - columns = new DataColumn [columnNames.Length];
> - for (int i=0; i < columnNames.Length; ++i)
> - columns [i] = Table.Columns [columnNames [i]];
> -
> - if (sortColumns != null) {
> - sortDirection = new ListSortDirection
> [columnNames.Length];
> - for (int i=0; i < columnNames.Length; ++i) {
> - sortDirection [i] = ListSortDirection.Ascending;
> - for (int j = 0; j < sortColumns.Length; ++j) {
> - if (sortColumns [j] != columns [i])
> - continue;
> - sortDirection [i] = sortOrder [j];
> - }
> - }
> - }
> - } else {
> - columns = (DataColumn[]) Table.Columns.ToArray (typeof
> (DataColumn));
> - sortDirection = sortOrder;
> - }
> -
> - ArrayList expressionCols = new ArrayList ();
> - for (int i = 0; i < columns.Length; ++i) {
> - DataColumn col = columns [i].Clone ();
> - if (col.Expression != String.Empty) {
> - col.Expression = string.Empty;
> - expressionCols.Add (col);
> - }
> - if (col.ReadOnly)
> - col.ReadOnly = false;
> - newTable.Columns.Add (col);
> - }
> -
> - DataRow [] rows;
> - Index index = new Index (new Key(Table, columns,
> sortDirection, RowStateFilter, rowFilterExpr));
> - if (isDistinct)
> - rows = index.GetDistinctRows ();
> - else
> - rows = index.GetAllRows ();
> -
> - foreach (DataRow row in rows) {
> - DataRow newRow = newTable.NewNotInitializedRow ();
> - newTable.Rows.AddInternal (newRow);
> - newRow.Original = -1;
> - if (row.HasVersion (DataRowVersion.Current))
> - newRow.Current = newTable.RecordCache.CopyRecord
> (Table, row.Current, -1);
> - else if (row.HasVersion (DataRowVersion.Original))
> - newRow.Current = newTable.RecordCache.CopyRecord
> (Table, row.Original, -1);
> -
> - foreach (DataColumn col in expressionCols)
> - newRow [col] = row [col.ColumnName];
> - newRow.Original = -1;
> - }
> - return newTable;
> - }
> -#endif
> -
> protected void UpdateIndex ()
> {
> UpdateIndex (false);
> @@ -956,13 +808,85 @@
> }
>
>
> + private int IndexOf (DataRow dr)
> + {
> + for (int i=0; i < rowCache.Length; i++)
> + if (dr.Equals (rowCache [i].Row))
> + return i;
> + return -1;
> + }
> +
> + private void PopulateDefaultSort ()
> + {
> + sort = string.Empty;
> + foreach (Constraint c in dataTable.Constraints) {
> + if (c is UniqueConstraint) {
> + PopulateDefaultSort ((UniqueConstraint) c);
> + break;
> + }
> + }
> + }
> +
> + private void PopulateDefaultSort (UniqueConstraint uc)
> + {
> + if (isInitPhase)
> + return;
> +
> + DataColumn [] columns = uc.Columns;
> + if (columns.Length == 0) {
> + sort = String.Empty;
> + return;
> + }
> +
> + StringBuilder builder = new StringBuilder ();
> + builder.Append (columns[0].ColumnName);
> + for (int i = 1; i < columns.Length; i++) {
> + builder.Append (", ");
> + builder.Append (columns [i].ColumnName);
> + }
> + sort = builder.ToString ();
> + }
> +
> + internal DataView CreateChildView (DataRelation
> relation, int index)
> + {
> + if (relation == null || relation.ParentTable != Table)
> + throw new ArgumentException("The relation is not
> parented to the table to which this DataView points.");
> +
> + int record = GetRecord (index);
> + object[] keyValues = new object
> [relation.ParentColumns.Length];
> + for (int i = 0; i < relation.ParentColumns.Length;
> i++)
> + keyValues [i] = relation.ParentColumns [i] [record];
> +
> + return new RelatedDataView (relation.ChildColumns,
> keyValues);
> + }
> +
> + private int GetRecord (int index)
> + {
> + if (index < 0 || index >= Count)
> + throw new
> IndexOutOfRangeException(String.Format("There is no row
> at position {0}.", index));
> +
> + return (index == Index.Size) ?
> + _lastAdded.IndexFromVersion (DataRowVersion.Default) :
> + Index.IndexToRecord (index);
> + }
> +
> + internal DataRowVersion GetRowVersion (int index)
> + {
> + int record = GetRecord (index);
> + return Table.RecordCache [record].VersionFromIndex
> (record);
> + }
> + }
> +
> + partial class DataView : ITypedList {
> string ITypedList.GetListName (PropertyDescriptor []
> listAccessors)
> {
> if (dataTable != null)
> return dataTable.TableName;
> return string.Empty;
> }
> + }
>
> + partial class DataView : ICollection {
> bool ICollection.IsSynchronized {
> get { return false; }
> }
> @@ -970,7 +894,9 @@
> object ICollection.SyncRoot {
> get { return this; }
> }
> + }
>
> + partial class DataView : IList {
> bool IList.IsFixedSize {
> get { return false; }
> }
> @@ -1030,9 +956,9 @@
> {
> Delete (index);
> }
> + }
>
> - #region IBindingList implementation
> -
> + partial class DataView : IBindingList {
> [MonoTODO]
> void IBindingList.AddIndex (PropertyDescriptor property)
> {
> @@ -1124,11 +1050,10 @@
> bool IBindingList.SupportsSorting {
> get { return true; }
> }
> + }
>
> - #endregion // IBindingList implementation
> -
> #if NET_2_0
> - #region IBindingListView implementation
> + partial class DataView : IBindingListView {
> string IBindingListView.Filter {
> get { return ((DataView) this).RowFilter; }
> set { ((DataView) this).RowFilter = value; }
> @@ -1169,76 +1094,130 @@
> {
> ((IBindingListView) this).Filter = string.Empty;
> }
> + }
>
> - #endregion //IBindingViewList implementation
> -#endif
> + partial class DataView : ISupportInitializeNotification {
> + private bool dataViewInitialized = true;
>
> - private int IndexOf (DataRow dr)
> - {
> - for (int i=0; i < rowCache.Length; i++)
> - if (dr.Equals (rowCache [i].Row))
> - return i;
> - return -1;
> + [Browsable (false)]
> + public bool IsInitialized {
> + get { return dataViewInitialized; }
> }
>
> - private void PopulateDefaultSort ()
> + public event EventHandler Initialized;
> +
> + partial void DataViewInitialized (bool value)
> {
> - sort = string.Empty;
> - foreach (Constraint c in dataTable.Constraints) {
> - if (c is UniqueConstraint) {
> - PopulateDefaultSort ((UniqueConstraint) c);
> - break;
> - }
> - }
> + dataViewInitialized = value;
> + if (value)
> + OnDataViewInitialized (new EventArgs ());
> }
>
> - private void PopulateDefaultSort (UniqueConstraint uc)
> + private void OnDataViewInitialized (EventArgs e)
> {
> - if (isInitPhase)
> - return;
> -
> - DataColumn [] columns = uc.Columns;
> - if (columns.Length == 0) {
> - sort = String.Empty;
> - return;
> - }
> -
> - StringBuilder builder = new StringBuilder ();
> - builder.Append (columns[0].ColumnName);
> - for (int i = 1; i < columns.Length; i++) {
> - builder.Append (", ");
> - builder.Append (columns [i].ColumnName);
> - }
> - sort = builder.ToString ();
> + if (null != Initialized)
> + Initialized (this, e);
> }
> + }
>
> - internal DataView CreateChildView (DataRelation
> relation, int index)
> + partial class DataView {
> + public virtual bool Equals (DataView dv)
> {
> - if (relation == null || relation.ParentTable != Table)
> - throw new ArgumentException("The relation is not
> parented to the table to which this DataView points.");
> + if (this == dv)
> + return true;
> + if (!(this.Table == dv.Table && this.Sort ==
> dv.Sort &&
> + this.RowFilter == dv.RowFilter &&
> + this.RowStateFilter == dv.RowStateFilter &&
> + this.AllowEdit == dv.AllowEdit &&
> + this.AllowNew == dv.AllowNew &&
> + this.AllowDelete == dv.AllowDelete &&
> + this.Count == dv.Count))
> + return false;
>
> - int record = GetRecord (index);
> - object[] keyValues = new object
> [relation.ParentColumns.Length];
> - for (int i = 0; i < relation.ParentColumns.Length;
> i++)
> - keyValues [i] = relation.ParentColumns [i] [record];
> -
> - return new RelatedDataView (relation.ChildColumns,
> keyValues);
> + for (int i = 0; i < Count; ++i)
> + if (!this [i].Equals (dv [i]))
> + return false;
> + return true;
> }
> + public DataTable ToTable ()
> + {
> + return this.ToTable (Table.TableName, false, new
> string[] {});
> + }
>
> - private int GetRecord (int index)
> + public DataTable ToTable (string tableName)
> {
> - if (index < 0 || index >= Count)
> - throw new
> IndexOutOfRangeException(String.Format("There is no row
> at position {0}.", index));
> + return this.ToTable (tableName, false, new string[]
> {});
> + }
>
> - return (index == Index.Size) ?
> - _lastAdded.IndexFromVersion (DataRowVersion.Default) :
> - Index.IndexToRecord (index);
> + public DataTable ToTable (bool isDistinct, params
> string[] columnNames)
> + {
> + return this.ToTable (Table.TableName, isDistinct,
> columnNames);
> }
>
> - internal DataRowVersion GetRowVersion (int index)
> + public DataTable ToTable (string tablename, bool
> isDistinct, params string[] columnNames)
> {
> - int record = GetRecord (index);
> - return Table.RecordCache [record].VersionFromIndex
> (record);
> + if (columnNames == null)
> + throw new ArgumentNullException
> ("columnNames", "'columnNames'
> argument cannot be null.");
> +
> + DataTable newTable = new DataTable (tablename);
> +
> + DataColumn[] columns;
> + ListSortDirection[] sortDirection = null;
> + if (columnNames.Length != 0) {
> + columns = new DataColumn [columnNames.Length];
> + for (int i=0; i < columnNames.Length; ++i)
> + columns [i] = Table.Columns [columnNames [i]];
> +
> + if (sortColumns != null) {
> + sortDirection = new ListSortDirection
> [columnNames.Length];
> + for (int i=0; i < columnNames.Length; ++i) {
> + sortDirection [i] = ListSortDirection.Ascending;
> + for (int j = 0; j < sortColumns.Length; ++j) {
> + if (sortColumns [j] != columns [i])
> + continue;
> + sortDirection [i] = sortOrder [j];
> + }
> + }
> + }
> + } else {
> + columns = (DataColumn[]) Table.Columns.ToArray (typeof
> (DataColumn));
> + sortDirection = sortOrder;
> + }
> +
> + ArrayList expressionCols = new ArrayList ();
> + for (int i = 0; i < columns.Length; ++i) {
> + DataColumn col = columns [i].Clone ();
> + if (col.Expression != String.Empty) {
> + col.Expression = string.Empty;
> + expressionCols.Add (col);
> + }
> + if (col.ReadOnly)
> + col.ReadOnly = false;
> + newTable.Columns.Add (col);
> + }
> +
> + DataRow [] rows;
> + Index index = new Index (new Key(Table, columns,
> sortDirection, RowStateFilter, rowFilterExpr));
> + if (isDistinct)
> + rows = index.GetDistinctRows ();
> + else
> + rows = index.GetAllRows ();
> +
> + foreach (DataRow row in rows) {
> + DataRow newRow = newTable.NewNotInitializedRow ();
> + newTable.Rows.AddInternal (newRow);
> + newRow.Original = -1;
> + if (row.HasVersion (DataRowVersion.Current))
> + newRow.Current = newTable.RecordCache.CopyRecord
> (Table, row.Current, -1);
> + else if (row.HasVersion (DataRowVersion.Original))
> + newRow.Current = newTable.RecordCache.CopyRecord
> (Table, row.Original, -1);
> +
> + foreach (DataColumn col in expressionCols)
> + newRow [col] = row [col.ColumnName];
> + newRow.Original = -1;
> + }
> + return newTable;
> }
> }
> +#endif
> }
>
> _______________________________________________
> Mono-patches maillist - Mono-patches at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-patches
More information about the Mono-devel-list
mailing list