public static IBinding <TView, TContext> TwoWay( string propertyName, Func <TContext, TValue> getContextValue, Action <TView, TValue> setViewValue, Action <TContext, TValue> setContextValue, Func <TView, TValue> getViewValue, EventInfo eventInfo) { var viewUpdater = new ViewUpdater(getContextValue, setViewValue); var contextUpdater = new ContextUpdater(setContextValue, getViewValue, eventInfo); return(new Binding <TView, TContext, TValue>(propertyName, contextUpdater, viewUpdater)); }
/// <summary> /// Commits all added file systems using <paramref name="contextFileSystem"/> to /// store the <see cref="Context"/>. /// </summary> /// <param name="contextFileSystem">The file system where the commit context will be stored.</param> /// <returns>The <see cref="Result"/> of the operation.</returns> private Result Commit(IFileSystem contextFileSystem) { ContextUpdater context = default; try { Counter = 1; context = new ContextUpdater(contextFileSystem); Result rc = context.Create(Counter, FileSystems.Count); if (rc.IsFailure()) { return(rc); } rc = CommitProvisionallyFileSystem(Counter); if (rc.IsFailure()) { return(rc); } rc = context.CommitProvisionallyDone(); if (rc.IsFailure()) { return(rc); } rc = CommitFileSystem(); if (rc.IsFailure()) { return(rc); } rc = context.CommitDone(); if (rc.IsFailure()) { return(rc); } } finally { context.Dispose(); } return(Result.Success); }
public static IBinding <TView, TContext> OneWayToSource(Action <TContext, TValue> setContextValue, Func <TView, TValue> getViewValue, EventInfo eventInfo) { var contextUpdater = new ContextUpdater(setContextValue, getViewValue, eventInfo); return(new Binding <TView, TContext, TValue>(string.Empty, contextUpdater, null)); }
Binding(string propertyName, ContextUpdater contextUpdater, ViewUpdater viewUpdater) { this.PropertyName = propertyName ?? throw new ArgumentNullException(propertyName); this.viewUpdater = viewUpdater; this.contextUpdater = contextUpdater; }