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
- EntityWrapperFactory.cs
- EmissiveMaterial.cs
- Variable.cs
- RelationshipFixer.cs
- SplineKeyFrames.cs
- NameTable.cs
- ElementProxy.cs
- CookieHandler.cs
- InkPresenter.cs
- XmlElementAttribute.cs
- ServiceEndpointCollection.cs
- ScriptingJsonSerializationSection.cs
- DataList.cs
- ApplicationInterop.cs
- DependencyProperty.cs
- GetResponse.cs
- ObjectIDGenerator.cs
- KeyboardDevice.cs
- NamedPipeAppDomainProtocolHandler.cs
- ExpressionLexer.cs
- QueryExpr.cs
- XamlFxTrace.cs
- HttpChannelHelpers.cs
- ReadOnlyState.cs
- StateManagedCollection.cs
- StylusSystemGestureEventArgs.cs
- WhiteSpaceTrimStringConverter.cs
- DynamicExpression.cs
- MenuItem.cs
- DrawingServices.cs
- RouteParameter.cs
- OpenTypeCommon.cs
- OleDbParameterCollection.cs
- WebPartConnectionsEventArgs.cs
- TextServicesProperty.cs
- UnconditionalPolicy.cs
- UnsafeNativeMethods.cs
- UriTemplateCompoundPathSegment.cs
- BuildProviderAppliesToAttribute.cs
- SQLBinaryStorage.cs
- SecuritySessionSecurityTokenAuthenticator.cs
- ListControl.cs
- OleDbParameterCollection.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- DoubleLinkListEnumerator.cs
- ToolStripTemplateNode.cs
- PageContent.cs
- JavaScriptObjectDeserializer.cs
- Encoding.cs
- IconConverter.cs
- WebBaseEventKeyComparer.cs
- TextTreeRootTextBlock.cs
- CompilerGeneratedAttribute.cs
- FontClient.cs
- DrawingGroupDrawingContext.cs
- SpecialNameAttribute.cs
- Renderer.cs
- DbProviderConfigurationHandler.cs
- ComPlusInstanceProvider.cs
- DesignerOptionService.cs
- CacheOutputQuery.cs
- PropertyEmitterBase.cs
- TextRangeSerialization.cs
- ByteAnimation.cs
- NameTable.cs
- TextSearch.cs
- Console.cs
- CapabilitiesRule.cs
- LicFileLicenseProvider.cs
- DatagridviewDisplayedBandsData.cs
- XslAst.cs
- AssemblySettingAttributes.cs
- SmtpCommands.cs
- RootNamespaceAttribute.cs
- HwndHostAutomationPeer.cs
- FileIOPermission.cs
- PagedDataSource.cs
- Decimal.cs
- PersistenceTask.cs
- ProfileGroupSettingsCollection.cs
- ExpressionConverter.cs
- RuntimeWrappedException.cs
- NumberFunctions.cs
- VisualBasicReference.cs
- FlowDocumentReaderAutomationPeer.cs
- Assembly.cs
- UniqueConstraint.cs
- ComboBoxItem.cs
- MdiWindowListStrip.cs
- XPathDocumentIterator.cs
- SegmentInfo.cs
- InfoCardMasterKey.cs
- AuthenticationSection.cs
- ModelMemberCollection.cs
- LayoutEngine.cs
- AQNBuilder.cs
- WindowsToolbarItemAsMenuItem.cs
- BCLDebug.cs
- PackWebResponse.cs
- HtmlInputButton.cs