本文整理汇总了C#中IValueSerializerContext类的典型用法代码示例。如果您正苦于以下问题:C# IValueSerializerContext类的具体用法?C# IValueSerializerContext怎么用?C# IValueSerializerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValueSerializerContext类属于命名空间,在下文中一共展示了IValueSerializerContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanConvertToString
/// <summary>
/// Determines whether the specified object can be converted into a <see cref="String"/>.
/// </summary>
/// <param name="value">The object to evaluate for conversion.</param>
/// <param name="context">Context information that is used for conversion.</param>
/// <returns>
/// <see langword="true"/> if the <paramref name="value"/> can be converted into a
/// <see cref="String"/>; otherwise, <see langword="false"/>.
/// </returns>
public override bool CanConvertToString(object value, IValueSerializerContext context)
{
var gesture = value as MultiKeyGesture;
return gesture != null
&& ModifierKeysConverter.IsDefinedModifierKeys(gesture.Modifiers)
&& MultiKeyGestureConverter.IsDefinedKey(gesture.Key);
}
示例2: XamlObjectNodeIterator
public XamlObjectNodeIterator (object root, XamlSchemaContext schemaContext, IValueSerializerContext vctx, XamlObjectReaderSettings settings)
{
ctx = schemaContext;
this.root = root;
value_serializer_ctx = vctx;
this.settings = settings;
}
示例3: CanConvertToString
/// <summary>
/// Returns true if the given transform can be converted into a string
/// </summary>
public override bool CanConvertToString(object value, IValueSerializerContext context)
{
ImageSource imageSource = value as ImageSource;
#pragma warning disable 6506
return imageSource != null && imageSource.CanSerializeToString();
#pragma warning restore 6506
}
示例4: ConvertToString
/// <summary>
/// Converts a font family to a string.
/// </summary>
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;
}
示例5: CanConvertToString
public override bool CanConvertToString (object value, IValueSerializerContext context)
{
if (!(value is DateTime))
throw new ArgumentException ("Can only convert objects of type 'DateTime'");
return true;
}
示例6: CanConvertToString
/// <summary>
/// CanConvertToString()
/// </summary>
/// <param name="value"></param>
/// <param name="context"></param>
/// <returns></returns>
/// <ExternalAPI/>
public override bool CanConvertToString(object value, IValueSerializerContext context)
{
if (!(value is Key))
return false;
Key key = (Key)value;
return ((int)key >= (int)Key.None && (int)key <= (int)Key.OemClear);
}
示例7: ConvertToString
/// <summary>
/// ConvertToString()
/// </summary>
/// <param name="value"></param>
/// <param name="context"></param>
/// <returns></returns>
public override string ConvertToString(object value, IValueSerializerContext context)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Key));
if (converter != null)
return converter.ConvertToInvariantString(value);
else
return base.ConvertToString(value, context);
}
示例8: ConvertFromString
public override object ConvertFromString (string value, IValueSerializerContext context)
{
if (value == null)
throw new NotSupportedException ();
if (value.Length == 0)
return DateTime.MinValue;
return DateTime.Parse (value, CultureInfo.InvariantCulture, styles);
}
示例9: ConvertFromString
/// <summary>
/// Converts a <see cref="String"/> to an instance of the type that the implementation of
/// <see cref="ValueSerializer"/> supports.
/// </summary>
/// <param name="value">The string to convert.</param>
/// <param name="context">Context information that is used for conversion.</param>
/// <returns>
/// A new instance of the type that the implementation of <see cref="ValueSerializer"/>
/// supports based on the supplied <paramref name="value"/>.
/// </returns>
/// <exception cref="NotSupportedException">
/// <paramref name="value"/> cannot be converted.
/// </exception>
public override object ConvertFromString(string value, IValueSerializerContext context)
{
var converter = TypeDescriptor.GetConverter(typeof(KeyGesture));
if (converter != null)
return converter.ConvertFromString(value);
return base.ConvertFromString(value, context);
}
示例10: CanConvertToString
public override bool CanConvertToString(object value, IValueSerializerContext context)
{
if (AttachablePropertyServices.GetAttachedPropertyCount(value) > 0)
{
return false;
}
return (((value != null) && (value is IValueSerializableExpression)) && ((IValueSerializableExpression) value).CanConvertToString(context));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ActivityWithResultValueSerializer.cs
示例11: ConvertFromString
/// <summary>
/// Creates a FontFamily from a string
/// </summary>
public override object ConvertFromString(string value, IValueSerializerContext context)
{
if (string.IsNullOrEmpty(value))
{
throw GetConvertFromException(value);
}
return new FontFamily(value);
}
示例12: ConvertFromString
/// <summary>
/// ConvertFromString()
/// </summary>
/// <param name="value"></param>
/// <param name="context"></param>
/// <returns></returns>
public override object ConvertFromString(string value, IValueSerializerContext context)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(MouseAction));
if (converter != null)
return converter.ConvertFromString(value);
else
return base.ConvertFromString(value, context);
}
示例13: ConvertToStringWrapper
internal static string ConvertToStringWrapper(object value, IValueSerializerContext context)
{
if (valueSerializer == null)
{
valueSerializer = new ActivityWithResultValueSerializer();
}
return valueSerializer.ConvertToString(value, context);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ActivityWithResultValueSerializer.cs
示例14: ConvertFromString
public override object ConvertFromString(string value, IValueSerializerContext context)
{
if (value != null)
{
return DataRect.Parse(value);
}
return base.ConvertFromString(value, context);
}
示例15: ConvertToString
/// <summary>
/// Converts a transform into a string.
/// </summary>
public override string ConvertToString(object value, IValueSerializerContext context)
{
ImageSource imageSource = value as ImageSource;
if (imageSource != null)
return imageSource.ConvertToString(null, System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS);
else
return base.ConvertToString(value, context);
}