Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / 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: Garyyang Created the file // 3/11/2005: garyyang 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 [....]'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. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Localization.Comments & Localization.Attributes attached properties // // History: // 12/4/2004: Garyyang Created the file // 3/11/2005: garyyang 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 [....]'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
- PassportAuthenticationModule.cs
- AnnotationAuthorChangedEventArgs.cs
- EventMetadata.cs
- DataGridViewRow.cs
- SettingsBindableAttribute.cs
- WebBrowserContainer.cs
- NetSectionGroup.cs
- PathGeometry.cs
- Item.cs
- CompleteWizardStep.cs
- LocationUpdates.cs
- Oid.cs
- ToolBarButton.cs
- ZipIORawDataFileBlock.cs
- _ConnectOverlappedAsyncResult.cs
- RtfControlWordInfo.cs
- ToolBarButtonClickEvent.cs
- ExpressionConverter.cs
- NavigationProperty.cs
- XmlLanguage.cs
- WebPartMinimizeVerb.cs
- ConditionBrowserDialog.cs
- SecurityDescriptor.cs
- StateChangeEvent.cs
- DeviceSpecificDialogCachedState.cs
- ExpressionBuilder.cs
- GridPattern.cs
- WindowsPrincipal.cs
- BackgroundWorker.cs
- FileResponseElement.cs
- CacheEntry.cs
- DbConnectionPoolGroupProviderInfo.cs
- SpotLight.cs
- DataKeyCollection.cs
- ConfigurationManager.cs
- IRCollection.cs
- DbMetaDataColumnNames.cs
- HuffModule.cs
- FrameworkElementFactoryMarkupObject.cs
- RoutedEventArgs.cs
- ExpressionCopier.cs
- OAVariantLib.cs
- ObjectRef.cs
- TransactionManager.cs
- SessionStateContainer.cs
- CompensationHandlingFilter.cs
- odbcmetadatafactory.cs
- SelectedDatesCollection.cs
- TrustManager.cs
- Win32KeyboardDevice.cs
- HttpChannelBindingToken.cs
- ADConnectionHelper.cs
- TransactedBatchingElement.cs
- ToolStripDropDownClosedEventArgs.cs
- ObjectStateManager.cs
- XmlNamedNodeMap.cs
- HostExecutionContextManager.cs
- FileDataSourceCache.cs
- ScriptControlManager.cs
- DataGridViewCellStyleBuilderDialog.cs
- HwndTarget.cs
- MILUtilities.cs
- BitmapEffectvisualstate.cs
- RoleServiceManager.cs
- ListItemParagraph.cs
- ReceiveCompletedEventArgs.cs
- PropertyNames.cs
- ModuleBuilderData.cs
- OleDbSchemaGuid.cs
- Site.cs
- FolderBrowserDialog.cs
- UpdatePanelControlTrigger.cs
- CodeGenerator.cs
- ProcessModuleCollection.cs
- RealizationDrawingContextWalker.cs
- RealizationContext.cs
- DataGridPageChangedEventArgs.cs
- AxHost.cs
- CollectionDataContract.cs
- Random.cs
- SupportingTokenProviderSpecification.cs
- SymDocumentType.cs
- XmlMapping.cs
- DataGridViewLinkCell.cs
- ImageMap.cs
- SiteMapNodeItemEventArgs.cs
- KoreanLunisolarCalendar.cs
- CommonXSendMessage.cs
- BypassElement.cs
- SizeAnimationUsingKeyFrames.cs
- WebPartPersonalization.cs
- DeclarativeCatalogPartDesigner.cs
- MetadataException.cs
- AppSettingsReader.cs
- ToolStripItem.cs
- SignedInfo.cs
- GridViewItemAutomationPeer.cs
- WebPartUserCapability.cs
- SingleConverter.cs
- SafeCryptoHandles.cs