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
- EntityContainer.cs
- SmiXetterAccessMap.cs
- TextSchema.cs
- NamedPipeChannelListener.cs
- WebPartConnectionsCancelEventArgs.cs
- FontFamilyIdentifier.cs
- TargetParameterCountException.cs
- ModulesEntry.cs
- ListViewItem.cs
- BaseCollection.cs
- RayMeshGeometry3DHitTestResult.cs
- Item.cs
- EventQueueState.cs
- SBCSCodePageEncoding.cs
- DesigntimeLicenseContext.cs
- FrameworkTemplate.cs
- TaskResultSetter.cs
- CellParaClient.cs
- followingquery.cs
- ExtendedProperty.cs
- processwaithandle.cs
- RectKeyFrameCollection.cs
- SecureStringHasher.cs
- DesignerRegionCollection.cs
- IListConverters.cs
- RuleProcessor.cs
- BoundField.cs
- InternalSafeNativeMethods.cs
- WithParamAction.cs
- StandardCommandToolStripMenuItem.cs
- ExpressionBuilderContext.cs
- XmlUrlResolver.cs
- RelationshipEnd.cs
- SkinBuilder.cs
- DataViewSetting.cs
- ExistsInCollection.cs
- OleDbStruct.cs
- QueryPageSettingsEventArgs.cs
- XmlSchemaExternal.cs
- ServiceOperationWrapper.cs
- CapiHashAlgorithm.cs
- DefinitionBase.cs
- LinqDataSourceContextEventArgs.cs
- WindowsNonControl.cs
- TreeNodeBindingCollection.cs
- GenericTypeParameterBuilder.cs
- FilterUserControlBase.cs
- Input.cs
- NumberFunctions.cs
- WrapPanel.cs
- HwndSourceKeyboardInputSite.cs
- TextElementAutomationPeer.cs
- WinFormsComponentEditor.cs
- Event.cs
- BufferModesCollection.cs
- httpapplicationstate.cs
- XmlSchemaComplexType.cs
- CollectionCodeDomSerializer.cs
- validation.cs
- FullTextState.cs
- ContainerVisual.cs
- IncrementalHitTester.cs
- HttpHostedTransportConfiguration.cs
- MenuRendererStandards.cs
- Pair.cs
- StringUtil.cs
- SerializationAttributes.cs
- ToolboxItemLoader.cs
- ProfilePropertySettings.cs
- ISAPIWorkerRequest.cs
- SQLBoolean.cs
- SpecialNameAttribute.cs
- SectionInformation.cs
- Version.cs
- Comparer.cs
- SharedDp.cs
- TemplateInstanceAttribute.cs
- RawStylusInputCustomData.cs
- Point3DConverter.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- Range.cs
- ApplicationManager.cs
- AnimationTimeline.cs
- ImageConverter.cs
- DeleteMemberBinder.cs
- ProxyWebPartManager.cs
- XmlNodeList.cs
- ValueSerializer.cs
- ObjectManager.cs
- SafeRegistryHandle.cs
- BindValidationContext.cs
- TreeNodeEventArgs.cs
- SID.cs
- GetIndexBinder.cs
- JumpTask.cs
- AttributeAction.cs
- ImagingCache.cs
- PresentationAppDomainManager.cs
- WindowsFont.cs
- XmlHierarchicalDataSourceView.cs