Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / DataViewSettingCollection.cs / 1 / DataViewSettingCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections;
[
Editor("Microsoft.VSDesigner.Data.Design.DataViewSettingsCollectionEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing),
]
#if WINFSInternalOnly
internal
#else
public
#endif
class DataViewSettingCollection : ICollection {
private readonly DataViewManager dataViewManager;
private readonly Hashtable list = new Hashtable();
internal DataViewSettingCollection(DataViewManager dataViewManager) {
if (dataViewManager == null) {
throw ExceptionBuilder.ArgumentNull("dataViewManager");
}
this.dataViewManager = dataViewManager;
}
public virtual DataViewSetting this[DataTable table] {
get {
if (table == null) {
throw ExceptionBuilder.ArgumentNull("table");
}
DataViewSetting dataViewSetting = (DataViewSetting) list[table];
if(dataViewSetting == null) {
dataViewSetting = new DataViewSetting();
this[table] = dataViewSetting;
}
return dataViewSetting;
}
set {
if (table == null) {
throw ExceptionBuilder.ArgumentNull("table");
}
value.SetDataViewManager(dataViewManager);
value.SetDataTable(table);
list[table] = value;
}
}
private DataTable GetTable(string tableName) {
DataTable dt = null;
DataSet ds = dataViewManager.DataSet;
if(ds != null) {
dt = ds.Tables[tableName];
}
return dt;
}
private DataTable GetTable(int index) {
DataTable dt = null;
DataSet ds = dataViewManager.DataSet;
if(ds != null) {
dt = ds.Tables[index];
}
return dt;
}
public virtual DataViewSetting this[string tableName] {
get {
DataTable dt = GetTable(tableName);
if(dt != null) {
return this[dt];
}
return null;
}
}
public virtual DataViewSetting this[int index] {
get {
DataTable dt = GetTable(index);
if(dt != null) {
return this[dt];
}
return null;
}
set {
DataTable dt = GetTable(index);
if(dt != null) {
this[dt] = value;
}else {
// throw excaption here.
}
}
}
// ----------- ICollection -------------------------
public void CopyTo(Array ar, int index) {
System.Collections.IEnumerator Enumerator = GetEnumerator();
while (Enumerator.MoveNext()) {
ar.SetValue(Enumerator.Current, index++);
}
}
public void CopyTo(DataViewSetting[] ar, int index) {
System.Collections.IEnumerator Enumerator = GetEnumerator();
while (Enumerator.MoveNext()) {
ar.SetValue(Enumerator.Current, index++);
}
}
[Browsable(false)]
public virtual int Count {
get {
DataSet ds = dataViewManager.DataSet;
return (ds == null) ? 0 : ds.Tables.Count;
}
}
public IEnumerator GetEnumerator() {
// I have to do something here.
return new DataViewSettingsEnumerator(dataViewManager);
}
[
Browsable(false)
]
public bool IsReadOnly {
get {
return true;
}
}
[Browsable(false)]
public bool IsSynchronized {
get {
// so the user will know that it has to lock this object
return false;
}
}
[Browsable(false)]
public object SyncRoot {
get {
return this;
}
}
internal void Remove(DataTable table) {
list.Remove(table);
}
private sealed class DataViewSettingsEnumerator : IEnumerator {
DataViewSettingCollection dataViewSettings;
IEnumerator tableEnumerator;
public DataViewSettingsEnumerator(DataViewManager dvm) {
DataSet ds = dvm.DataSet;
if(ds != null) {
dataViewSettings = dvm.DataViewSettings;
tableEnumerator = dvm.DataSet.Tables.GetEnumerator();
}else {
dataViewSettings = null;
tableEnumerator = DataSet.zeroTables.GetEnumerator();
}
}
public bool MoveNext() {
return tableEnumerator.MoveNext();
}
public void Reset() {
tableEnumerator.Reset();
}
public object Current {
get {
return dataViewSettings[(DataTable) tableEnumerator.Current];
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data {
using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections;
[
Editor("Microsoft.VSDesigner.Data.Design.DataViewSettingsCollectionEditor, " + AssemblyRef.MicrosoftVSDesigner, "System.Drawing.Design.UITypeEditor, " + AssemblyRef.SystemDrawing),
]
#if WINFSInternalOnly
internal
#else
public
#endif
class DataViewSettingCollection : ICollection {
private readonly DataViewManager dataViewManager;
private readonly Hashtable list = new Hashtable();
internal DataViewSettingCollection(DataViewManager dataViewManager) {
if (dataViewManager == null) {
throw ExceptionBuilder.ArgumentNull("dataViewManager");
}
this.dataViewManager = dataViewManager;
}
public virtual DataViewSetting this[DataTable table] {
get {
if (table == null) {
throw ExceptionBuilder.ArgumentNull("table");
}
DataViewSetting dataViewSetting = (DataViewSetting) list[table];
if(dataViewSetting == null) {
dataViewSetting = new DataViewSetting();
this[table] = dataViewSetting;
}
return dataViewSetting;
}
set {
if (table == null) {
throw ExceptionBuilder.ArgumentNull("table");
}
value.SetDataViewManager(dataViewManager);
value.SetDataTable(table);
list[table] = value;
}
}
private DataTable GetTable(string tableName) {
DataTable dt = null;
DataSet ds = dataViewManager.DataSet;
if(ds != null) {
dt = ds.Tables[tableName];
}
return dt;
}
private DataTable GetTable(int index) {
DataTable dt = null;
DataSet ds = dataViewManager.DataSet;
if(ds != null) {
dt = ds.Tables[index];
}
return dt;
}
public virtual DataViewSetting this[string tableName] {
get {
DataTable dt = GetTable(tableName);
if(dt != null) {
return this[dt];
}
return null;
}
}
public virtual DataViewSetting this[int index] {
get {
DataTable dt = GetTable(index);
if(dt != null) {
return this[dt];
}
return null;
}
set {
DataTable dt = GetTable(index);
if(dt != null) {
this[dt] = value;
}else {
// throw excaption here.
}
}
}
// ----------- ICollection -------------------------
public void CopyTo(Array ar, int index) {
System.Collections.IEnumerator Enumerator = GetEnumerator();
while (Enumerator.MoveNext()) {
ar.SetValue(Enumerator.Current, index++);
}
}
public void CopyTo(DataViewSetting[] ar, int index) {
System.Collections.IEnumerator Enumerator = GetEnumerator();
while (Enumerator.MoveNext()) {
ar.SetValue(Enumerator.Current, index++);
}
}
[Browsable(false)]
public virtual int Count {
get {
DataSet ds = dataViewManager.DataSet;
return (ds == null) ? 0 : ds.Tables.Count;
}
}
public IEnumerator GetEnumerator() {
// I have to do something here.
return new DataViewSettingsEnumerator(dataViewManager);
}
[
Browsable(false)
]
public bool IsReadOnly {
get {
return true;
}
}
[Browsable(false)]
public bool IsSynchronized {
get {
// so the user will know that it has to lock this object
return false;
}
}
[Browsable(false)]
public object SyncRoot {
get {
return this;
}
}
internal void Remove(DataTable table) {
list.Remove(table);
}
private sealed class DataViewSettingsEnumerator : IEnumerator {
DataViewSettingCollection dataViewSettings;
IEnumerator tableEnumerator;
public DataViewSettingsEnumerator(DataViewManager dvm) {
DataSet ds = dvm.DataSet;
if(ds != null) {
dataViewSettings = dvm.DataViewSettings;
tableEnumerator = dvm.DataSet.Tables.GetEnumerator();
}else {
dataViewSettings = null;
tableEnumerator = DataSet.zeroTables.GetEnumerator();
}
}
public bool MoveNext() {
return tableEnumerator.MoveNext();
}
public void Reset() {
tableEnumerator.Reset();
}
public object Current {
get {
return dataViewSettings[(DataTable) tableEnumerator.Current];
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FileUtil.cs
- SubtreeProcessor.cs
- FileVersion.cs
- TableRowsCollectionEditor.cs
- ManualWorkflowSchedulerService.cs
- EntitySetBase.cs
- TableLayoutPanelResizeGlyph.cs
- MemberDescriptor.cs
- ListBase.cs
- Padding.cs
- RadioButtonRenderer.cs
- ConditionalAttribute.cs
- RuleRefElement.cs
- DataGridTemplateColumn.cs
- VScrollBar.cs
- OleAutBinder.cs
- SchemaEntity.cs
- DbConnectionFactory.cs
- SmtpReplyReaderFactory.cs
- PTManager.cs
- SiteOfOriginContainer.cs
- BoundingRectTracker.cs
- SqlTypesSchemaImporter.cs
- HtmlEmptyTagControlBuilder.cs
- DeviceContexts.cs
- InfoCardSymmetricAlgorithm.cs
- ActivationServices.cs
- XPathNavigatorKeyComparer.cs
- Condition.cs
- SqlHelper.cs
- HandleRef.cs
- EventItfInfo.cs
- mda.cs
- Parsers.cs
- CardSpaceSelector.cs
- HtmlInputReset.cs
- Misc.cs
- _NTAuthentication.cs
- SqlGatherConsumedAliases.cs
- Pen.cs
- Separator.cs
- TextSelectionProcessor.cs
- OutOfProcStateClientManager.cs
- RowToParametersTransformer.cs
- ValidatedControlConverter.cs
- TransformedBitmap.cs
- ProfileService.cs
- WebPartDescriptionCollection.cs
- ModifierKeysConverter.cs
- AssociationEndMember.cs
- EventData.cs
- followingquery.cs
- ScopedKnownTypes.cs
- IPipelineRuntime.cs
- StorageAssociationSetMapping.cs
- EntityModelBuildProvider.cs
- XmlSchemaImporter.cs
- DataGrid.cs
- AudioSignalProblemOccurredEventArgs.cs
- LogicalExpressionEditor.cs
- DesigntimeLicenseContext.cs
- Point4D.cs
- ColumnMapCopier.cs
- TimeZone.cs
- sqlstateclientmanager.cs
- InlinedLocationReference.cs
- SchemaElementLookUpTableEnumerator.cs
- GeneratedCodeAttribute.cs
- NativeMethods.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- InvalidStoreProtectionKeyException.cs
- BoundingRectTracker.cs
- Wildcard.cs
- DataContractAttribute.cs
- ItemChangedEventArgs.cs
- PointUtil.cs
- ListViewInsertionMark.cs
- EditCommandColumn.cs
- WindowsListViewItemStartMenu.cs
- TabPage.cs
- unsafenativemethodstextservices.cs
- CodeAccessPermission.cs
- BuildProvider.cs
- WindowsImpersonationContext.cs
- DefaultPropertiesToSend.cs
- DbConnectionPool.cs
- WindowsEditBoxRange.cs
- RuntimeHandles.cs
- AnnotationComponentChooser.cs
- PlainXmlWriter.cs
- comcontractssection.cs
- ArrangedElement.cs
- DataGridCaption.cs
- InvariantComparer.cs
- BindingExpressionBase.cs
- Iis7Helper.cs
- DebugView.cs
- DataViewManager.cs
- DataControlFieldTypeEditor.cs
- GuidConverter.cs