Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / DrawingCollection.cs / 1305600 / DrawingCollection.cs
//----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Description: This file contains non-generated DrawingCollection
// methods.
//
// History:
//
// 2005/03/18 : timothyc - Created it.
//
//---------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Windows.Media.Animation;
using System.Windows.Markup;
namespace System.Windows.Media
{
///
/// Collection of Drawing objects
///
public sealed partial class DrawingCollection : Animatable, IList, IList
{
///
/// Appends the entire input DrawingCollection, while only firing a single set of
/// public events. If an exception is thrown from the public events, the
/// Append operation is rolled back.
///
internal void TransactionalAppend(DrawingCollection collectionToAppend)
{
// Use appendCount to avoid inconsistencies & runaway loops when
// this == collectionToAppend, and to ensure collectionToAppend.Count
// is only evaluated once.
int appendCount = collectionToAppend.Count;
// First, append the collection
for(int i = 0; i < appendCount; i++)
{
AddWithoutFiringPublicEvents(collectionToAppend.Internal_GetItem(i));
}
// Fire the public Changed event after all the elements have been added.
//
// If an exception is thrown, then the Append operation is rolled-back without
// firing additional events.
try
{
FireChanged();
}
catch (Exception)
{
// Compute the number of elements that existed before the append
int beforeAppendCount = Count - appendCount;
// Remove the appended elements in reverse order without firing Changed events.
for ( int i = Count - 1; // Start at the current last index
i >= beforeAppendCount; // Until the previous last index
i-- // Move to the preceding index
)
{
RemoveAtWithoutFiringPublicEvents(i);
}
// Avoid firing WritePostscript events (e.g., OnChanged) after rolling-back
// the current operation.
//
// This ensures that only a single set of events is fired for both exceptional &
// typical cases, and it's likely that firing events would cause another exception.
throw;
}
}
}
}
// 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
- SoapEnumAttribute.cs
- ClientSession.cs
- DesignColumnCollection.cs
- SortedDictionary.cs
- SqlClientMetaDataCollectionNames.cs
- FieldToken.cs
- PreApplicationStartMethodAttribute.cs
- MultipleFilterMatchesException.cs
- _LocalDataStoreMgr.cs
- ClientRoleProvider.cs
- RootBrowserWindow.cs
- QilInvokeLateBound.cs
- ArgumentException.cs
- SrgsNameValueTag.cs
- StateChangeEvent.cs
- xmlsaver.cs
- ExpressionParser.cs
- BitmapEffectState.cs
- Ref.cs
- TextBoxLine.cs
- CultureData.cs
- RenderingEventArgs.cs
- SystemResources.cs
- SmiRequestExecutor.cs
- TransportSecurityProtocol.cs
- SecureUICommand.cs
- MembershipValidatePasswordEventArgs.cs
- CustomTypeDescriptor.cs
- InstanceHandleReference.cs
- WebPartCloseVerb.cs
- AutomationPatternInfo.cs
- ConvertEvent.cs
- TabItemAutomationPeer.cs
- Pen.cs
- PreservationFileWriter.cs
- Int64Storage.cs
- NameSpaceEvent.cs
- CngAlgorithmGroup.cs
- dsa.cs
- SelectionPatternIdentifiers.cs
- IncrementalReadDecoders.cs
- MarkupCompilePass1.cs
- HopperCache.cs
- RotateTransform.cs
- SrgsGrammarCompiler.cs
- BrowsableAttribute.cs
- WebBrowserNavigatedEventHandler.cs
- mansign.cs
- MessageDroppedTraceRecord.cs
- PhysicalFontFamily.cs
- DiagnosticTrace.cs
- BufferAllocator.cs
- PagesChangedEventArgs.cs
- ImageFormatConverter.cs
- UTF8Encoding.cs
- DataRowChangeEvent.cs
- DiscoveryClientOutputChannel.cs
- HttpCacheParams.cs
- EnumMemberAttribute.cs
- RotateTransform3D.cs
- EntityDataSourceDesignerHelper.cs
- CompatibleComparer.cs
- PreservationFileWriter.cs
- RegexCode.cs
- ButtonPopupAdapter.cs
- PointCollection.cs
- MailWebEventProvider.cs
- FontNameConverter.cs
- ServicesUtilities.cs
- JoinTreeSlot.cs
- DataReceivedEventArgs.cs
- ListItemCollection.cs
- UnicastIPAddressInformationCollection.cs
- ArraySegment.cs
- RegularExpressionValidator.cs
- WebResponse.cs
- SqlInternalConnectionSmi.cs
- WS2007HttpBindingCollectionElement.cs
- NameValuePair.cs
- XmlParser.cs
- ClaimComparer.cs
- ObjectStorage.cs
- ReadOnlyDataSource.cs
- CategoryNameCollection.cs
- EnlistmentTraceIdentifier.cs
- SecurityCriticalDataForSet.cs
- MultipartIdentifier.cs
- DocumentPageHost.cs
- DataTrigger.cs
- TypedDataSourceCodeGenerator.cs
- MultiTrigger.cs
- KeyGestureConverter.cs
- Psha1DerivedKeyGenerator.cs
- CodeSnippetExpression.cs
- SubMenuStyle.cs
- SecurityState.cs
- Quaternion.cs
- UnsafeNativeMethods.cs
- HttpHeaderCollection.cs
- UpdateProgress.cs