Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Internal / FreezableOperations.cs / 1305600 / FreezableOperations.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: FreezableOperations class definition.
//
// History:
// 2005/02/02 : [....] - Created
//
//---------------------------------------------------------------------------
using System;
using System.Windows;
using MS.Internal.PresentationCore;
namespace MS.Internal
{
///
/// Internal static class which provides helper methods for common
/// Freezable operations.
///
[FriendAccessAllowed] // Built into Core, also used by Framework.
internal static class FreezableOperations
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
///
/// A null-safe wrapper around Freezable.Clone(). (If a null
/// is encountered it returns null.)
///
internal static Freezable Clone(Freezable freezable)
{
if (freezable == null)
{
return null;
}
return freezable.Clone();
}
///
/// Semantically equivilent to Freezable.Clone().Freeze() except that
/// GetAsFrozen avoids copying any portions of the Freezable graph
/// which are already frozen.
///
public static Freezable GetAsFrozen(Freezable freezable)
{
if (freezable == null)
{
return null;
}
return freezable.GetAsFrozen();
}
///
/// If freezable is already frozen, it returns freezable
/// If freezable is not frozen, it returns a copy that is frozen if possible
///
internal static Freezable GetAsFrozenIfPossible(Freezable freezable)
{
if (freezable == null)
{
return null;
}
if (freezable.CanFreeze)
{
freezable = freezable.GetAsFrozen();
}
return freezable;
}
///
/// Moves the specified changed handler from the old value
/// to the new value correctly no-oping nulls. This is useful
/// for non-Freezables which expose a Freezable property.
///
internal static void PropagateChangedHandlers(
Freezable oldValue,
Freezable newValue,
EventHandler changedHandler)
{
if (newValue != null && !newValue.IsFrozen)
{
newValue.Changed += changedHandler;
}
if (oldValue != null && !oldValue.IsFrozen)
{
oldValue.Changed -= changedHandler;
}
}
#endregion Internal Methods
}
}
// 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
- HandleScope.cs
- VerificationException.cs
- EmbeddedMailObject.cs
- NativeMethodsOther.cs
- HttpServerUtilityWrapper.cs
- Pkcs7Recipient.cs
- ToolStripSplitStackLayout.cs
- TableLayoutCellPaintEventArgs.cs
- ItemList.cs
- GridViewPageEventArgs.cs
- InternalEnumValidatorAttribute.cs
- Timer.cs
- Scene3D.cs
- ControlPropertyNameConverter.cs
- AlgoModule.cs
- CountdownEvent.cs
- ServicePoint.cs
- NumberSubstitution.cs
- CompressEmulationStream.cs
- SmtpException.cs
- DesignSurface.cs
- StylusPoint.cs
- XmlAtomicValue.cs
- Rotation3D.cs
- InvokeHandlers.cs
- DocumentPageView.cs
- QueryCorrelationInitializer.cs
- RightsManagementEncryptionTransform.cs
- DbParameterCollectionHelper.cs
- DefaultTextStoreTextComposition.cs
- EmptyStringExpandableObjectConverter.cs
- EventSourceCreationData.cs
- SqlCachedBuffer.cs
- TextBoxRenderer.cs
- BrowserTree.cs
- MaskedTextBoxDesigner.cs
- SoapAttributeAttribute.cs
- returneventsaver.cs
- LassoSelectionBehavior.cs
- CustomTypeDescriptor.cs
- XmlSchemaProviderAttribute.cs
- XmlElementAttributes.cs
- ApplicationSettingsBase.cs
- TemplateBamlTreeBuilder.cs
- BindingParameterCollection.cs
- LambdaCompiler.Expressions.cs
- Reference.cs
- ParserHooks.cs
- OraclePermission.cs
- SqlIdentifier.cs
- SortDescriptionCollection.cs
- TextEditorContextMenu.cs
- DurableEnlistmentState.cs
- XPathScanner.cs
- MetadataPropertyAttribute.cs
- ValidateNames.cs
- ReversePositionQuery.cs
- MulticastOption.cs
- SessionStateModule.cs
- Switch.cs
- ExtensionWindowResizeGrip.cs
- CheckBoxBaseAdapter.cs
- ProcessManager.cs
- XmlSerializerFormatAttribute.cs
- AssemblyFilter.cs
- SafeUserTokenHandle.cs
- DebuggerAttributes.cs
- SystemException.cs
- Soap12ServerProtocol.cs
- WinEventHandler.cs
- XmlLinkedNode.cs
- SendKeys.cs
- EditCommandColumn.cs
- ExcCanonicalXml.cs
- XPathSingletonIterator.cs
- ResourceReferenceExpression.cs
- Native.cs
- CheckoutException.cs
- GetPageCompletedEventArgs.cs
- cookiecollection.cs
- TextChangedEventArgs.cs
- SqlExpressionNullability.cs
- GridPattern.cs
- ZipIOBlockManager.cs
- WebPartTransformer.cs
- PrimarySelectionGlyph.cs
- Help.cs
- ExpandableObjectConverter.cs
- InvalidCommandTreeException.cs
- SqlXml.cs
- DragEventArgs.cs
- StandardBindingImporter.cs
- ObjectQuery_EntitySqlExtensions.cs
- DesignerActionHeaderItem.cs
- SpotLight.cs
- ConnectivityStatus.cs
- HttpsTransportBindingElement.cs
- ThreadAttributes.cs
- ToggleButton.cs
- XmlUnspecifiedAttribute.cs