Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / LinkedResourceCollection.cs / 1305376 / 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
- ButtonFieldBase.cs
- ToolTip.cs
- CallbackValidator.cs
- DetailsViewUpdateEventArgs.cs
- SerializationAttributes.cs
- DataException.cs
- PeerNameRecord.cs
- ActivationArguments.cs
- ResXFileRef.cs
- EditorPart.cs
- ConfigXmlWhitespace.cs
- DataGridViewCellLinkedList.cs
- ExpandCollapseIsCheckedConverter.cs
- SqlNotificationEventArgs.cs
- ImageMap.cs
- DropTarget.cs
- AxHost.cs
- DataGridViewColumnConverter.cs
- XmlObjectSerializer.cs
- StrongNameMembershipCondition.cs
- PointLightBase.cs
- XmlTextAttribute.cs
- SqlTriggerContext.cs
- GridView.cs
- EntityContainerAssociationSet.cs
- Module.cs
- ReflectionTypeLoadException.cs
- SqlError.cs
- SqlConnectionStringBuilder.cs
- EventLogSession.cs
- WCFServiceClientProxyGenerator.cs
- AbsoluteQuery.cs
- PropertyDescriptorCollection.cs
- BaseParser.cs
- WindowsPrincipal.cs
- ControllableStoryboardAction.cs
- WaitHandle.cs
- SchemaConstraints.cs
- ComponentGuaranteesAttribute.cs
- Stroke.cs
- EventLogEntry.cs
- QuaternionKeyFrameCollection.cs
- __TransparentProxy.cs
- TimeZoneNotFoundException.cs
- ProxyWebPartConnectionCollection.cs
- EncoderNLS.cs
- GridViewColumnCollectionChangedEventArgs.cs
- LocalIdKeyIdentifierClause.cs
- QilScopedVisitor.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- StrokeNodeEnumerator.cs
- FieldToken.cs
- PolyBezierSegment.cs
- ComponentRenameEvent.cs
- TypeConverterBase.cs
- PathFigureCollectionValueSerializer.cs
- DoubleAnimationBase.cs
- RadioButtonAutomationPeer.cs
- TemplateControl.cs
- CryptoHelper.cs
- QilDataSource.cs
- ZipIOModeEnforcingStream.cs
- PromptBuilder.cs
- InfoCardTraceRecord.cs
- QilCloneVisitor.cs
- SmtpException.cs
- ToolStripItemTextRenderEventArgs.cs
- OracleConnectionString.cs
- SizeValueSerializer.cs
- TTSVoice.cs
- CodeLinePragma.cs
- SqlBuffer.cs
- DataGridRowEventArgs.cs
- RegistryPermission.cs
- ScriptResourceAttribute.cs
- SelfIssuedAuthAsymmetricKey.cs
- WrappedReader.cs
- ComContractElement.cs
- XpsResource.cs
- AssemblyNameProxy.cs
- DispatcherBuilder.cs
- RawAppCommandInputReport.cs
- ManipulationVelocities.cs
- XhtmlBasicSelectionListAdapter.cs
- FunctionParameter.cs
- PreloadedPackages.cs
- DesignerActionItem.cs
- DatatypeImplementation.cs
- MissingFieldException.cs
- DataRowCollection.cs
- ExtenderControl.cs
- PtsContext.cs
- Win32.cs
- AccessedThroughPropertyAttribute.cs
- BuildProviderInstallComponent.cs
- CharStorage.cs
- _SslSessionsCache.cs
- Bezier.cs
- FieldNameLookup.cs
- VisualStyleRenderer.cs