Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / localization.cs / 1 / localization.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Localization.Comments & Localization.Attributes attached properties // // History: // 12/4/2004: [....] Created the file // 3/11/2005: [....] rename Loc to Localization class // //--------------------------------------------------------------------------- using System.Collections; using System.Diagnostics; using MS.Internal.Globalization; namespace System.Windows { // // Note: the class name and property name must be kept in sync'ed with // Framework\MS\Internal\Globalization\LocalizationComments.cs file. // Compiler checks for them by literal string comparisons. // ////// Class defines attached properties for Comments and Localizability /// public static class Localization { ////// DependencyProperty for Comments property. /// public static readonly DependencyProperty CommentsProperty = DependencyProperty.RegisterAttached( "Comments", typeof(string), typeof(Localization) ); ////// DependencyProperty for Localizability property. /// public static readonly DependencyProperty AttributesProperty = DependencyProperty.RegisterAttached( "Attributes", typeof(string), typeof(Localization) ); ////// Reads the attached property Comments from given element. /// /// The element from which to read the attached property. ///The property's value. [AttachedPropertyBrowsableForType(typeof(object))] public static string GetComments(object element) { if (element == null) { throw new ArgumentNullException("element"); } return GetValue(element, CommentsProperty); } ////// Writes the attached property Comments to the given element. /// /// The element to which to write the attached property. /// The property value to set public static void SetComments(object element, string comments) { if (element == null) { throw new ArgumentNullException("element"); } LocComments.ParsePropertyComments(comments); SetValue(element, CommentsProperty, comments); } ////// Reads the attached property Localizability from given element. /// /// The element from which to read the attached property. ///The property's value. [AttachedPropertyBrowsableForType(typeof(object))] public static string GetAttributes(object element) { if (element == null) { throw new ArgumentNullException("element"); } return GetValue(element, AttributesProperty); } ////// Writes the attached property Localizability to the given element. /// /// The element to which to write the attached property. /// The property value to set public static void SetAttributes(object element, string attributes) { if (element == null) { throw new ArgumentNullException("element"); } LocComments.ParsePropertyLocalizabilityAttributes(attributes); SetValue(element, AttributesProperty, attributes); } private static string GetValue(object element, DependencyProperty property) { DependencyObject dependencyObject = element as DependencyObject; if (dependencyObject != null) { // For DO, get the value from the property system return (string) dependencyObject.GetValue(property); } // For objects, get the value from our own hashtable if (property == CommentsProperty) { lock(_commentsOnObjects.SyncRoot) { return (string) _commentsOnObjects[element]; } } else { Debug.Assert(property == AttributesProperty); lock(_attributesOnObjects.SyncRoot) { return (string) _attributesOnObjects[element]; } } } private static void SetValue(object element, DependencyProperty property, string value) { DependencyObject dependencyObject = element as DependencyObject; if (dependencyObject != null) { // For DO, store the value in the property system dependencyObject.SetValue(property, value); return; } // For other objects, store the value in our own hashtable if (property == CommentsProperty) { lock(_commentsOnObjects.SyncRoot) { _commentsOnObjects[element] = value; } } else { Debug.Assert(property == AttributesProperty); lock(_attributesOnObjects.SyncRoot) { _attributesOnObjects[element] = value; } } } /// /// private storage for values set on objects /// private static Hashtable _commentsOnObjects = new Hashtable(); private static Hashtable _attributesOnObjects = new Hashtable(); } } // 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
- Funcletizer.cs
- ByteRangeDownloader.cs
- ObjectAnimationBase.cs
- TextBoxBase.cs
- ImageListImageEditor.cs
- TaiwanCalendar.cs
- GlyphCache.cs
- TraceFilter.cs
- CommunicationObjectAbortedException.cs
- Queue.cs
- UnsafeNativeMethods.cs
- StringInfo.cs
- EventSinkHelperWriter.cs
- VerticalAlignConverter.cs
- BitmapPalette.cs
- CultureTable.cs
- ResetableIterator.cs
- TextElementEnumerator.cs
- KeyPressEvent.cs
- AdRotator.cs
- TouchEventArgs.cs
- ErrorLog.cs
- CompoundFileStreamReference.cs
- TraceLevelStore.cs
- InputLangChangeRequestEvent.cs
- WebSysDescriptionAttribute.cs
- ISAPIRuntime.cs
- SecurityTokenException.cs
- EndpointFilterProvider.cs
- DataRow.cs
- Operand.cs
- ObjectIDGenerator.cs
- ObjectDataSourceEventArgs.cs
- BitSet.cs
- _NegoState.cs
- Internal.cs
- OleDbRowUpdatingEvent.cs
- AppDomainFactory.cs
- OLEDB_Util.cs
- SafeArchiveContext.cs
- ThreadPool.cs
- XmlILIndex.cs
- TemplateKey.cs
- JavaScriptObjectDeserializer.cs
- ObjectKeyFrameCollection.cs
- ContentValidator.cs
- PropertyCondition.cs
- XmlTypeMapping.cs
- DrawListViewColumnHeaderEventArgs.cs
- PanningMessageFilter.cs
- SqlUtil.cs
- SchemaTypeEmitter.cs
- DataGridViewRowPostPaintEventArgs.cs
- regiisutil.cs
- FixedTextBuilder.cs
- ArrayEditor.cs
- FileDataSource.cs
- MultipleViewPattern.cs
- HighlightComponent.cs
- NullToBooleanConverter.cs
- ArraySubsetEnumerator.cs
- DetailsViewCommandEventArgs.cs
- Pair.cs
- MemberHolder.cs
- CollectionType.cs
- formatter.cs
- Crypto.cs
- LogicalChannel.cs
- SpellerError.cs
- XmlFormatExtensionAttribute.cs
- EndOfStreamException.cs
- MenuItemBinding.cs
- DataObjectEventArgs.cs
- NetworkCredential.cs
- XmlTextAttribute.cs
- ThreadAttributes.cs
- VirtualPathUtility.cs
- ThicknessConverter.cs
- SessionStateContainer.cs
- ExecutionEngineException.cs
- Panel.cs
- _Rfc2616CacheValidators.cs
- XmlAggregates.cs
- AttachmentCollection.cs
- UndirectedGraph.cs
- MetadataProperty.cs
- AmbientProperties.cs
- TextEditorParagraphs.cs
- DataGridViewHeaderCell.cs
- DirtyTextRange.cs
- DesignerEditorPartChrome.cs
- TraceListener.cs
- Msec.cs
- CornerRadiusConverter.cs
- FieldToken.cs
- CheckPair.cs
- UnmanagedMemoryStreamWrapper.cs
- SchemaNotation.cs
- StateDesigner.Layouts.cs
- TypeInformation.cs