本文整理汇总了C#中IXamlTypeConverterContext类的典型用法代码示例。如果您正苦于以下问题:C# IXamlTypeConverterContext类的具体用法?C# IXamlTypeConverterContext怎么用?C# IXamlTypeConverterContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IXamlTypeConverterContext类属于命名空间,在下文中一共展示了IXamlTypeConverterContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
return new MemberSelector
{
MemberName = (string)value,
};
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:7,代码来源:MemberSelectorTypeConverter.cs
示例2: ConvertTo
public object ConvertTo(
IXamlTypeConverterContext context,
CultureInfo culture,
object value,
Type destinationType)
{
throw new NotImplementedException();
}
开发者ID:danwalmsley,项目名称:OmniXAML,代码行数:8,代码来源:TypeTypeConverter.cs
示例3: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var colorString = (string)value;
var color = DecodeColor(colorString);
return new SolidColorBrush(color);
}
开发者ID:Scellow,项目名称:Perspex,代码行数:8,代码来源:BrushConverter.cs
示例4: CanConvertFrom
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return false;
}
开发者ID:Scellow,项目名称:Perspex,代码行数:9,代码来源:ThicknessConverter.cs
示例5: ConvertTo
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType)
{
if ((string) value == "Auto")
{
return new GridLength(0, GridUnitType.Auto);
}
return new GridLength(1, GridUnitType.Star);
}
开发者ID:Scellow,项目名称:Perspex,代码行数:9,代码来源:GridLengthTypeConverter.cs
示例6: CanConvertTo
public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType)
{
if (destinationType == typeof(string) || destinationType == typeof(int))
{
return true;
}
return false;
}
开发者ID:grokys,项目名称:OmniXAML,代码行数:9,代码来源:StringTypeConverter.cs
示例7: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
if (value is string)
{
return value;
}
return null;
}
开发者ID:grokys,项目名称:OmniXAML,代码行数:9,代码来源:StringTypeConverter.cs
示例8: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var s = value as string;
if (s != null)
{
return ConvertFromString(s);
}
return null;
}
开发者ID:Scellow,项目名称:Perspex,代码行数:10,代码来源:ThicknessConverter.cs
示例9: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
string strValue = (string)value;
string[] pointStrs = strValue.Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var result = new List<Point>(pointStrs.Length);
foreach (var pointStr in pointStrs)
{
result.Add(Point.Parse(pointStr, culture));
}
return result;
}
开发者ID:abdelkarim,项目名称:Perspex,代码行数:11,代码来源:PointsListTypeConverter.cs
示例10: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var valueStr = (string)value;
if (!valueStr.Contains(":"))
{
// shorthand seconds format (ie. "0.25")
var secs = double.Parse(valueStr);
return TimeSpan.FromSeconds(secs);
}
return TimeSpan.Parse(valueStr);
}
开发者ID:Mike-EEE,项目名称:Perspex,代码行数:12,代码来源:TimeSpanTypeConverter.cs
示例11: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var s = (string)value;
string typeName;
string propertyName;
Type type;
ParseProperty(s, out typeName, out propertyName);
if (typeName == null)
{
var styleType = context.TypeRepository.GetXamlType(typeof(Style));
var style = (Style)context.TopDownValueContext.GetLastInstance(styleType);
type = style.Selector.TargetType;
if (type == null)
{
throw new XamlParseException(
"Could not determine the target type. Please fully qualify the property name.");
}
}
else
{
type = context.TypeRepository.GetByQualifiedName(typeName)?.UnderlyingType;
if (type == null)
{
throw new XamlParseException($"Could not find type '{typeName}'.");
}
}
// Ensure the type's static ctor has been run.
RuntimeHelpers.RunClassConstructor(type.TypeHandle);
// First look for non-attached property on the type and then look for an attached property.
var property = PerspexPropertyRegistry.Instance.FindRegistered(type, s);
if (property == null)
{
property = PerspexPropertyRegistry.Instance.GetAttached(type)
.FirstOrDefault(x => x.Name == propertyName);
}
if (property == null)
{
throw new XamlParseException(
$"Could not find PerspexProperty '{type.Name}.{propertyName}'.");
}
return property;
}
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:52,代码来源:PerspexPropertyTypeConverter.cs
示例12: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var uri = new Uri((string)value, UriKind.RelativeOrAbsolute);
var scheme = uri.IsAbsoluteUri ? uri.Scheme : "file";
switch (scheme)
{
case "file":
return new Bitmap((string)value);
default:
var assets = PerspexLocator.Current.GetService<IAssetLoader>();
return new Bitmap(assets.Open(uri));
}
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:14,代码来源:BitmapTypeConverter.cs
示例13: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var str = value as string;
if (str != null)
{
if (string.Equals(str, "Auto"))
{
return new GridLength(0, GridUnitType.Auto);
}
}
return new GridLength(1, GridUnitType.Star);
}
开发者ID:Scellow,项目名称:Perspex,代码行数:14,代码来源:GridLengthTypeConverter.cs
示例14: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var s = (string)value;
var lastDot = s.LastIndexOf('.');
if (lastDot == -1)
{
throw new NotSupportedException("PerspexProperties must currently be fully qualified.");
}
var typeName = s.Substring(0, lastDot);
var propertyName = s.Substring(lastDot + 1);
var type = context.TypeRepository.GetByQualifiedName(typeName)?.UnderlyingType;
var styleType = context.TypeRepository.GetXamlType(typeof(Style));
// ATTN: SuperJMN
//var style = ((XamlTypeConverterContext)context).TopDownValueContext.GetLastInstance(styleType);
if (type == null)
{
throw new XamlParseException($"Could not find type '{typeName}'.");
}
// First look for non-attached property on the type and then look for an attached property.
var property = PerspexObject.GetRegisteredProperties(type)
.FirstOrDefault(x => x.Name == propertyName);
if (property == null)
{
property = PerspexObject.GetAttachedProperties(type)
.FirstOrDefault(x => x.Name == propertyName);
}
if (property == null)
{
throw new XamlParseException(
$"Could not find PerspexProperty '{typeName}'.{propertyName}.");
}
return property;
}
开发者ID:rdterner,项目名称:Perspex,代码行数:41,代码来源:PerspexPropertyTypeConverter.cs
示例15: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
var str = value as string;
if (value is int)
{
return Convert.ToInt32(value, CultureInfo.InvariantCulture);
}
if (value is long)
{
return Convert.ToInt32(value, CultureInfo.InvariantCulture);
}
else if (str != null)
{
long v;
if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out v))
{
return (int)v;
}
}
throw new InvalidOperationException();
}
开发者ID:rdterner,项目名称:OmniXAML,代码行数:23,代码来源:IntTypeConverter.cs
示例16: ConvertTo
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType)
{
if (value == null)
{
return null;
}
if (destinationType == typeof(int))
{
var str = value as string;
if (str != null)
{
int n;
if (int.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out n))
{
return n;
}
return null;
}
}
if (destinationType == typeof(double))
{
var str = value as string;
if (str != null)
{
double n;
if (double.TryParse(str, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out n))
{
return n;
}
return null;
}
}
return value.ToString();
}
开发者ID:rdterner,项目名称:OmniXAML,代码行数:37,代码来源:StringTypeConverter.cs
示例17: ConvertTo
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType)
{
if (value == null)
{
return null;
}
if (destinationType == typeof(int))
{
var str = value as string;
if (str != null)
{
int n;
if (int.TryParse(str, out n))
{
return n;
}
return null;
}
}
if (destinationType == typeof(double))
{
var str = value as string;
if (str != null)
{
double n;
if (double.TryParse(str, out n))
{
return n;
}
return null;
}
}
return value.ToString();
}
开发者ID:grokys,项目名称:OmniXAML,代码行数:37,代码来源:StringTypeConverter.cs
示例18: ConvertFrom
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
return RelativePoint.Parse((string)value, culture);
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:4,代码来源:RelativePointTypeConverter.cs
示例19: CanConvertTo
public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType)
{
return false;
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:4,代码来源:RelativePointTypeConverter.cs
示例20: CanConvertFrom
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)
{
return sourceType == typeof(string);
}
开发者ID:Arlorean,项目名称:Perspex,代码行数:4,代码来源:RelativePointTypeConverter.cs
注:本文中的IXamlTypeConverterContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论