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
- ClientTargetCollection.cs
- DragEventArgs.cs
- Stackframe.cs
- DataObjectPastingEventArgs.cs
- InputScopeManager.cs
- SqlClientWrapperSmiStream.cs
- NoResizeHandleGlyph.cs
- DatagridviewDisplayedBandsData.cs
- ZipFileInfo.cs
- RegistryKey.cs
- GenerateScriptTypeAttribute.cs
- ProviderMetadata.cs
- ListenerSessionConnection.cs
- RenderData.cs
- ViewEventArgs.cs
- HttpResponse.cs
- IntegrationExceptionEventArgs.cs
- ProviderCollection.cs
- CalculatedColumn.cs
- ConnectionManagementElement.cs
- Selector.cs
- HtmlAnchor.cs
- SqlProcedureAttribute.cs
- ComponentDispatcher.cs
- ListBindingHelper.cs
- IndentedTextWriter.cs
- AutomationEvent.cs
- BCryptNative.cs
- ObjectFullSpanRewriter.cs
- DetailsViewCommandEventArgs.cs
- FlowDecisionDesigner.xaml.cs
- ReliableReplySessionChannel.cs
- ChangeNode.cs
- RowSpanVector.cs
- TraceHwndHost.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- OpenTypeCommon.cs
- NameObjectCollectionBase.cs
- ImportCatalogPart.cs
- SessionSwitchEventArgs.cs
- TemplateBamlTreeBuilder.cs
- DateTimeValueSerializerContext.cs
- Expander.cs
- MeshGeometry3D.cs
- KeyEvent.cs
- ServiceHttpModule.cs
- BitSet.cs
- NTAccount.cs
- WindowsAuthenticationModule.cs
- KeyEventArgs.cs
- BehaviorDragDropEventArgs.cs
- PauseStoryboard.cs
- BlurBitmapEffect.cs
- DataGridParentRows.cs
- GetMemberBinder.cs
- ToolBar.cs
- HttpConfigurationSystem.cs
- DiagnosticsConfiguration.cs
- TriggerCollection.cs
- EdmComplexTypeAttribute.cs
- SqlDataSource.cs
- FormParameter.cs
- Message.cs
- Duration.cs
- PolicyImporterElement.cs
- EntityUtil.cs
- CodeIndexerExpression.cs
- Vector3D.cs
- SourceInterpreter.cs
- CompositeFontInfo.cs
- PackageDigitalSignature.cs
- BaseCodeDomTreeGenerator.cs
- Stackframe.cs
- ConfigXmlElement.cs
- PropertyEmitterBase.cs
- QueuedDeliveryRequirementsMode.cs
- HttpServerVarsCollection.cs
- HttpWebRequest.cs
- SiteMapNodeItem.cs
- CheckBoxList.cs
- RemotingClientProxy.cs
- ParserStreamGeometryContext.cs
- KnownBoxes.cs
- StdRegProviderWrapper.cs
- OracleConnectionString.cs
- CroppedBitmap.cs
- ContentFilePart.cs
- QueueProcessor.cs
- DesignerDataRelationship.cs
- PersonalizationAdministration.cs
- WebConfigurationHostFileChange.cs
- SpeechSeg.cs
- OleDbPermission.cs
- EncodingInfo.cs
- RandomNumberGenerator.cs
- LocalizationParserHooks.cs
- WebPartsSection.cs
- DeviceContext.cs
- ListViewContainer.cs
- ComponentEditorPage.cs