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
- ScriptResourceHandler.cs
- DataContext.cs
- CaseInsensitiveOrdinalStringComparer.cs
- MetadataItem_Static.cs
- FocusChangedEventArgs.cs
- RunInstallerAttribute.cs
- CodeTypeReferenceExpression.cs
- AxHost.cs
- CustomLineCap.cs
- CodeRemoveEventStatement.cs
- TextBoxDesigner.cs
- DesignerToolStripControlHost.cs
- RoleService.cs
- TreeNode.cs
- Variant.cs
- VBIdentifierDesigner.xaml.cs
- Misc.cs
- SessionSwitchEventArgs.cs
- AssociationType.cs
- xmlglyphRunInfo.cs
- Configuration.cs
- GetPageCompletedEventArgs.cs
- XmlElementAttributes.cs
- DelayedRegex.cs
- DataService.cs
- DataRecordObjectView.cs
- HierarchicalDataBoundControlAdapter.cs
- MarshalByRefObject.cs
- TypedRowHandler.cs
- RangeValidator.cs
- ColumnHeader.cs
- HtmlProps.cs
- SafeReadContext.cs
- ConfigXmlSignificantWhitespace.cs
- DbProviderFactory.cs
- SmiContext.cs
- AttachedPropertyBrowsableAttribute.cs
- ObjectDisposedException.cs
- Utils.cs
- Error.cs
- LazyTextWriterCreator.cs
- TemplateParser.cs
- TrackingMemoryStreamFactory.cs
- EntityStoreSchemaFilterEntry.cs
- Panel.cs
- AssemblyCollection.cs
- DbException.cs
- DetailsViewUpdateEventArgs.cs
- Properties.cs
- ExtenderControl.cs
- DataTemplate.cs
- CharacterMetricsDictionary.cs
- Divide.cs
- DataQuery.cs
- dtdvalidator.cs
- TransformGroup.cs
- unsafenativemethodstextservices.cs
- ActivationServices.cs
- AddValidationError.cs
- DefaultBindingPropertyAttribute.cs
- Pen.cs
- SingleResultAttribute.cs
- SingletonChannelAcceptor.cs
- StyleHelper.cs
- Propagator.cs
- DataGridViewRowHeaderCell.cs
- RuntimeResourceSet.cs
- TrackingServices.cs
- ObjRef.cs
- DiffuseMaterial.cs
- Exception.cs
- Message.cs
- TrustManagerPromptUI.cs
- Profiler.cs
- ConfigXmlDocument.cs
- IndexerHelper.cs
- SafeRightsManagementSessionHandle.cs
- ErrorActivity.cs
- SqlProfileProvider.cs
- TrustLevel.cs
- ConnectionPoint.cs
- InvokeWebService.cs
- CustomSignedXml.cs
- AsyncContentLoadedEventArgs.cs
- SafeNativeMethodsOther.cs
- SchemaCreator.cs
- IPPacketInformation.cs
- AggregateNode.cs
- ScriptingRoleServiceSection.cs
- HtmlCommandAdapter.cs
- DataGridHeaderBorder.cs
- HtmlWindow.cs
- Quaternion.cs
- DataControlFieldCollection.cs
- Int16Animation.cs
- EditorPartCollection.cs
- ChameleonKey.cs
- ProfileServiceManager.cs
- PinProtectionHelper.cs
- Application.cs