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
- ButtonBaseAutomationPeer.cs
- DataGridViewMethods.cs
- ChangeInterceptorAttribute.cs
- Pts.cs
- PropertyTab.cs
- RuleEngine.cs
- PackageDigitalSignature.cs
- EntityDataSourceContextDisposingEventArgs.cs
- RowBinding.cs
- XamlParser.cs
- TracingConnectionInitiator.cs
- TransactionState.cs
- DataPagerFieldCollection.cs
- Exceptions.cs
- XmlNotation.cs
- PingOptions.cs
- HashHelper.cs
- ExecutedRoutedEventArgs.cs
- ProfileProvider.cs
- FreezableCollection.cs
- PageCache.cs
- ScrollEvent.cs
- PeerObject.cs
- DoubleStorage.cs
- WsrmMessageInfo.cs
- SecurityPolicySection.cs
- HostSecurityManager.cs
- IPEndPoint.cs
- WebAdminConfigurationHelper.cs
- UnsafeNativeMethods.cs
- WindowsPen.cs
- DataObjectFieldAttribute.cs
- MouseActionValueSerializer.cs
- RuntimeComponentFilter.cs
- ActiveXContainer.cs
- ContentHostHelper.cs
- FormViewInsertedEventArgs.cs
- XPathParser.cs
- _Semaphore.cs
- BitmapSource.cs
- ParameterCollectionEditor.cs
- MimeMapping.cs
- MsmqSecureHashAlgorithm.cs
- CacheHelper.cs
- ConnectionStringsExpressionBuilder.cs
- SqlUdtInfo.cs
- CellParaClient.cs
- RightsManagementResourceHelper.cs
- Stroke.cs
- MemberDomainMap.cs
- NativeMethods.cs
- Animatable.cs
- BindingContext.cs
- ListViewGroupConverter.cs
- DictionaryManager.cs
- PackageFilter.cs
- TextParagraphCache.cs
- NativeObjectSecurity.cs
- MouseGestureValueSerializer.cs
- ColorAnimation.cs
- XhtmlCssHandler.cs
- CqlParser.cs
- SoundPlayerAction.cs
- CompilerErrorCollection.cs
- ActivationServices.cs
- StrongNameUtility.cs
- thaishape.cs
- ProcessModelSection.cs
- TableProviderWrapper.cs
- RegionData.cs
- OdbcInfoMessageEvent.cs
- cryptoapiTransform.cs
- InvokeWebService.cs
- QuaternionRotation3D.cs
- AlternateViewCollection.cs
- Mutex.cs
- DataServiceProviderMethods.cs
- XmlKeywords.cs
- FormatterConverter.cs
- InternalCache.cs
- Internal.cs
- FacetChecker.cs
- SemaphoreSlim.cs
- Query.cs
- ProfileGroupSettings.cs
- PipelineModuleStepContainer.cs
- IntSecurity.cs
- ObjectPersistData.cs
- ADConnectionHelper.cs
- RowToParametersTransformer.cs
- SafeProcessHandle.cs
- BaseCodePageEncoding.cs
- COM2TypeInfoProcessor.cs
- DataColumnMappingCollection.cs
- ListBox.cs
- DesignBinding.cs
- UpDownEvent.cs
- WebDisplayNameAttribute.cs
- ListControlBuilder.cs
- MLangCodePageEncoding.cs