当前位置: 首页>>代码示例>>C#>>正文


C# IValueContext类代码示例

本文整理汇总了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);
            }
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:34,代码来源:PropertyAccessor.cs

示例2: ConvertFrom

 public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
 {
     return new MemberSelector
     {
         MemberName = (string)value,
     };
 }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:7,代码来源:MemberSelectorTypeConverter.cs

示例3: GetValues

 public IEnumerable<string> GetValues(IValueContext currentContext) {
     
         return GetValue(currentContext).Split(new[] {
             ','
         }, StringSplitOptions.RemoveEmptyEntries).Select( each => each.Trim());
     
 }
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:7,代码来源:Scalar.cs

示例4: ObjectAssembler

 public ObjectAssembler(StackingLinkedList<Level> state,
     IRuntimeTypeSource typeSource,
     IInstanceLifeCycleListener listener,
     IValueContext context)
 {
     StateCommuter = new StateCommuter(state, typeSource, listener, context);
     LifecycleListener = listener;
 }
开发者ID:wieslawsoltes,项目名称:OmniXAML,代码行数:8,代码来源:ObjectAssembler.cs

示例5: ConvertTo

 public object ConvertTo(
     IValueContext context,
     CultureInfo culture,
     object value,
     Type destinationType)
 {
     throw new NotImplementedException();
 }
开发者ID:AvaloniaUI,项目名称:OmniXAML,代码行数:8,代码来源:TypeTypeConverter.cs

示例6: ConvertFrom

        public object ConvertFrom(IValueContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                return value;
            }

            return null;
        }
开发者ID:AvaloniaUI,项目名称:OmniXAML,代码行数:9,代码来源:StringTypeConverter.cs

示例7: CanConvertTo

        public bool CanConvertTo(IValueContext context, Type destinationType)
        {
            if (destinationType == typeof(string) || destinationType == typeof(int))
            {
                return true;
            }

            return false;
        }
开发者ID:AvaloniaUI,项目名称:OmniXAML,代码行数:9,代码来源:StringTypeConverter.cs

示例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 });
     }
 }
开发者ID:AvaloniaUI,项目名称:OmniXAML,代码行数:11,代码来源:MemberValuePlugin.cs

示例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;
 }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:11,代码来源:PointsListTypeConverter.cs

示例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;
        }
开发者ID:AvaloniaUI,项目名称:OmniXAML,代码行数:12,代码来源:StateCommuter.cs

示例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);
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:12,代码来源:TimeSpanTypeConverter.cs

示例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");
     }
 }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:13,代码来源:FontWeightConverter.cs

示例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;
        }
开发者ID:wieslawsoltes,项目名称:OmniXAML,代码行数:13,代码来源:CommonValueConversion.cs

示例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));
            }
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:14,代码来源:BitmapTypeConverter.cs

示例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()}");
     }
 }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:14,代码来源:PropertyAccessor.cs


注:本文中的IValueContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。