Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / DrawingCollection.cs / 1 / 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.
//----------------------------------------------------------------------------
//
// 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
- UpdateTranslator.cs
- ControlUtil.cs
- CellRelation.cs
- BasicHttpBinding.cs
- CipherData.cs
- Touch.cs
- WebPartUtil.cs
- SerializerWriterEventHandlers.cs
- Floater.cs
- XmlDataImplementation.cs
- SpecularMaterial.cs
- InsufficientExecutionStackException.cs
- PageAsyncTask.cs
- sitestring.cs
- EventLogEntry.cs
- SqlProviderManifest.cs
- Rfc2898DeriveBytes.cs
- SelectionRange.cs
- DatatypeImplementation.cs
- ContainerParaClient.cs
- ContextStack.cs
- UniqueConstraint.cs
- IisTraceWebEventProvider.cs
- IteratorDescriptor.cs
- DocumentGridContextMenu.cs
- Normalization.cs
- TypeRestriction.cs
- COM2ColorConverter.cs
- XmlNullResolver.cs
- PageBreakRecord.cs
- AccessedThroughPropertyAttribute.cs
- FloatSumAggregationOperator.cs
- CodeRemoveEventStatement.cs
- Button.cs
- ContractMapping.cs
- BitmapPalette.cs
- VisualTreeHelper.cs
- _NegoState.cs
- InternalConfigHost.cs
- DataTableNewRowEvent.cs
- OrderedDictionaryStateHelper.cs
- SerializationException.cs
- DataGridAddNewRow.cs
- CompilerParameters.cs
- HttpRequestMessageProperty.cs
- PeerNameRegistration.cs
- ResourceExpressionBuilder.cs
- XmlIlGenerator.cs
- TheQuery.cs
- FormParameter.cs
- SmiGettersStream.cs
- RepeatBehaviorConverter.cs
- ListSortDescription.cs
- HtmlWindow.cs
- XamlStream.cs
- _ListenerAsyncResult.cs
- SchemaInfo.cs
- oledbconnectionstring.cs
- DependencyPropertyDescriptor.cs
- RoutingEndpointTrait.cs
- StringValidatorAttribute.cs
- CodeGenerationManager.cs
- ApplicationActivator.cs
- CodeComment.cs
- ElementHost.cs
- TreeViewAutomationPeer.cs
- FileReader.cs
- ToolboxBitmapAttribute.cs
- PropertyHelper.cs
- AttributeUsageAttribute.cs
- DataMisalignedException.cs
- SymbolUsageManager.cs
- RelationshipWrapper.cs
- ValueTable.cs
- PrintDialog.cs
- SqlAggregateChecker.cs
- MetadataItemEmitter.cs
- CannotUnloadAppDomainException.cs
- DataGridViewCellCollection.cs
- ControlIdConverter.cs
- ContextProperty.cs
- PropVariant.cs
- ExpressionPrefixAttribute.cs
- PolicyManager.cs
- ComponentCollection.cs
- glyphs.cs
- WindowsStatusBar.cs
- ProfilePropertySettings.cs
- DataGridViewComboBoxCell.cs
- RegistrySecurity.cs
- DiagnosticTrace.cs
- BinaryFormatterWriter.cs
- DataGrid.cs
- nulltextcontainer.cs
- ExceptionHelpers.cs
- ConnectionManagementSection.cs
- AutomationProperties.cs
- MultiPageTextView.cs
- ContractMapping.cs
- StorageMappingItemLoader.cs