Exemple #1
0
 public static IAttribute <T> Default <T>()
 {
     return(Create(
                Observable.Return(UxExpression.Inherited(default(T))),
                Observable.Return(default(T)),
                clear: Command.Disabled,
                write: (t, save) => { },
                isReadOnly: Observable.Return(true),
                stringValue: Property.Constant("")));
 }
Exemple #2
0
 public static IAttribute <TOut> Focus <TIn, TOut>(
     this IAttribute <TIn> property,
     Func <TIn, TOut> select,
     Func <TIn, TOut, TIn> combine,
     Func <string, Parsed <TOut> > parse,
     Func <TOut, string> serialize,
     TOut inheritedValue)
 {
     return(property.Focus(
                c => c.Local
                .SelectMany(l => l.Value)
                .MatchWith(
                    some: local => UxExpression.Local(serialize(select(local)), parse, inheritedValue),
                    none: () => UxExpression.Inherited(inheritedValue)),
                select,
                combine));
 }
Exemple #3
0
 public static IAttribute <TTo> Convert <TTo>(
     this IProperty <Optional <string> > property,
     Func <string, Parsed <TTo> > parse,
     Func <TTo, string> serialize,
     TTo defaultValue)
 {
     return(Attribute.Create(
                expression: property.Select(v =>
                                            v.MatchWith(
                                                some: value => UxExpression.Local(value, parse, defaultValue),
                                                none: () => UxExpression.Inherited(defaultValue))),
                value: property.SelectSome(v =>
                                           v.MatchWith(
                                               some: prop => parse(prop).Value,
                                               none: () => Optional.Some(defaultValue))),
                clear: Command.Enabled(() => property.Write(Optional.None())),
                write: (value, save) => property.Write(serialize(value), save),
                isReadOnly: property.IsReadOnly,
                stringValue: property.OrEmpty()));
 }