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
- TableRowCollection.cs
- CompiledQueryCacheEntry.cs
- TaiwanCalendar.cs
- GenericTypeParameterBuilder.cs
- BamlLocalizer.cs
- VisualTransition.cs
- CustomBindingCollectionElement.cs
- IPAddressCollection.cs
- QuaternionRotation3D.cs
- RegexMatch.cs
- StorageInfo.cs
- List.cs
- WaitHandle.cs
- TranslateTransform.cs
- MessageQueuePermissionEntry.cs
- SponsorHelper.cs
- CellTreeNode.cs
- DrawingGroup.cs
- UpDownBaseDesigner.cs
- DocumentPropertiesDialog.cs
- SplitterEvent.cs
- UInt64Storage.cs
- ValueQuery.cs
- WindowShowOrOpenTracker.cs
- ValidateNames.cs
- CheckedPointers.cs
- ActivityDelegate.cs
- DataGridItemAttachedStorage.cs
- TextEditorLists.cs
- VirtualPathUtility.cs
- WhiteSpaceTrimStringConverter.cs
- _ConnectStream.cs
- TextEmbeddedObject.cs
- WebPartZoneBaseDesigner.cs
- PrintDialog.cs
- ResourceCollectionInfo.cs
- SqlCachedBuffer.cs
- DataGridViewCellValidatingEventArgs.cs
- NullExtension.cs
- DomNameTable.cs
- XsltException.cs
- DeleteHelper.cs
- ToolStripRendererSwitcher.cs
- LongTypeConverter.cs
- AudioSignalProblemOccurredEventArgs.cs
- SchemaTypeEmitter.cs
- Int16AnimationUsingKeyFrames.cs
- XPathConvert.cs
- Base64Stream.cs
- EncoderParameter.cs
- SqlCaseSimplifier.cs
- FixedDocument.cs
- WebErrorHandler.cs
- PropertyConverter.cs
- StylusOverProperty.cs
- PathTooLongException.cs
- DeferredReference.cs
- Matrix3DStack.cs
- FixedTextContainer.cs
- SimpleNameService.cs
- TemplateInstanceAttribute.cs
- Point.cs
- WebPartEditVerb.cs
- SiteMapDataSource.cs
- SplineKeyFrames.cs
- EntityWithKeyStrategy.cs
- FunctionQuery.cs
- PropertyRef.cs
- FormsAuthentication.cs
- _UriTypeConverter.cs
- DATA_BLOB.cs
- WindowsRebar.cs
- FrameworkElement.cs
- mediaeventshelper.cs
- SparseMemoryStream.cs
- UpdateExpressionVisitor.cs
- CodeDOMUtility.cs
- NegatedConstant.cs
- HttpHeaderCollection.cs
- GenericTransactionFlowAttribute.cs
- OpenFileDialog.cs
- EntityDataSourceState.cs
- StringUtil.cs
- SupportsEventValidationAttribute.cs
- SortKey.cs
- AncillaryOps.cs
- X509AsymmetricSecurityKey.cs
- ModelTreeEnumerator.cs
- WebResourceAttribute.cs
- ToolStripGripRenderEventArgs.cs
- XhtmlBasicCommandAdapter.cs
- RuleSet.cs
- ConsumerConnectionPointCollection.cs
- ConstrainedDataObject.cs
- TemplateManager.cs
- HtmlInputPassword.cs
- ExceptionWrapper.cs
- PagerStyle.cs
- BaseDataBoundControlDesigner.cs
- SingleAnimationBase.cs