Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / FontFamilyValueSerializer.cs / 1 / 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
- StorageInfo.cs
- ServiceBuildProvider.cs
- CodeValidator.cs
- XmlReflectionMember.cs
- RoutedUICommand.cs
- CubicEase.cs
- TemplateParser.cs
- CodeValidator.cs
- RowToParametersTransformer.cs
- EasingQuaternionKeyFrame.cs
- LogArchiveSnapshot.cs
- StrokeIntersection.cs
- DataGridViewImageCell.cs
- CharAnimationBase.cs
- XPathNavigatorKeyComparer.cs
- XmlTextWriter.cs
- SessionParameter.cs
- MaskInputRejectedEventArgs.cs
- ByteStream.cs
- AnnotationDocumentPaginator.cs
- NotConverter.cs
- Object.cs
- LayoutExceptionEventArgs.cs
- KnownTypesProvider.cs
- Propagator.ExtentPlaceholderCreator.cs
- StylusPoint.cs
- SmtpLoginAuthenticationModule.cs
- FormCollection.cs
- MdiWindowListStrip.cs
- GeneralTransformGroup.cs
- PublisherIdentityPermission.cs
- Exceptions.cs
- IChannel.cs
- PolyBezierSegmentFigureLogic.cs
- SQLInt32.cs
- MediaCommands.cs
- ImageSourceValueSerializer.cs
- BindingListCollectionView.cs
- MethodExpression.cs
- InheritedPropertyDescriptor.cs
- ScriptBehaviorDescriptor.cs
- ClientSponsor.cs
- OverrideMode.cs
- LogLogRecordEnumerator.cs
- DesignerTextBoxAdapter.cs
- ScriptResourceAttribute.cs
- ValidationVisibilityAttribute.cs
- FixedDocumentSequencePaginator.cs
- EdmEntityTypeAttribute.cs
- SecurityManager.cs
- OdbcParameterCollection.cs
- GridToolTip.cs
- BitmapMetadataBlob.cs
- FaultPropagationQuery.cs
- ClientSettingsSection.cs
- XmlILOptimizerVisitor.cs
- AdornerLayer.cs
- SqlCacheDependency.cs
- RSAProtectedConfigurationProvider.cs
- HandleExceptionArgs.cs
- PersonalizableAttribute.cs
- HttpListenerResponse.cs
- XMLSchema.cs
- HitTestParameters3D.cs
- HeaderPanel.cs
- ConfigXmlText.cs
- TableLayoutColumnStyleCollection.cs
- TripleDESCryptoServiceProvider.cs
- DataObject.cs
- XmlILConstructAnalyzer.cs
- DetailsViewUpdateEventArgs.cs
- XmlSchemaSequence.cs
- Panel.cs
- CollectionChangeEventArgs.cs
- DataGridViewRowHeaderCell.cs
- DataGridClipboardHelper.cs
- CompModSwitches.cs
- NavigationProperty.cs
- SizeIndependentAnimationStorage.cs
- Main.cs
- TranslateTransform3D.cs
- RuleSetReference.cs
- DictionaryEntry.cs
- ScrollChrome.cs
- CodeConditionStatement.cs
- LoginName.cs
- ExpressionEditorAttribute.cs
- FixUp.cs
- RSAOAEPKeyExchangeDeformatter.cs
- SignatureDescription.cs
- XmlAttributeOverrides.cs
- Html32TextWriter.cs
- AutoSizeComboBox.cs
- WindowsListViewSubItem.cs
- DataRelationPropertyDescriptor.cs
- Effect.cs
- CorrelationManager.cs
- DebugInfoExpression.cs
- RegexWriter.cs
- ManipulationLogic.cs