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
- SspiSafeHandles.cs
- PropertyMap.cs
- wmiprovider.cs
- WmlLiteralTextAdapter.cs
- MappedMetaModel.cs
- WeakRefEnumerator.cs
- ObjectStorage.cs
- DataGridViewMethods.cs
- SessionParameter.cs
- BooleanExpr.cs
- FixedSchema.cs
- FacetDescriptionElement.cs
- hresults.cs
- TransactedBatchContext.cs
- CompilationLock.cs
- CheckPair.cs
- XPathScanner.cs
- ArithmeticException.cs
- DataConnectionHelper.cs
- coordinatorfactory.cs
- XamlReader.cs
- SignedPkcs7.cs
- XmlQueryContext.cs
- UTF8Encoding.cs
- NavigatingCancelEventArgs.cs
- XmlCharCheckingWriter.cs
- PropertyToken.cs
- Border.cs
- RawKeyboardInputReport.cs
- CreationContext.cs
- ChtmlTextBoxAdapter.cs
- LocalizableAttribute.cs
- TextRangeAdaptor.cs
- SoapMessage.cs
- ZoomingMessageFilter.cs
- TypeDelegator.cs
- DataGridCellItemAutomationPeer.cs
- SelectingProviderEventArgs.cs
- SynchronizationLockException.cs
- WinFormsSecurity.cs
- PrinterUnitConvert.cs
- XmlSchemaSimpleContentExtension.cs
- SortQuery.cs
- StaticSiteMapProvider.cs
- Identifier.cs
- OperationAbortedException.cs
- SynthesizerStateChangedEventArgs.cs
- ExpandSegment.cs
- DataGridViewComponentPropertyGridSite.cs
- InternalConfigHost.cs
- DataGridViewCellEventArgs.cs
- SchemeSettingElement.cs
- StringHandle.cs
- TileModeValidation.cs
- CurrentTimeZone.cs
- GridErrorDlg.cs
- Binding.cs
- GridViewColumnHeader.cs
- safemediahandle.cs
- WorkflowRuntimeServicesBehavior.cs
- ButtonBaseDesigner.cs
- SqlDataSourceEnumerator.cs
- TraceSwitch.cs
- X509Utils.cs
- CfgSemanticTag.cs
- ConcurrentDictionary.cs
- JsonQueryStringConverter.cs
- NativeMethods.cs
- StatusBarPanelClickEvent.cs
- OleDbException.cs
- SqlResolver.cs
- InternalMappingException.cs
- ByValueEqualityComparer.cs
- XmlSchemaImporter.cs
- BaseResourcesBuildProvider.cs
- EventProviderBase.cs
- OleDbConnection.cs
- DynamicRouteExpression.cs
- DescendantOverDescendantQuery.cs
- Pointer.cs
- BoundingRectTracker.cs
- DataViewListener.cs
- InternalCache.cs
- DesignOnlyAttribute.cs
- MapPathBasedVirtualPathProvider.cs
- MenuItemCollection.cs
- TransactionWaitAsyncResult.cs
- GuidelineSet.cs
- Highlights.cs
- SectionInput.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- OdbcDataAdapter.cs
- XmlIncludeAttribute.cs
- MarkerProperties.cs
- ToolStrip.cs
- StreamGeometryContext.cs
- BamlStream.cs
- SegmentInfo.cs
- TextBoxBase.cs
- XmlNodeChangedEventArgs.cs