本文整理汇总了C#中ISetting.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ISetting.Write方法的具体用法?C# ISetting.Write怎么用?C# ISetting.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISetting
的用法示例。
在下文中一共展示了ISetting.Write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecentSearchCollection
public RecentSearchCollection(ILogger logger, ISetting<RecentSearch[]> setting)
{
if (logger == null) throw new ArgumentNullException("logger");
_logger = logger;
Items = _files.Connect()
.RemoveKey()
.AsObservableList();
var loader = setting.Value.Subscribe(files =>
{
_files.Edit(innerCache =>
{
//all files are loaded when state changes, so only add new ones
var newItems = files
.Where(f => !innerCache.Lookup(f.Text).HasValue)
.ToArray();
innerCache.AddOrUpdate(newItems);
});
});
var settingsWriter = _files.Connect()
.ToCollection()
.Subscribe(items =>
{
setting.Write(items.ToArray());
});
_cleanUp = new CompositeDisposable(settingsWriter, loader, _files,Items);
}
示例2: GeneralOptionsViewModel
public GeneralOptionsViewModel(ISetting<GeneralOptions> setting, ISchedulerProvider schedulerProvider)
{
var reader = setting.Value.Subscribe(options =>
{
UseDarkTheme = options.Theme== Theme.Dark;
HighlightTail = options.HighlightTail;
HighlightDuration = options.HighlightDuration;
Scale = options.Scale;
});
var writter = this.WhenAnyPropertyChanged()
.Subscribe(vm =>
{
setting.Write(new GeneralOptions(UseDarkTheme ? Theme.Dark : Theme.Light, HighlightTail, HighlightDuration, Scale));
});
HighlightDurationText = this.WhenValueChanged(vm=>vm.HighlightDuration)
.Select(value => value.ToString("0.00 Seconds"))
.ForBinding();
ScaleText = this.WhenValueChanged(vm => vm.Scale)
.Select(value => $"{value} %" )
.ForBinding();
ScaleRatio= this.WhenValueChanged(vm => vm.Scale)
.Select(value =>(decimal)value / (decimal)100)
// .Sample(TimeSpan.FromMilliseconds(250))
.ForBinding();
_cleanUp = new CompositeDisposable(reader, writter, HighlightDurationText, ScaleText, ScaleRatio);
}
示例3: GeneralOptionsViewModel
public GeneralOptionsViewModel(ISetting<GeneralOptions> setting, ISchedulerProvider schedulerProvider)
{
var reader = setting.Value.Subscribe(options =>
{
UseDarkTheme = options.Theme== Theme.Dark;
HighlightTail = options.HighlightTail;
HighlightDuration = options.HighlightDuration;
Scale = options.Scale;
});
var writter = this.WhenAnyPropertyChanged()
.Subscribe(vm =>
{
setting.Write(new GeneralOptions(UseDarkTheme ? Theme.Dark : Theme.Light, HighlightTail, HighlightDuration, Scale));
});
var themeSetter = setting.Value.Select(options=> options.Theme)
.ObserveOn(schedulerProvider.MainThread)
.Subscribe(theme =>
{
new PaletteHelper().SetLightDark(theme== Theme.Dark);
});
HighlightDurationText = this.WhenValueChanged(vm=>vm.HighlightDuration)
.Select(value => value.ToString("0.00 Seconds"))
.ForBinding();
ScaleText = this.WhenValueChanged(vm => vm.Scale)
.Select(value => value+" %" )
.ForBinding();
ScaleRatio= this.WhenValueChanged(vm => vm.Scale)
.Select(value =>(decimal)value / (decimal)100)
//.Sample(Times)
.Do(x=> { Console.WriteLine(); })
.ForBinding();
_cleanUp = new CompositeDisposable(reader, writter, themeSetter, HighlightDurationText, ScaleText, ScaleRatio);
}