Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / Mail / AttachmentCollection.cs / 1 / AttachmentCollection.cs
using System;
using System.Collections.ObjectModel;
namespace System.Net.Mail
{
///
/// Summary description for AttachmentCollection.
///
public sealed class AttachmentCollection : Collection, IDisposable
{
bool disposed = false;
internal AttachmentCollection() { }
public void Dispose(){
if(disposed){
return;
}
foreach (Attachment attachment in this) {
attachment.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, Attachment 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, Attachment 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
{
///
/// Summary description for AttachmentCollection.
///
public sealed class AttachmentCollection : Collection, IDisposable
{
bool disposed = false;
internal AttachmentCollection() { }
public void Dispose(){
if(disposed){
return;
}
foreach (Attachment attachment in this) {
attachment.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, Attachment 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, Attachment 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
- HtmlTextArea.cs
- ExtensionSimplifierMarkupObject.cs
- Matrix3DConverter.cs
- ObjectListComponentEditor.cs
- AuthenticateEventArgs.cs
- XmlDictionary.cs
- EnumerableValidator.cs
- InternalConfigHost.cs
- XsdDuration.cs
- DefaultPropertyAttribute.cs
- Attributes.cs
- RecognizerBase.cs
- WebRequest.cs
- Hash.cs
- XPathScanner.cs
- HttpDigestClientCredential.cs
- DeclarativeExpressionConditionDeclaration.cs
- MessageUtil.cs
- DataGridViewCellConverter.cs
- CannotUnloadAppDomainException.cs
- DataColumnChangeEvent.cs
- HashSetDebugView.cs
- OptimizedTemplateContentHelper.cs
- ProviderUtil.cs
- UnsafeNativeMethods.cs
- PageParser.cs
- ViewStateModeByIdAttribute.cs
- SpellerStatusTable.cs
- X509Certificate2.cs
- SqlDataReaderSmi.cs
- SchemaNamespaceManager.cs
- WindowsListViewItem.cs
- XPathNodeHelper.cs
- BasicHttpBindingElement.cs
- CommandLineParser.cs
- GridLengthConverter.cs
- DataGridViewColumnEventArgs.cs
- OracleException.cs
- CapabilitiesUse.cs
- MatrixUtil.cs
- NeedSkipTokenVisitor.cs
- HttpValueCollection.cs
- FileSystemInfo.cs
- MenuBase.cs
- CodeDirectoryCompiler.cs
- ManualResetEvent.cs
- xmlsaver.cs
- LongPath.cs
- RemoteWebConfigurationHostServer.cs
- PageCodeDomTreeGenerator.cs
- MSHTMLHost.cs
- ToolStripRenderer.cs
- ZipQueryOperator.cs
- TimerElapsedEvenArgs.cs
- MsmqHostedTransportManager.cs
- ItemsPanelTemplate.cs
- DataContractJsonSerializer.cs
- Transform3D.cs
- Button.cs
- DrawingBrush.cs
- LinqDataSourceDeleteEventArgs.cs
- Rect.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- XmlNodeList.cs
- SymbolType.cs
- WebOperationContext.cs
- StringComparer.cs
- CodeArgumentReferenceExpression.cs
- TypeConverterHelper.cs
- ValueType.cs
- MethodAccessException.cs
- SqlUnionizer.cs
- InkPresenter.cs
- GeneralTransform3DTo2DTo3D.cs
- MetadataWorkspace.cs
- ValidationPropertyAttribute.cs
- Activator.cs
- ApplicationProxyInternal.cs
- ReplyChannelAcceptor.cs
- OleDbConnectionInternal.cs
- TreeChangeInfo.cs
- CompiledQueryCacheKey.cs
- ObjectDataSourceSelectingEventArgs.cs
- Stroke2.cs
- IODescriptionAttribute.cs
- LineBreakRecord.cs
- SafeHandles.cs
- SimpleLine.cs
- UriSection.cs
- documentsequencetextview.cs
- FrameworkTemplate.cs
- XsltFunctions.cs
- ElementsClipboardData.cs
- TeredoHelper.cs
- FunctionGenerator.cs
- Hashtable.cs
- OutKeywords.cs
- ServerIdentity.cs
- COSERVERINFO.cs
- MethodSignatureGenerator.cs