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
- RsaSecurityKey.cs
- SizeAnimationUsingKeyFrames.cs
- DefaultBinder.cs
- CodeExpressionRuleDeclaration.cs
- ListViewDeleteEventArgs.cs
- BasicExpressionVisitor.cs
- SocketInformation.cs
- PointF.cs
- DetailsViewCommandEventArgs.cs
- ConnectionManagementElement.cs
- __TransparentProxy.cs
- ImageIndexConverter.cs
- WindowsTokenRoleProvider.cs
- LoginCancelEventArgs.cs
- StorageAssociationSetMapping.cs
- InternalEnumValidatorAttribute.cs
- BitmapEffectrendercontext.cs
- ColumnMapCopier.cs
- PngBitmapDecoder.cs
- VariableDesigner.xaml.cs
- RelationshipType.cs
- CompilationSection.cs
- CssStyleCollection.cs
- DataGridViewComboBoxColumn.cs
- ListViewItem.cs
- Gdiplus.cs
- MiniModule.cs
- ThreadStateException.cs
- SecureStringHasher.cs
- HttpModulesSection.cs
- FilteredAttributeCollection.cs
- ProviderCollection.cs
- ProtectedConfigurationSection.cs
- SocketAddress.cs
- precedingsibling.cs
- CriticalHandle.cs
- NativeMethods.cs
- QilTernary.cs
- XmlIgnoreAttribute.cs
- StrongBox.cs
- ProgressChangedEventArgs.cs
- Thickness.cs
- BinHexEncoder.cs
- ImageCodecInfo.cs
- ApplicationContext.cs
- SplineKeyFrames.cs
- EncodingTable.cs
- _CommandStream.cs
- SecurityPolicySection.cs
- LocatorManager.cs
- TypeUtils.cs
- ToolStripItemEventArgs.cs
- EntityProviderFactory.cs
- DBAsyncResult.cs
- WebPartCatalogAddVerb.cs
- TempEnvironment.cs
- OleCmdHelper.cs
- ExpressionPrinter.cs
- DragCompletedEventArgs.cs
- DefaultTraceListener.cs
- Container.cs
- SafeMILHandleMemoryPressure.cs
- DataGridViewCellCancelEventArgs.cs
- GenericXmlSecurityToken.cs
- CommandTreeTypeHelper.cs
- TranslateTransform3D.cs
- ComPersistableTypeElement.cs
- ConversionContext.cs
- InvalidDataException.cs
- EventHandlerList.cs
- NativeCompoundFileAPIs.cs
- TextEditorParagraphs.cs
- MasterPageCodeDomTreeGenerator.cs
- DataSet.cs
- DataQuery.cs
- PropertiesTab.cs
- QueryCursorEventArgs.cs
- CounterSampleCalculator.cs
- UriTemplateQueryValue.cs
- FtpWebResponse.cs
- ExitEventArgs.cs
- EntityDataSourceStatementEditor.cs
- ExpressionVisitor.cs
- StatusBar.cs
- DocumentSequenceHighlightLayer.cs
- ErrorHandlingReceiver.cs
- MessageBox.cs
- SingleObjectCollection.cs
- BaseCollection.cs
- Base64Decoder.cs
- FormsAuthentication.cs
- SoapAttributeAttribute.cs
- SafeCryptoHandles.cs
- RuntimeEnvironment.cs
- XPathBinder.cs
- HuffModule.cs
- Positioning.cs
- NotSupportedException.cs
- DebugView.cs
- ThrowHelper.cs