Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / Mail / LinkedResourceCollection.cs / 1 / LinkedResourceCollection.cs
using System; using System.Collections.ObjectModel; namespace System.Net.Mail { public sealed class LinkedResourceCollection : Collection, IDisposable { bool disposed = false; internal LinkedResourceCollection() { } public void Dispose() { if(disposed){ return; } foreach (LinkedResource resource in this) { resource.Dispose(); } Clear(); disposed = true; } protected override void RemoveItem(int index){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.RemoveItem(index); } protected override void ClearItems(){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.ClearItems(); } protected override void SetItem(int index, LinkedResource item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null) { throw new ArgumentNullException("item"); } base.SetItem(index,item); } protected override void InsertItem(int index, LinkedResource item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null){ throw new ArgumentNullException("item"); } base.InsertItem(index,item); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.ObjectModel; namespace System.Net.Mail { public sealed class LinkedResourceCollection : Collection , IDisposable { bool disposed = false; internal LinkedResourceCollection() { } public void Dispose() { if(disposed){ return; } foreach (LinkedResource resource in this) { resource.Dispose(); } Clear(); disposed = true; } protected override void RemoveItem(int index){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.RemoveItem(index); } protected override void ClearItems(){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } base.ClearItems(); } protected override void SetItem(int index, LinkedResource item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null) { throw new ArgumentNullException("item"); } base.SetItem(index,item); } protected override void InsertItem(int index, LinkedResource item){ if (disposed) { throw new ObjectDisposedException(this.GetType().FullName); } if(item==null){ throw new ArgumentNullException("item"); } base.InsertItem(index,item); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommonObjectSecurity.cs
- HostedTcpTransportManager.cs
- BooleanProjectedSlot.cs
- ProcessStartInfo.cs
- XMLSchema.cs
- DeflateEmulationStream.cs
- AppSettingsExpressionBuilder.cs
- ExtendedProtectionPolicyTypeConverter.cs
- ColumnMapCopier.cs
- ValueType.cs
- DataSourceBooleanViewSchemaConverter.cs
- XmlFormatMapping.cs
- SrgsElementList.cs
- SqlHelper.cs
- ImageSource.cs
- SpellerInterop.cs
- HwndAppCommandInputProvider.cs
- HtmlLink.cs
- SelectedDatesCollection.cs
- Match.cs
- StorageAssociationSetMapping.cs
- PeerContact.cs
- FormClosingEvent.cs
- UTF8Encoding.cs
- TextRange.cs
- ControlBindingsCollection.cs
- GenericPrincipal.cs
- TypeContext.cs
- DynamicValueConverter.cs
- AddInToken.cs
- DoubleCollectionConverter.cs
- StreamGeometry.cs
- CodeTypeParameter.cs
- DSASignatureDeformatter.cs
- AssemblyNameProxy.cs
- RunClient.cs
- EventSource.cs
- SelectiveScrollingGrid.cs
- WeakHashtable.cs
- StylusPoint.cs
- FileNameEditor.cs
- TextDecorationLocationValidation.cs
- ConfigurationStrings.cs
- SafeSecurityHandles.cs
- X509RawDataKeyIdentifierClause.cs
- StylusPlugin.cs
- SqlConnectionString.cs
- LocatorGroup.cs
- MinimizableAttributeTypeConverter.cs
- ThousandthOfEmRealPoints.cs
- DataGridViewComboBoxColumn.cs
- ToolboxComponentsCreatingEventArgs.cs
- SoapHeader.cs
- VerificationAttribute.cs
- ObservableCollection.cs
- SingleAnimationUsingKeyFrames.cs
- ConfigurationSectionHelper.cs
- ReferenceSchema.cs
- BaseDataListActionList.cs
- RowBinding.cs
- BaseConfigurationRecord.cs
- RefreshEventArgs.cs
- UnsafeNativeMethods.cs
- EnumerableWrapperWeakToStrong.cs
- CopyAttributesAction.cs
- HttpListenerContext.cs
- PrintDialog.cs
- SymDocumentType.cs
- StringValidatorAttribute.cs
- WindowsAuthenticationModule.cs
- ExplicitDiscriminatorMap.cs
- DataGridViewSelectedColumnCollection.cs
- HWStack.cs
- NegotiateStream.cs
- SessionStateUtil.cs
- SystemResourceKey.cs
- VerticalAlignConverter.cs
- Point4DValueSerializer.cs
- Drawing.cs
- BulletChrome.cs
- DeleteHelper.cs
- DefaultBinder.cs
- DriveNotFoundException.cs
- Imaging.cs
- RelOps.cs
- DataServiceProviderMethods.cs
- TCEAdapterGenerator.cs
- StylusPointPropertyUnit.cs
- SqlNamer.cs
- DataControlFieldCell.cs
- WindowsButton.cs
- PropertyManager.cs
- DataTableReader.cs
- DataGridViewRowConverter.cs
- ProtectedConfiguration.cs
- TracingConnectionListener.cs
- UnaryNode.cs
- NotifyInputEventArgs.cs
- StyleBamlTreeBuilder.cs
- MasterPage.cs