Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / FontFamilyValueSerializer.cs / 1305600 / FontFamilyValueSerializer.cs
//+------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2002 // // File: FontFamilyValueSerializer.cs // // Contents: FontFamilyValueSerializer implementation // // Created: 6-20-2005 Chuck Jazdzewski ([....]) // //----------------------------------------------------------------------- using System.ComponentModel; using System.Globalization; using System.Windows.Markup; // Allow suppression of presharp warnings #pragma warning disable 1634, 1691 namespace System.Windows.Media { ////// Serializer for a FontFamily /// public class FontFamilyValueSerializer: ValueSerializer { ////// Returns true. FontFamilyValueSerializer can always convert from a string. /// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } ////// Creates a FontFamily from a string /// public override object ConvertFromString(string value, IValueSerializerContext context) { if (string.IsNullOrEmpty(value)) { throw GetConvertFromException(value); } return new FontFamily(value); } ////// Returns true if the FontFamily is a named font family. /// public override bool CanConvertToString(object value, IValueSerializerContext context) { FontFamily fontFamily = value as FontFamily; // Suppress PRESharp warning that fontFamily can be null; apparently PRESharp // doesn't understand short circuit evaluation of operator &&. #pragma warning suppress 56506 return fontFamily != null && fontFamily.Source != null && fontFamily.Source.Length != 0; } ////// Converts a font family to a string. /// public override string ConvertToString(object value, IValueSerializerContext context) { FontFamily fontFamily = value as FontFamily; if (fontFamily == null || fontFamily.Source == null) throw GetConvertToException(value, typeof(string)); return fontFamily.Source; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //+------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2002 // // File: FontFamilyValueSerializer.cs // // Contents: FontFamilyValueSerializer implementation // // Created: 6-20-2005 Chuck Jazdzewski ([....]) // //----------------------------------------------------------------------- using System.ComponentModel; using System.Globalization; using System.Windows.Markup; // Allow suppression of presharp warnings #pragma warning disable 1634, 1691 namespace System.Windows.Media { ////// Serializer for a FontFamily /// public class FontFamilyValueSerializer: ValueSerializer { ////// Returns true. FontFamilyValueSerializer can always convert from a string. /// public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } ////// Creates a FontFamily from a string /// public override object ConvertFromString(string value, IValueSerializerContext context) { if (string.IsNullOrEmpty(value)) { throw GetConvertFromException(value); } return new FontFamily(value); } ////// Returns true if the FontFamily is a named font family. /// public override bool CanConvertToString(object value, IValueSerializerContext context) { FontFamily fontFamily = value as FontFamily; // Suppress PRESharp warning that fontFamily can be null; apparently PRESharp // doesn't understand short circuit evaluation of operator &&. #pragma warning suppress 56506 return fontFamily != null && fontFamily.Source != null && fontFamily.Source.Length != 0; } ////// Converts a font family to a string. /// public override string ConvertToString(object value, IValueSerializerContext context) { FontFamily fontFamily = value as FontFamily; if (fontFamily == null || fontFamily.Source == null) throw GetConvertToException(value, typeof(string)); return fontFamily.Source; } } } // 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
- Vector3DAnimationUsingKeyFrames.cs
- CompatibleIComparer.cs
- GeometryHitTestParameters.cs
- XsltLoader.cs
- MessageLogTraceRecord.cs
- Rotation3DAnimationUsingKeyFrames.cs
- EntityTypeBase.cs
- CharKeyFrameCollection.cs
- DisplayInformation.cs
- ResolveDuplex11AsyncResult.cs
- PanelStyle.cs
- Win32.cs
- ForeignConstraint.cs
- DynamicDocumentPaginator.cs
- IntSecurity.cs
- __ConsoleStream.cs
- WasEndpointConfigContainer.cs
- DSASignatureDeformatter.cs
- RichTextBoxAutomationPeer.cs
- FormsAuthenticationTicket.cs
- HMACSHA1.cs
- MatrixKeyFrameCollection.cs
- ReadOnlyMetadataCollection.cs
- TreeNodeStyle.cs
- KeyBinding.cs
- SystemIPAddressInformation.cs
- RegexTree.cs
- BuildProviderAppliesToAttribute.cs
- KnownBoxes.cs
- X509Certificate.cs
- OdbcHandle.cs
- ClipboardProcessor.cs
- DataGridItem.cs
- XmlException.cs
- FixedSOMTable.cs
- GeneralTransform2DTo3D.cs
- InputMethod.cs
- TripleDES.cs
- TabItemAutomationPeer.cs
- Fault.cs
- MultiViewDesigner.cs
- SessionStateModule.cs
- ListMarkerSourceInfo.cs
- ipaddressinformationcollection.cs
- Parsers.cs
- WebResourceUtil.cs
- WebBrowserHelper.cs
- SecurityTokenResolver.cs
- CaseStatement.cs
- dbenumerator.cs
- TraceHandlerErrorFormatter.cs
- shaperfactory.cs
- ToolStripCollectionEditor.cs
- NextPreviousPagerField.cs
- BasicHttpBindingElement.cs
- TextElementEnumerator.cs
- QueryOutputWriter.cs
- GeneralTransform3DGroup.cs
- CopyAttributesAction.cs
- XPathNodeInfoAtom.cs
- DataBoundControl.cs
- SQLDoubleStorage.cs
- XmlObjectSerializerReadContextComplex.cs
- AnimationTimeline.cs
- FacetDescriptionElement.cs
- MatrixTransform.cs
- FontConverter.cs
- PropertyGroupDescription.cs
- URLString.cs
- ToolBarOverflowPanel.cs
- EditModeSwitchButton.cs
- QilGenerator.cs
- EntityParameter.cs
- NavigationWindow.cs
- NetTcpSectionData.cs
- StdValidatorsAndConverters.cs
- CommandManager.cs
- Convert.cs
- mil_sdk_version.cs
- SqlGenerator.cs
- XmlSerializationGeneratedCode.cs
- ChannelManager.cs
- WsatConfiguration.cs
- TextProviderWrapper.cs
- BufferModesCollection.cs
- SByteStorage.cs
- XamlParser.cs
- DataFormat.cs
- ServiceDescriptionReflector.cs
- RadioButton.cs
- DrawingContextDrawingContextWalker.cs
- JournalNavigationScope.cs
- TypeUsage.cs
- ISCIIEncoding.cs
- DataGridViewAccessibleObject.cs
- XmlNodeWriter.cs
- Operator.cs
- InputProviderSite.cs
- SqlFileStream.cs
- shaper.cs