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
- SurrogateSelector.cs
- NegotiationTokenAuthenticatorStateCache.cs
- _Rfc2616CacheValidators.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- SymbolDocumentGenerator.cs
- BaseInfoTable.cs
- Ops.cs
- PolicyManager.cs
- Enumerable.cs
- TrackingLocation.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- HtmlShimManager.cs
- ValidatorCollection.cs
- __TransparentProxy.cs
- WebPartsSection.cs
- MenuScrollingVisibilityConverter.cs
- TraceInternal.cs
- DataGridViewEditingControlShowingEventArgs.cs
- MappingModelBuildProvider.cs
- RemotingServices.cs
- XmlILStorageConverter.cs
- DataGridTextColumn.cs
- PersianCalendar.cs
- SkinBuilder.cs
- EntityClientCacheKey.cs
- httpapplicationstate.cs
- WSTrustDec2005.cs
- TypeHelper.cs
- MergeEnumerator.cs
- AttributeData.cs
- CodeConstructor.cs
- ContainerControl.cs
- CounterCreationDataConverter.cs
- PropertyValueChangedEvent.cs
- DataViewManagerListItemTypeDescriptor.cs
- MobileUserControlDesigner.cs
- ViewPort3D.cs
- HttpPostServerProtocol.cs
- Parameter.cs
- Selection.cs
- DataGridViewRowEventArgs.cs
- XPathDescendantIterator.cs
- SerializationAttributes.cs
- ScrollViewerAutomationPeer.cs
- WindowsListViewScroll.cs
- IRCollection.cs
- LogWriteRestartAreaAsyncResult.cs
- Cursors.cs
- X509Certificate2Collection.cs
- LicFileLicenseProvider.cs
- BaseParser.cs
- RefExpr.cs
- BitVector32.cs
- DetailsViewDeleteEventArgs.cs
- WebEventTraceProvider.cs
- TCEAdapterGenerator.cs
- Propagator.cs
- CngAlgorithm.cs
- StringFormat.cs
- SynchronizationLockException.cs
- ApplicationManager.cs
- StreamUpgradeInitiator.cs
- MainMenu.cs
- OutputCacheProfile.cs
- InvariantComparer.cs
- TemplateBindingExpression.cs
- FrameworkTextComposition.cs
- ServiceMetadataPublishingElement.cs
- TemplateBaseAction.cs
- DataGridColumn.cs
- ParameterToken.cs
- CompModSwitches.cs
- MemberRestriction.cs
- HMACRIPEMD160.cs
- XPathAxisIterator.cs
- ProxyDataContractResolver.cs
- DecimalFormatter.cs
- IOException.cs
- AddInServer.cs
- ProcessProtocolHandler.cs
- FormViewPagerRow.cs
- CustomWebEventKey.cs
- ChangeBlockUndoRecord.cs
- precedingquery.cs
- XmlCharCheckingReader.cs
- AuthenticationConfig.cs
- ActivityCodeDomSerializationManager.cs
- ToolStripItem.cs
- NonParentingControl.cs
- DbConnectionStringCommon.cs
- TransportBindingElement.cs
- XmlDictionaryReader.cs
- TreeNodeClickEventArgs.cs
- ParameterToken.cs
- ProfileParameter.cs
- WbmpConverter.cs
- _emptywebproxy.cs
- StrokeCollection2.cs
- SchemaObjectWriter.cs
- Expressions.cs