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
- SchemaTypeEmitter.cs
- ValidationError.cs
- ConfigurationPermission.cs
- DataTemplate.cs
- Vector.cs
- Point3DValueSerializer.cs
- SerializationInfo.cs
- SQLDoubleStorage.cs
- SmtpNegotiateAuthenticationModule.cs
- DataGridParentRows.cs
- EdmItemCollection.OcAssemblyCache.cs
- RegexRunnerFactory.cs
- WindowsSysHeader.cs
- StrictModeSecurityHeaderElementInferenceEngine.cs
- ProgressBar.cs
- UnsafeNativeMethodsCLR.cs
- BinaryObjectInfo.cs
- ConfigurationErrorsException.cs
- SqlDataReader.cs
- ResourceReferenceExpressionConverter.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- BigInt.cs
- TrustLevel.cs
- XmlWriter.cs
- SemanticResultValue.cs
- FileFormatException.cs
- XmlCompatibilityReader.cs
- AnyReturnReader.cs
- DomNameTable.cs
- ToolStripControlHost.cs
- RefExpr.cs
- TemplateBaseAction.cs
- AnnotationService.cs
- UniformGrid.cs
- RemotingSurrogateSelector.cs
- DnsPermission.cs
- SQLDouble.cs
- StatusStrip.cs
- WindowsPrincipal.cs
- SetterBase.cs
- SpotLight.cs
- SmiContextFactory.cs
- Schema.cs
- DotExpr.cs
- ECDiffieHellmanPublicKey.cs
- HttpModule.cs
- SqlRemoveConstantOrderBy.cs
- TileModeValidation.cs
- MemberMaps.cs
- WaitHandle.cs
- SchemaImporterExtensionElementCollection.cs
- ObjectStateFormatter.cs
- UriGenerator.cs
- RegisterInfo.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- HandlerMappingMemo.cs
- BufferModesCollection.cs
- LabelEditEvent.cs
- DecimalConstantAttribute.cs
- TextSelection.cs
- HwndKeyboardInputProvider.cs
- MLangCodePageEncoding.cs
- LicenseException.cs
- Duration.cs
- BoolExpressionVisitors.cs
- Base64Stream.cs
- Utils.cs
- ExpressionLexer.cs
- LinqMaximalSubtreeNominator.cs
- ClickablePoint.cs
- DynamicDocumentPaginator.cs
- ComponentManagerBroker.cs
- bidPrivateBase.cs
- Stackframe.cs
- DllHostInitializer.cs
- BrowserCapabilitiesCodeGenerator.cs
- ContractMethodParameterInfo.cs
- XpsFilter.cs
- TransactionScopeDesigner.cs
- FixedSOMLineCollection.cs
- PersonalizationStateInfo.cs
- InstanceContextMode.cs
- StandardMenuStripVerb.cs
- _LocalDataStore.cs
- MenuEventArgs.cs
- LogRecordSequence.cs
- CheckBoxStandardAdapter.cs
- MSAANativeProvider.cs
- PingReply.cs
- UInt32Storage.cs
- Form.cs
- MimeBasePart.cs
- ToolboxControl.cs
- WebServiceAttribute.cs
- XmlDataCollection.cs
- FileSystemInfo.cs
- XmlTextAttribute.cs
- SchemaNamespaceManager.cs
- EntityClassGenerator.cs
- Help.cs