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
- TdsParserHelperClasses.cs
- HttpRuntimeSection.cs
- Classification.cs
- ScaleTransform3D.cs
- BitSet.cs
- TextUtf8RawTextWriter.cs
- ContextQuery.cs
- COMException.cs
- UnaryNode.cs
- _ConnectStream.cs
- Util.cs
- DataGridViewButtonColumn.cs
- DocumentAutomationPeer.cs
- ObservableCollection.cs
- CapabilitiesSection.cs
- WebPartsPersonalization.cs
- PathFigureCollectionValueSerializer.cs
- CssStyleCollection.cs
- XmlRawWriter.cs
- FormatSettings.cs
- Expr.cs
- CodeTypeParameterCollection.cs
- SoapReflector.cs
- ConfigXmlWhitespace.cs
- TextSelectionHelper.cs
- linebase.cs
- MetadataUtil.cs
- Imaging.cs
- ActiveDocumentEvent.cs
- DirectoryInfo.cs
- DataGridPagerStyle.cs
- TdsValueSetter.cs
- CompositeScriptReferenceEventArgs.cs
- DataServices.cs
- MethodRental.cs
- ColorMap.cs
- Blend.cs
- GifBitmapDecoder.cs
- XamlSerializer.cs
- InputLanguage.cs
- CodeVariableDeclarationStatement.cs
- HostingPreferredMapPath.cs
- RelationshipWrapper.cs
- AttachInfo.cs
- ValidatorCollection.cs
- DependencyPropertyKey.cs
- ColorDialog.cs
- TemplateBindingExpression.cs
- SystemTcpConnection.cs
- AssemblyAttributesGoHere.cs
- DesignRelationCollection.cs
- PageRanges.cs
- SimpleLine.cs
- QuestionEventArgs.cs
- SourceFileBuildProvider.cs
- FlowDocumentPage.cs
- InputEventArgs.cs
- QilXmlWriter.cs
- DataSourceControlBuilder.cs
- BrowserDefinition.cs
- UserPreferenceChangingEventArgs.cs
- NotSupportedException.cs
- MethodBody.cs
- HostExecutionContextManager.cs
- InplaceBitmapMetadataWriter.cs
- DiscoveryClientReferences.cs
- GlyphCache.cs
- ViewEventArgs.cs
- EtwTrace.cs
- ExpressionBuilderContext.cs
- SystemTcpStatistics.cs
- TreeNodeBinding.cs
- ContextMenu.cs
- ObjectConverter.cs
- ReachPageContentSerializerAsync.cs
- SoundPlayerAction.cs
- Monitor.cs
- DesignerToolboxInfo.cs
- ObjectPersistData.cs
- HTMLTextWriter.cs
- ListViewCancelEventArgs.cs
- NumericUpDownAccelerationCollection.cs
- PropVariant.cs
- SerializableAttribute.cs
- TextEncodedRawTextWriter.cs
- BezierSegment.cs
- CodeEventReferenceExpression.cs
- WpfXamlMember.cs
- FacetValues.cs
- InstrumentationTracker.cs
- ButtonBaseAdapter.cs
- PipeStream.cs
- VisualStyleInformation.cs
- TransformationRules.cs
- EncoderParameter.cs
- SecurityHelper.cs
- SortExpressionBuilder.cs
- DirectoryObjectSecurity.cs
- ValueQuery.cs
- LateBoundBitmapDecoder.cs