Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / ResourceReferenceExpressionConverter.cs / 1 / ResourceReferenceExpressionConverter.cs
//---------------------------------------------------------------------------- // // File: ResourceReferenceExpressionConverter.cs // // Description: // TypeConverter for a resource value expression // // Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Windows; namespace System.Windows.Markup { ////// TypeConverter for a resource value expression /// public class ResourceReferenceExpressionConverter : ExpressionConverter { ////// TypeConverter method override. /// /// /// ITypeDescriptorContext /// /// /// Type to convert from /// ////// true if conversion is possible /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return base.CanConvertFrom(context, sourceType); } ////// TypeConverter method override. /// ////// For avalon serialization this converter /// returns true for string types only if the /// target element with the resource /// dictionary for the current resource /// reference is also being serialized. Else /// it returns false and the serialization /// engine must serialize the evaluated /// value of the expression. /// /// /// ITypeDescriptorContext /// /// /// Type to convert to /// ////// true if conversion is possible /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { // Validate Input Arguments if (destinationType == null) { throw new ArgumentNullException("destinationType"); } //MarkupExtention if (destinationType == typeof(MarkupExtension)) return true; return base.CanConvertTo(context, destinationType); } ////// TypeConverter method implementation. /// /// /// ITypeDescriptorContext /// /// /// current culture (see CLR specs) /// /// /// value to convert from /// ////// value that is result of conversion /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return base.ConvertFrom(context, culture, value); } ////// TypeConverter method implementation. /// /// /// ITypeDescriptorContext /// /// /// current culture (see CLR specs) /// /// /// value to convert from /// /// /// Type to convert to /// ////// converted value /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { // Validate Input Arguments ResourceReferenceExpression expr = value as ResourceReferenceExpression; if (expr == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "ResourceReferenceExpression")); } if (destinationType == null) { throw new ArgumentNullException("destinationType"); } // MarkupExtension if (destinationType == typeof(MarkupExtension)) { return new DynamicResourceExtension(expr.ResourceKey); } return base.ConvertTo(context, culture, value, destinationType); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: ResourceReferenceExpressionConverter.cs // // Description: // TypeConverter for a resource value expression // // Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Diagnostics; using System.Windows; namespace System.Windows.Markup { ////// TypeConverter for a resource value expression /// public class ResourceReferenceExpressionConverter : ExpressionConverter { ////// TypeConverter method override. /// /// /// ITypeDescriptorContext /// /// /// Type to convert from /// ////// true if conversion is possible /// public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return base.CanConvertFrom(context, sourceType); } ////// TypeConverter method override. /// ////// For avalon serialization this converter /// returns true for string types only if the /// target element with the resource /// dictionary for the current resource /// reference is also being serialized. Else /// it returns false and the serialization /// engine must serialize the evaluated /// value of the expression. /// /// /// ITypeDescriptorContext /// /// /// Type to convert to /// ////// true if conversion is possible /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { // Validate Input Arguments if (destinationType == null) { throw new ArgumentNullException("destinationType"); } //MarkupExtention if (destinationType == typeof(MarkupExtension)) return true; return base.CanConvertTo(context, destinationType); } ////// TypeConverter method implementation. /// /// /// ITypeDescriptorContext /// /// /// current culture (see CLR specs) /// /// /// value to convert from /// ////// value that is result of conversion /// public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return base.ConvertFrom(context, culture, value); } ////// TypeConverter method implementation. /// /// /// ITypeDescriptorContext /// /// /// current culture (see CLR specs) /// /// /// value to convert from /// /// /// Type to convert to /// ////// converted value /// public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { // Validate Input Arguments ResourceReferenceExpression expr = value as ResourceReferenceExpression; if (expr == null) { throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "ResourceReferenceExpression")); } if (destinationType == null) { throw new ArgumentNullException("destinationType"); } // MarkupExtension if (destinationType == typeof(MarkupExtension)) { return new DynamicResourceExtension(expr.ResourceKey); } return base.ConvertTo(context, culture, value, destinationType); } } } // 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
- MenuBase.cs
- OutgoingWebResponseContext.cs
- CharUnicodeInfo.cs
- UserPreferenceChangedEventArgs.cs
- CodeTypeReferenceCollection.cs
- AsyncContentLoadedEventArgs.cs
- SendMailErrorEventArgs.cs
- TabControlDesigner.cs
- Single.cs
- InputBuffer.cs
- InstalledFontCollection.cs
- ParameterCollection.cs
- WebEventTraceProvider.cs
- ThreadExceptionDialog.cs
- TransformerConfigurationWizardBase.cs
- CompilerTypeWithParams.cs
- ConfigXmlSignificantWhitespace.cs
- ItemCheckEvent.cs
- SubtreeProcessor.cs
- ServiceHostFactory.cs
- RepeatBehaviorConverter.cs
- TextChangedEventArgs.cs
- DiscoveryClientChannelBase.cs
- BindingWorker.cs
- SchemaTypeEmitter.cs
- ReversePositionQuery.cs
- GlyphManager.cs
- ObjectSet.cs
- WebBrowserUriTypeConverter.cs
- ProgressPage.cs
- FilterException.cs
- SQLSingle.cs
- ELinqQueryState.cs
- PrintDocument.cs
- HashSetDebugView.cs
- hresults.cs
- OdbcDataReader.cs
- ImageIndexEditor.cs
- SystemBrushes.cs
- CriticalHandle.cs
- TimeEnumHelper.cs
- ModuleBuilder.cs
- basecomparevalidator.cs
- SelectionRange.cs
- FontDifferentiator.cs
- CompressStream.cs
- KeyValueConfigurationElement.cs
- XamlInt32CollectionSerializer.cs
- SkipStoryboardToFill.cs
- RowTypePropertyElement.cs
- XmlAttributeProperties.cs
- QuaternionRotation3D.cs
- TriggerAction.cs
- SoundPlayer.cs
- Typography.cs
- SqlInternalConnectionTds.cs
- ScrollableControlDesigner.cs
- Fonts.cs
- SmtpReplyReaderFactory.cs
- RoutingEndpointTrait.cs
- DetailsViewModeEventArgs.cs
- NativeMethodsCLR.cs
- ProfilePropertyNameValidator.cs
- QueryActivatableWorkflowsCommand.cs
- PointAnimationUsingKeyFrames.cs
- DisplayMemberTemplateSelector.cs
- EtwTrace.cs
- SerializationFieldInfo.cs
- SecurityUtils.cs
- DelegateBodyWriter.cs
- NotifyInputEventArgs.cs
- Soap11ServerProtocol.cs
- StylusPointPropertyInfo.cs
- querybuilder.cs
- LinearGradientBrush.cs
- CompilationRelaxations.cs
- SafePEFileHandle.cs
- TdsParserStateObject.cs
- HMACRIPEMD160.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- ExtenderProviderService.cs
- ForceCopyBuildProvider.cs
- HashSetDebugView.cs
- ExpandableObjectConverter.cs
- ByteStack.cs
- OdbcConnectionFactory.cs
- shaperfactoryquerycacheentry.cs
- BindingWorker.cs
- Marshal.cs
- HtmlInputRadioButton.cs
- BamlCollectionHolder.cs
- Buffer.cs
- Padding.cs
- SchemaEntity.cs
- XPathParser.cs
- FunctionUpdateCommand.cs
- CodeTypeDelegate.cs
- BitmapVisualManager.cs
- SqlProfileProvider.cs
- RolePrincipal.cs