Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Base / System / Windows / UncommonField.cs / 1 / UncommonField.cs
using System; using System.Diagnostics; using System.Security.Permissions; using MS.Internal.WindowsBase; // for FriendAccessAllowed namespace System.Windows { ////// /// //CASRemoval:[StrongNameIdentityPermissionAttribute(SecurityAction.InheritanceDemand, PublicKey=Microsoft.Internal.BuildInfo.WCP_PUBLIC_KEY_STRING)] [FriendAccessAllowed] // Built into Base, used by Core and Framework internal class UncommonField{ /// /// Create a new UncommonField. /// public UncommonField() : this(default(T)) { } ////// Create a new UncommonField. /// /// The default value of the field. public UncommonField(T defaultValue) { _defaultValue = defaultValue; _hasBeenSet = false; lock (DependencyProperty.Synchronized) { _globalIndex = DependencyProperty.GetUniqueGlobalIndex(null, null); DependencyProperty.RegisteredPropertyList.Add(); } } ////// Write the given value onto a DependencyObject instance. /// /// The DependencyObject on which to set the value. /// The value to set. public void SetValue(DependencyObject instance, T value) { if (instance != null) { EntryIndex entryIndex = instance.LookupEntry(_globalIndex); // Set the value if it's not the default, otherwise remove the value. if (!object.ReferenceEquals(value, _defaultValue)) { instance.SetEffectiveValue(entryIndex, null /* dp */, _globalIndex, null /* metadata */, value, BaseValueSourceInternal.Local); _hasBeenSet = true; } else { instance.UnsetEffectiveValue(entryIndex, null /* dp */, null /* metadata */); } } else { throw new ArgumentNullException("instance"); } } ////// Read the value of this field on a DependencyObject instance. /// /// The DependencyObject from which to get the value. ///public T GetValue(DependencyObject instance) { if (instance != null) { if (_hasBeenSet) { EntryIndex entryIndex = instance.LookupEntry(_globalIndex); if (entryIndex.Found) { object value = instance.EffectiveValues[entryIndex.Index].LocalValue; if (value != DependencyProperty.UnsetValue) { return (T)value; } } return _defaultValue; } else { return _defaultValue; } } else { throw new ArgumentNullException("instance"); } } /// /// Clear this field from the given DependencyObject instance. /// /// public void ClearValue(DependencyObject instance) { if (instance != null) { EntryIndex entryIndex = instance.LookupEntry(_globalIndex); instance.UnsetEffectiveValue(entryIndex, null /* dp */, null /* metadata */); } else { throw new ArgumentNullException("instance"); } } #region Private Fields private T _defaultValue; private int _globalIndex; private bool _hasBeenSet; #endregion } } // 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
- ComponentCollection.cs
- FormViewUpdateEventArgs.cs
- HttpRequestMessageProperty.cs
- DataGridViewAccessibleObject.cs
- NullRuntimeConfig.cs
- XmlJsonReader.cs
- WebBrowserHelper.cs
- ThreadInterruptedException.cs
- ListQueryResults.cs
- StaticResourceExtension.cs
- DecoderReplacementFallback.cs
- Security.cs
- RelatedPropertyManager.cs
- X509Extension.cs
- MethodExpr.cs
- AQNBuilder.cs
- ObjectViewQueryResultData.cs
- CodeTryCatchFinallyStatement.cs
- SectionXmlInfo.cs
- loginstatus.cs
- dataobject.cs
- RadioButtonRenderer.cs
- PopOutPanel.cs
- ChangeProcessor.cs
- PersonalizationState.cs
- XmlResolver.cs
- HashJoinQueryOperatorEnumerator.cs
- ReleaseInstanceMode.cs
- DataServiceRequestException.cs
- MulticastOption.cs
- HierarchicalDataTemplate.cs
- VisualBrush.cs
- Globals.cs
- CodeTypeDeclarationCollection.cs
- NameValueConfigurationCollection.cs
- FileEnumerator.cs
- PrintDocument.cs
- Stack.cs
- IndexerNameAttribute.cs
- FixedSOMImage.cs
- CodeGenerator.cs
- SystemIPInterfaceProperties.cs
- Nodes.cs
- DataListCommandEventArgs.cs
- UnsafeNativeMethods.cs
- OutputWindow.cs
- Comparer.cs
- Page.cs
- HostedTransportConfigurationManager.cs
- DataGridRowDetailsEventArgs.cs
- Matrix3DValueSerializer.cs
- PixelFormat.cs
- NonBatchDirectoryCompiler.cs
- OpenTypeLayoutCache.cs
- SafeFileMappingHandle.cs
- Run.cs
- TimelineCollection.cs
- MatrixStack.cs
- XamlSerializerUtil.cs
- AVElementHelper.cs
- DocumentViewerBase.cs
- AttributeCollection.cs
- TypeToken.cs
- InputScope.cs
- IdentityModelDictionary.cs
- HybridDictionary.cs
- Axis.cs
- RotateTransform3D.cs
- safemediahandle.cs
- SendMailErrorEventArgs.cs
- KeyboardEventArgs.cs
- ResolveNameEventArgs.cs
- SHA512.cs
- DiagnosticStrings.cs
- PolicyManager.cs
- CustomErrorsSection.cs
- DbInsertCommandTree.cs
- TimeSpanSecondsConverter.cs
- NumericPagerField.cs
- ConfigurationValue.cs
- ListControlConvertEventArgs.cs
- UnsafeNativeMethods.cs
- TailCallAnalyzer.cs
- LOSFormatter.cs
- XmlSchemaSet.cs
- SafeNativeMethods.cs
- FlowDocument.cs
- TaiwanCalendar.cs
- ParserHooks.cs
- DoubleStorage.cs
- ConfigXmlComment.cs
- DependencyObjectProvider.cs
- SelfIssuedTokenFactoryCredential.cs
- InternalsVisibleToAttribute.cs
- AliasGenerator.cs
- TextTreeInsertUndoUnit.cs
- IdentifierElement.cs
- RecognizedWordUnit.cs
- HtmlInputText.cs
- VirtualizingStackPanel.cs