Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DynamicResourceExtensionConverter.cs / 1305600 / DynamicResourceExtensionConverter.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: ElementItem.cs // // Contents: Implements a converter to an instance descriptor for // DynamicResourceExtension // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Security; using System.Text; namespace System.Windows { ////// Type converter to inform the serialization system how to construct a DynamicResourceExtension from /// an instance. It reports that ResourceKey should be used as the first parameter to the constructor. /// public class DynamicResourceExtensionConverter: TypeConverter { ////// True if converting to an instance descriptor /// public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { return true; } return base.CanConvertTo(context, destinationType); } ////// Converts to an instance descriptor /// ////// Critical: calls InstanceDescriptor ctor which LinkDemands /// PublicOK: can only make an InstanceDescriptor for DynamicResourceExtension, not an arbitrary class /// [SecurityCritical] public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { if(value == null) throw new ArgumentNullException("value"); DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; if (dynamicResource == null) throw new ArgumentException(SR.Get(SRID.MustBeOfType, "value", "DynamicResourceExtension"), "value"); return new InstanceDescriptor(typeof(DynamicResourceExtension).GetConstructor(new Type[] { typeof(object) }), new object[] { dynamicResource.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
- ApplicationException.cs
- SafeCryptContextHandle.cs
- StagingAreaInputItem.cs
- HtmlTableCell.cs
- ManagedWndProcTracker.cs
- Compilation.cs
- Normalization.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- DesignerCalendarAdapter.cs
- PolicyConversionContext.cs
- XmlNavigatorFilter.cs
- CommunicationObjectAbortedException.cs
- BookmarkScopeHandle.cs
- SurrogateSelector.cs
- MetadataSection.cs
- RecipientIdentity.cs
- NativeMethods.cs
- LicenseException.cs
- RotateTransform3D.cs
- HierarchicalDataBoundControlAdapter.cs
- TransportListener.cs
- DataComponentMethodGenerator.cs
- FontFamilyConverter.cs
- _ListenerResponseStream.cs
- DataList.cs
- AddIn.cs
- LicenseContext.cs
- PageVisual.cs
- MobileRedirect.cs
- XmlSchemaImport.cs
- DispatcherExceptionFilterEventArgs.cs
- EditorAttribute.cs
- SplitContainer.cs
- DesigntimeLicenseContextSerializer.cs
- XmlSchemaIdentityConstraint.cs
- IgnoreSection.cs
- ToolStripPanel.cs
- documentsequencetextview.cs
- ScalarType.cs
- DataGridItemCollection.cs
- ShutDownListener.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- PrintControllerWithStatusDialog.cs
- MenuBase.cs
- UniqueID.cs
- CommentEmitter.cs
- GPRECTF.cs
- ExpressionNode.cs
- OLEDB_Enum.cs
- DispatchWrapper.cs
- LinkedList.cs
- ClientApiGenerator.cs
- DeclarativeCatalogPart.cs
- CollectionChangeEventArgs.cs
- Rect.cs
- SessionStateSection.cs
- ComponentCommands.cs
- BaseConfigurationRecord.cs
- WsatTransactionHeader.cs
- ProfilePropertySettingsCollection.cs
- CaseStatementSlot.cs
- PropertyInformationCollection.cs
- AssemblyResolver.cs
- Timer.cs
- AndCondition.cs
- CompatibleComparer.cs
- ResolveCriteriaApril2005.cs
- Literal.cs
- SQLInt16.cs
- RegionData.cs
- TypeInfo.cs
- SqlClientWrapperSmiStream.cs
- WebPartConnection.cs
- ProfileModule.cs
- BackgroundWorker.cs
- DataBoundControlParameterTarget.cs
- QueryConverter.cs
- ForceCopyBuildProvider.cs
- DbConnectionStringBuilder.cs
- DPAPIProtectedConfigurationProvider.cs
- HtmlForm.cs
- DeferredSelectedIndexReference.cs
- RowUpdatingEventArgs.cs
- KeyValueSerializer.cs
- BindUriHelper.cs
- XappLauncher.cs
- CFGGrammar.cs
- PropertyGeneratedEventArgs.cs
- XmlWhitespace.cs
- PathGeometry.cs
- WorkflowTransactionService.cs
- HttpModuleCollection.cs
- ZipIOFileItemStream.cs
- CodeTypeMember.cs
- webeventbuffer.cs
- URLIdentityPermission.cs
- RepeaterCommandEventArgs.cs
- PageParser.cs
- TransformerInfoCollection.cs
- HtmlTextArea.cs