本文整理汇总了C#中IValueContext类的典型用法代码示例。如果您正苦于以下问题:C# IValueContext类的具体用法?C# IValueContext怎么用?C# IValueContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValueContext类属于命名空间,在下文中一共展示了IValueContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetValue
public static void SetValue(
object instance,
MutableMember member,
object value,
IValueContext context)
{
var perspexProperty = FindPerspexProperty(instance, member);
if (value is IBinding)
{
SetBinding(instance, member, perspexProperty, (IBinding)value);
}
else if (perspexProperty != null)
{
((PerspexObject)instance).SetValue(perspexProperty, value);
}
else if (instance is Setter && member.Name == "Value")
{
// TODO: Make this more generic somehow.
var setter = (Setter)instance;
var targetType = setter.Property.PropertyType;
var xamlType = member.TypeRepository.GetByType(targetType);
var convertedValue = default(object);
if (CommonValueConversion.TryConvert(value, xamlType, context, out convertedValue))
{
SetClrProperty(instance, member, convertedValue);
}
}
else
{
SetClrProperty(instance, member, value);
}
}
示例2: ConvertFrom
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
{
return new MemberSelector
{
MemberName = (string)value,
};
}
示例3: GetValues
public IEnumerable<string> GetValues(IValueContext currentContext) {
return GetValue(currentContext).Split(new[] {
','
}, StringSplitOptions.RemoveEmptyEntries).Select( each => each.Trim());
}
示例4: ObjectAssembler
public ObjectAssembler(StackingLinkedList<Level> state,
IRuntimeTypeSource typeSource,
IInstanceLifeCycleListener listener,
IValueContext context)
{
StateCommuter = new StateCommuter(state, typeSource, listener, context);
LifecycleListener = listener;
}
示例5: ConvertTo
public object ConvertTo(
IValueContext context,
CultureInfo culture,
object value,
Type destinationType)
{
throw new NotImplementedException();
}
示例6: ConvertFrom
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
{
if (value is string)
{
return value;
}
return null;
}
示例7: CanConvertTo
public bool CanConvertTo(IValueContext context, Type destinationType)
{
if (destinationType == typeof(string) || destinationType == typeof(int))
{
return true;
}
return false;
}
示例8: SetValue
public virtual void SetValue(object instance, object value, IValueContext valueContext)
{
if (ValueSetter.IsStatic)
{
ValueSetter.Invoke(null, new[] { instance, value });
}
else
{
member.Setter.Invoke(instance, new[] { value });
}
}
示例9: ConvertFrom
public object ConvertFrom(IValueContext 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;
}
示例10: StateCommuter
public StateCommuter(StackingLinkedList<Level> stack,
IRuntimeTypeSource typeSource,
IInstanceLifeCycleListener lifecycleListener,
IValueContext valueContext)
{
Guard.ThrowIfNull(stack, nameof(stack));
Guard.ThrowIfNull(typeSource, nameof(typeSource));
Stack = stack;
this.lifecycleListener = lifecycleListener;
this.valueContext = valueContext;
}
示例11: ConvertFrom
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
{
var valueStr = (string)value;
if (!valueStr.Contains(":"))
{
// shorthand seconds format (ie. "0.25")
var secs = double.Parse(valueStr, CultureInfo.InvariantCulture);
return TimeSpan.FromSeconds(secs);
}
return TimeSpan.Parse(valueStr);
}
示例12: ConvertFrom
public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
{
FontWeight result;
if (Enum.TryParse(value as string, out result))
{
return result;
}
else
{
throw new ArgumentException("unable to convert parameter to FontWeight");
}
}
示例13: TryConvert
public static bool TryConvert(object value, XamlType targetType, IValueContext valueContext, out object result)
{
result = null;
foreach (var step in ValueConverters)
{
if (step.TryConvert(value, targetType, valueContext, out result))
{
return true;
}
}
return false;
}
示例14: ConvertFrom
public object ConvertFrom(IValueContext 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));
}
}
示例15: SetBinding
private static void SetBinding(
object instance,
MutableMember member,
AvaloniaProperty property,
IValueContext context,
IBinding binding)
{
if (!(AssignBinding(instance, member, binding) ||
ApplyBinding(instance, property, context, binding)))
{
throw new InvalidOperationException(
$"Cannot assign to '{member.Name}' on '{instance.GetType()}");
}
}