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
- ProfilePropertyNameValidator.cs
- ProcessStartInfo.cs
- MsmqIntegrationMessageProperty.cs
- DataGridViewLinkColumn.cs
- ControlParameter.cs
- BaseTemplatedMobileComponentEditor.cs
- WeakReferenceList.cs
- XmlSchemaInclude.cs
- TextDocumentView.cs
- SymmetricAlgorithm.cs
- InputQueueChannelAcceptor.cs
- PerfCounterSection.cs
- ExceptionAggregator.cs
- DataGridColumnCollection.cs
- NameValueFileSectionHandler.cs
- TreeView.cs
- ObfuscationAttribute.cs
- SymLanguageType.cs
- WindowsProgressbar.cs
- SizeKeyFrameCollection.cs
- SvcFileManager.cs
- LockedAssemblyCache.cs
- XsltSettings.cs
- PropertyStore.cs
- QueryableDataSourceView.cs
- ClientClassGenerator.cs
- UpdateTracker.cs
- DuplicateDetector.cs
- RecordManager.cs
- Light.cs
- DurableMessageDispatchInspector.cs
- CodeGenHelper.cs
- OverlappedContext.cs
- DirectoryNotFoundException.cs
- PageCodeDomTreeGenerator.cs
- CellPartitioner.cs
- SystemDiagnosticsSection.cs
- PropertyGrid.cs
- RegexEditorDialog.cs
- DivideByZeroException.cs
- TempFiles.cs
- ApplicationFileParser.cs
- DateTimeConstantAttribute.cs
- SamlAssertionKeyIdentifierClause.cs
- XmlSchemaChoice.cs
- Model3DGroup.cs
- ToolStripDropDownClosedEventArgs.cs
- StringComparer.cs
- DesignerProperties.cs
- ElementHostPropertyMap.cs
- FontSource.cs
- HtmlInputCheckBox.cs
- RectValueSerializer.cs
- RemoteWebConfigurationHostServer.cs
- SiblingIterators.cs
- MediaPlayerState.cs
- AuthenticationConfig.cs
- HttpPostServerProtocol.cs
- WmlListAdapter.cs
- Panel.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- CustomSignedXml.cs
- XPathNodeHelper.cs
- ListControlConvertEventArgs.cs
- XPathScanner.cs
- ToolBarButton.cs
- ObjectCloneHelper.cs
- MultidimensionalArrayItemReference.cs
- BufferAllocator.cs
- Int32RectValueSerializer.cs
- ScriptControlDescriptor.cs
- DataSourceSelectArguments.cs
- ChildTable.cs
- RestHandlerFactory.cs
- Quad.cs
- OracleTransaction.cs
- WaitingCursor.cs
- ExpressionWriter.cs
- ProfileParameter.cs
- TextTrailingCharacterEllipsis.cs
- SqlBulkCopyColumnMappingCollection.cs
- BindingMemberInfo.cs
- AutoResetEvent.cs
- DataSourceView.cs
- OneWayBindingElementImporter.cs
- WindowsProgressbar.cs
- Hex.cs
- ParagraphVisual.cs
- ClientTargetSection.cs
- ClickablePoint.cs
- ControlPager.cs
- SqlTypeSystemProvider.cs
- XmlEntity.cs
- CompilationSection.cs
- SharedTcpTransportManager.cs
- ScalarType.cs
- ContentValidator.cs
- Activator.cs
- ProgressPage.cs
- IntSecurity.cs