Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / RoutedEventValueSerializer.cs / 1305600 / RoutedEventValueSerializer.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: RoutedEventValueSerializer.cs // // Contents: Value serializer for the RoutedEvent class // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; namespace System.Windows.Markup { internal class RoutedEventValueSerializer: ValueSerializer { public override bool CanConvertToString(object value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override string ConvertToString(object value, IValueSerializerContext context) { RoutedEvent routedEvent = value as RoutedEvent; if (routedEvent != null) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { return typeSerializer.ConvertToString(routedEvent.OwnerType, context) + "." + routedEvent.Name; } } return base.ConvertToString(value, context); } static DictionaryinitializedTypes = new Dictionary (); static void ForceTypeConstructors(Type currentType) { // Force load the Statics by walking up the hierarchy and running class constructors while (currentType != null && !initializedTypes.ContainsKey(currentType)) { MS.Internal.WindowsBase.SecurityHelper.RunClassConstructor(currentType); initializedTypes[currentType] = currentType; currentType = currentType.BaseType; } } public override object ConvertFromString(string value, IValueSerializerContext context) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { int index = value.IndexOf('.'); if (index > 0) { Type type = typeSerializer.ConvertFromString(value.Substring(0, index), context) as Type; string name = value.Substring(index + 1).Trim(); ForceTypeConstructors(type); return EventManager.GetRoutedEventFromName(name, type); } } return base.ConvertFromString(value, context); } } } // 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
- Exceptions.cs
- WebServiceTypeData.cs
- PassportPrincipal.cs
- JsonEnumDataContract.cs
- SecurityAlgorithmSuite.cs
- documentation.cs
- PartitionedStream.cs
- CellCreator.cs
- WithStatement.cs
- SqlWebEventProvider.cs
- SocketPermission.cs
- AsymmetricSignatureDeformatter.cs
- TreeNodeConverter.cs
- WebPartConnectionsConfigureVerb.cs
- HttpCacheVary.cs
- DbUpdateCommandTree.cs
- XsltSettings.cs
- DebugTraceHelper.cs
- QuaternionRotation3D.cs
- GroupBoxAutomationPeer.cs
- ExpressionPrefixAttribute.cs
- ClientTargetCollection.cs
- RegexGroupCollection.cs
- ScrollViewer.cs
- DetailsViewInsertEventArgs.cs
- SizeF.cs
- ActionItem.cs
- EastAsianLunisolarCalendar.cs
- SoapIgnoreAttribute.cs
- Listbox.cs
- BinaryWriter.cs
- SafeNativeMethodsCLR.cs
- SqlMetaData.cs
- ClientUtils.cs
- TemplatePagerField.cs
- JsonDeserializer.cs
- StaticDataManager.cs
- CopyNamespacesAction.cs
- InputEventArgs.cs
- LeftCellWrapper.cs
- DesignTimeValidationFeature.cs
- FixedDocumentPaginator.cs
- SoapMessage.cs
- BrowsableAttribute.cs
- TimeSpanSecondsConverter.cs
- ToolConsole.cs
- BaseTreeIterator.cs
- UnsafeNativeMethods.cs
- ErrorWebPart.cs
- ActionMessageFilterTable.cs
- MergeFilterQuery.cs
- PathSegmentCollection.cs
- CanonicalFontFamilyReference.cs
- MouseOverProperty.cs
- GeometryGroup.cs
- ProcessModuleCollection.cs
- _NegoState.cs
- ToolStripDesignerAvailabilityAttribute.cs
- DateTimeOffsetStorage.cs
- EtwTrace.cs
- DataGridViewBand.cs
- EntityContainerEntitySet.cs
- DataKey.cs
- COMException.cs
- TextAction.cs
- DesignSurfaceManager.cs
- StyleXamlTreeBuilder.cs
- ContentPathSegment.cs
- UInt64Converter.cs
- WindowsFormsHost.cs
- XamlToRtfWriter.cs
- OutputCacheSettings.cs
- XXXOnTypeBuilderInstantiation.cs
- DbConnectionClosed.cs
- RemoteWebConfigurationHostServer.cs
- SqlDataSourceView.cs
- WindowsRichEditRange.cs
- DataGridViewCellParsingEventArgs.cs
- WindowsListViewSubItem.cs
- ObjectListCommandCollection.cs
- MobileTextWriter.cs
- ContentPlaceHolder.cs
- DateTimeSerializationSection.cs
- PageTheme.cs
- AxisAngleRotation3D.cs
- FileIOPermission.cs
- InternalDispatchObject.cs
- SqlDependencyUtils.cs
- SynchronizationLockException.cs
- CompositeCollectionView.cs
- TextFindEngine.cs
- FontNamesConverter.cs
- EdmProviderManifest.cs
- ClientFormsAuthenticationMembershipProvider.cs
- ReachDocumentPageSerializer.cs
- SqlTransaction.cs
- QueryStringHandler.cs
- DataGridAddNewRow.cs
- SQLBinary.cs
- TargetParameterCountException.cs