Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / Microsoft / VisualBasic / Activities / XamlIntegration / VisualBasicSettingsConverter.cs / 1407647 / VisualBasicSettingsConverter.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace Microsoft.VisualBasic.Activities.XamlIntegration
{
using System;
using System.ComponentModel;
using System.Runtime;
using System.Globalization;
using System.Activities;
// this class is necessary in order for our value serializer to get called by XAML,
// even though the functionality is a no-op
public sealed class VisualBasicSettingsConverter : TypeConverter
{
public VisualBasicSettingsConverter()
: base()
{
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == TypeHelper.StringType)
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == TypeHelper.StringType)
{
return false;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string sourceString = value as string;
if (sourceString != null)
{
if (sourceString.Equals(VisualBasicSettingsValueSerializer.ImplementationVisualBasicSettingsValue))
{
// this is the VBSettings for the internal implementation
// suppress its Xaml serialization
VisualBasicSettings settings = CollectXmlNamespacesAndAssemblies(context);
if (settings != null)
{
settings.SuppressXamlSerialization = true;
}
return settings;
}
if (!(sourceString.Equals(String.Empty) || sourceString.Equals(VisualBasicSettingsValueSerializer.VisualBasicSettingsValue)))
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidVisualBasicSettingsValue));
}
return CollectXmlNamespacesAndAssemblies(context);
}
return base.ConvertFrom(context, culture, value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
return base.ConvertTo(context, culture, value, destinationType);
}
VisualBasicSettings CollectXmlNamespacesAndAssemblies(ITypeDescriptorContext context)
{
return VisualBasicExpressionConverter.CollectXmlNamespacesAndAssemblies(context);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Transactions.cs
- TextEndOfSegment.cs
- Duration.cs
- CompModSwitches.cs
- StaticTextPointer.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- PenThreadPool.cs
- ProxyAttribute.cs
- SpotLight.cs
- ConfigXmlComment.cs
- WebPartTransformer.cs
- GridViewColumnCollectionChangedEventArgs.cs
- SQLString.cs
- AlgoModule.cs
- OutputCacheSection.cs
- Solver.cs
- DataGridViewTextBoxCell.cs
- ToolStripControlHost.cs
- FormViewModeEventArgs.cs
- DefaultPrintController.cs
- DtdParser.cs
- ExpressionWriter.cs
- ServiceDiscoveryElement.cs
- UserUseLicenseDictionaryLoader.cs
- ParameterCollectionEditor.cs
- ThreadSafeList.cs
- ExtentCqlBlock.cs
- SoapReflector.cs
- PropertyKey.cs
- TemplateBindingExpression.cs
- HttpListenerResponse.cs
- PeerApplicationLaunchInfo.cs
- GridViewColumnCollectionChangedEventArgs.cs
- SelectionChangedEventArgs.cs
- CommonDialog.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ConstantProjectedSlot.cs
- XmlIlVisitor.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- StringInfo.cs
- WebBrowserHelper.cs
- InkCollectionBehavior.cs
- InvalidPrinterException.cs
- MenuItemAutomationPeer.cs
- XPathNavigatorReader.cs
- UnsupportedPolicyOptionsException.cs
- EventMap.cs
- DiscoveryDocumentReference.cs
- Enlistment.cs
- TargetInvocationException.cs
- DataGridTablesFactory.cs
- EntityKey.cs
- SHA512Managed.cs
- ParenthesizePropertyNameAttribute.cs
- OuterGlowBitmapEffect.cs
- Zone.cs
- X509ChainElement.cs
- XdrBuilder.cs
- Imaging.cs
- CommandSet.cs
- GradientStopCollection.cs
- StylusPlugInCollection.cs
- EasingKeyFrames.cs
- MaskInputRejectedEventArgs.cs
- UIElementIsland.cs
- BitConverter.cs
- GraphicsPathIterator.cs
- HwndStylusInputProvider.cs
- InputMethodStateChangeEventArgs.cs
- CopyEncoder.cs
- TemplateEditingFrame.cs
- ProjectionPruner.cs
- Win32Native.cs
- TextRangeSerialization.cs
- MailAddressCollection.cs
- ProgressBarAutomationPeer.cs
- HttpCacheParams.cs
- DocumentApplication.cs
- ErasingStroke.cs
- DesignSurfaceEvent.cs
- UnauthorizedWebPart.cs
- _NetworkingPerfCounters.cs
- ProxyWebPartConnectionCollection.cs
- ReliabilityContractAttribute.cs
- SourceSwitch.cs
- StringArrayConverter.cs
- IntegerFacetDescriptionElement.cs
- CompiledQuery.cs
- PeerSecurityHelpers.cs
- ModelVisual3D.cs
- UpDownBase.cs
- InputProcessorProfiles.cs
- GifBitmapEncoder.cs
- IndexingContentUnit.cs
- DataGridCellInfo.cs
- WebPartConnectionsDisconnectVerb.cs
- ConnectAlgorithms.cs
- DataReaderContainer.cs
- ToolStripRendererSwitcher.cs
- ArraySubsetEnumerator.cs