本文整理汇总了C#中Observable类的典型用法代码示例。如果您正苦于以下问题:C# Observable类的具体用法?C# Observable怎么用?C# Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Observable类属于命名空间,在下文中一共展示了Observable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LogEntryCounter
public LogEntryCounter(ObservableCollection<LogEntry> entries)
{
this.Entries = entries;
Entries.CollectionChanged += Entries_CollectionChanged;
Count = new Observable<LogEntryLevelCount>();
Count.Value = GetCount(Entries);
}
开发者ID:Lundalogik,项目名称:log4net-logviewer,代码行数:7,代码来源:LogEntryCounter.cs
示例2: LoadIndex
private void LoadIndex(Observable<IndexDefinitionModel> observable)
{
var serverModel = ApplicationModel.Current.Server.Value;
if (serverModel == null)
{
ApplicationModel.Current.Server.RegisterOnce(() => LoadIndex(observable));
return;
}
ApplicationModel.Current.RegisterOnceForNavigation(() => LoadIndex(observable));
var asyncDatabaseCommands = serverModel.SelectedDatabase.Value.AsyncDatabaseCommands;
var name = ApplicationModel.Current.GetQueryParam("name");
if (name == null)
return;
asyncDatabaseCommands.GetIndexAsync(name)
.ContinueOnSuccess(index =>
{
if (index == null)
{
ApplicationModel.Current.Navigate(new Uri("/DocumentNotFound?id=" + name, UriKind.Relative));
return;
}
observable.Value = new IndexDefinitionModel(index, asyncDatabaseCommands);
}
)
.Catch();
}
开发者ID:samueldjack,项目名称:studio,代码行数:29,代码来源:IndexDefinitionModelLocator.cs
示例3: NewDatabase
public NewDatabase()
{
LicensingStatus = new Observable<LicensingStatus>();
InitializeComponent();
var req = ApplicationModel.DatabaseCommands.ForDefaultDatabase().CreateRequest("/license/status", "GET");
req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
{
LicensingStatus.Value = ((RavenJObject)doc).Deserialize<LicensingStatus>(new DocumentConvention());
var hasPeriodic =(bool) new BundleNameToActiveConverter().Convert(LicensingStatus.Value, typeof (bool), "PeriodicBackup",
CultureInfo.InvariantCulture);
if (hasPeriodic)
{
Bundles.Add("PeriodicBackup");
}
});
Bundles = new List<string>();
KeyDown += (sender, args) =>
{
if (args.Key == Key.Escape)
DialogResult = false;
};
}
开发者ID:aiex,项目名称:ravendb,代码行数:25,代码来源:NewDatabase.xaml.cs
示例4: AlertsModel
public AlertsModel()
{
Alerts = new ObservableCollection<AlertProxy>();
UnobservedAlerts = new ObservableCollection<AlertProxy>();
ServerAlerts = new ObservableCollection<Alert>();
ShowObserved = new Observable<bool>();
AlertsToSee = Alerts;
ShowObserved.PropertyChanged += (sender, args) =>
{
AlertsToSee = ShowObserved.Value ? Alerts : UnobservedAlerts;
OnPropertyChanged(() => AlertsToSee);
};
ServerAlerts.CollectionChanged += (sender, args) =>
{
Alerts.Clear();
foreach (var serverAlert in ServerAlerts)
{
Alerts.Add(new AlertProxy(serverAlert));
}
};
ShowObserved.Value = false;
Alerts.CollectionChanged += (sender, args) => UpdateUnobserved();
GetAlertsFromServer();
OnPropertyChanged(() => Alerts);
}
开发者ID:remcoros,项目名称:ravendb,代码行数:32,代码来源:AlertsModel.cs
示例5: AllDocumentsModel
static AllDocumentsModel()
{
Documents = new Observable<DocumentsModel>();
Documents.Value = new DocumentsModel();
SetTotalResults();
ApplicationModel.Database.PropertyChanged += (sender, args) => SetTotalResults();
}
开发者ID:richSourceShaper,项目名称:ravendb,代码行数:7,代码来源:AllDocumentsModel.cs
示例6: OnBeforeClientInit
protected override void OnBeforeClientInit(Observable sender)
{
base.OnBeforeClientInit(sender);
string apiKey = HttpContext.Current.Items["GMapApiKey"] as string;
this.ScriptManager.RegisterClientScriptInclude("GMapApiKey", string.Format(this.APIBaseUrl, apiKey ?? this.APIKey));
}
开发者ID:stacyjeptha,项目名称:coolite-ux-toolkit,代码行数:7,代码来源:GMapPanel.cs
示例7: MainWindowViewModel
public MainWindowViewModel()
{
Directories = new Observable<string>(string.Empty);
IsExecuting = new Observable<bool>();
Candidates = new Observable<IEnumerable<DuplicateCandidateGroup>>();
ExecuteCommand = new RelayCommand(Execute, CanExecute);
}
开发者ID:JonasSamuelsson,项目名称:DuplicateKiller,代码行数:7,代码来源:MainWindowViewModel.cs
示例8: CanHaveManyComputeds
public void CanHaveManyComputeds()
{
var prefix = new Observable<string>("Before");
var contacts = new ObservableList<Contact>(
Enumerable.Range(0, 10000)
.Select(i => new Contact()
{
FirstName = "FirstName" + i,
LastName = "LastName" + i
}));
var projections = new ComputedList<Projection>(() =>
from c in contacts
select new Projection(prefix, c));
string dummy;
foreach (var projection in projections)
dummy = projection.Name;
Assert.AreEqual("BeforeFirstName3LastName3", projections.ElementAt(3).Name);
prefix.Value = "After";
foreach (var projection in projections)
dummy = projection.Name;
Assert.AreEqual("AfterFirstName3LastName3", projections.ElementAt(3).Name);
}
开发者ID:Railgun-it,项目名称:Assisticant,代码行数:25,代码来源:LargeListTest.cs
示例9: CreateBindings
protected override void CreateBindings()
{
checkboxBinder = AddBinding<bool>(ObservableBoolName, value => checkbox.isChecked = value);
if (!String.IsNullOrEmpty(ObservableStringLabel)) {
AddBinding<string>(ObservableStringLabel, value => checkboxLabel.text = value);
}
}
开发者ID:hiyijia,项目名称:UnityDatabinding,代码行数:7,代码来源:CheckboxBinder.cs
示例10: SettingsMenu
public SettingsMenu(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
DisplayName = Observable("DisplayName", "Settings");
Volume = Observable("Volume", .25f);
}
开发者ID:GeorgeR,项目名称:UnityDatabinding,代码行数:7,代码来源:SettingsMenu.cs
示例11: CollectionsModel
static CollectionsModel()
{
Collections = new BindableCollection<CollectionModel>(model => model.Name, new KeysComparer<CollectionModel>(model => model.Count));
SelectedCollection = new Observable<CollectionModel>();
SelectedCollection.PropertyChanged += (sender, args) => PutCollectionNameInTheUrl();
}
开发者ID:maurodx,项目名称:ravendb,代码行数:7,代码来源:CollectionsModel.cs
示例12: ApplicationModel
private ApplicationModel()
{
Notifications = new BindableCollection<Notification>(x=>x.Message);
LastNotification = new Observable<string>();
Server = new Observable<ServerModel> {Value = new ServerModel()};
State = new ApplicationState();
}
开发者ID:royra,项目名称:ravendb,代码行数:7,代码来源:ApplicationModel.cs
示例13: WindowsAuthSettingsSectionModel
public WindowsAuthSettingsSectionModel()
{
SectionName = "Windows Authentication";
Document = new Observable<WindowsAuthDocument>();
RequiredUsers = new ObservableCollection<WindowsAuthData>();
RequiredGroups = new ObservableCollection<WindowsAuthData>();
SelectedList = new ObservableCollection<WindowsAuthData>();
DatabaseSuggestionProvider = new DatabaseSuggestionProvider();
WindowsAuthName = new WindowsAuthName();
ApplicationModel.DatabaseCommands.ForSystemDatabase()
.GetAsync("Raven/Authorization/WindowsSettings")
.ContinueOnSuccessInTheUIThread(doc =>
{
if (doc == null)
{
Document.Value = new WindowsAuthDocument();
return;
}
Document.Value = doc.DataAsJson.JsonDeserialization<WindowsAuthDocument>();
RequiredUsers = new ObservableCollection<WindowsAuthData>(Document.Value.RequiredUsers);
RequiredGroups = new ObservableCollection<WindowsAuthData>(Document.Value.RequiredGroups);
SelectedList = RequiredUsers;
OnPropertyChanged(() => Document);
OnPropertyChanged(() => RequiredUsers);
OnPropertyChanged(() => RequiredGroups);
});
}
开发者ID:nberardi,项目名称:ravendb,代码行数:29,代码来源:WindowsAuthSettingsSectionModel.cs
示例14: ContactsEditorViewModel
public ContactsEditorViewModel()
{
SelectedContact = (Observable<ObservableContact>)ValidatedObservableFactory.ValidatedObservable(new ObservableContact());
Contacts = new EntityDataViewModel(10, typeof(Contact),true);
Contacts.OnSelectedRowsChanged += OnSelectedRowsChanged;
Contacts.FetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' returntotalrecordcount='true' no-lock='true' distinct='false' count='{0}' paging-cookie='{1}' page='{2}'>
<entity name='contact'>
<attribute name='firstname' />
<attribute name='lastname' />
<attribute name='telephone1' />
<attribute name='birthdate' />
<attribute name='accountrolecode' />
<attribute name='parentcustomerid'/>
<attribute name='transactioncurrencyid'/>
<attribute name='creditlimit'/>
<attribute name='numberofchildren'/>
<attribute name='contactid' />{3}
</entity>
</fetch>";
// Register validation
ContactValidation.Register(Contacts.ValidationBinder);
ContactValidation.Register(new ObservableValidationBinder(this.SelectedContact));
}
开发者ID:aytacozkan,项目名称:NetworkView,代码行数:26,代码来源:ContactsEditorViewModel.cs
示例15: ValidValueShouldNotResultInAnyValidationErrors
public void ValidValueShouldNotResultInAnyValidationErrors()
{
var observable = new Observable<int>();
observable.Error.ShouldBe(string.Empty);
observable["Value"].ShouldBe(string.Empty);
}
开发者ID:JonasSamuelsson,项目名称:Handyman,代码行数:7,代码来源:ObservableOf1Tests.cs
示例16: PersonViewModel
public PersonViewModel()
{
this.FirstName = Knockout.Observable("Matthew");
this.LastName = Knockout.Observable("Leibowitz");
this.FullName = Knockout.Computed(() => this.FirstName.Value + " " + this.LastName.Value);
// AND, there is way to perform the updates to the computed object
//var options = new DependentObservableOptions<string>();
//options.GetValueFunction = () => self.FirstName.Value + " " + self.LastName.Value;
//options.SetValueFunction = s =>
//{
// s = s.Trim();
// var index = s.IndexOf(" ");
// if (index == -1)
// {
// self.FirstName.Value = s;
// self.LastName.Value = string.Empty;
// }
// else
// {
// self.FirstName.Value = s.Substring(0, index);
// self.LastName.Value = s.Substring(index + 1, s.Length);
// }
//};
//this.FullName = Knockout.Computed(options);
}
开发者ID:mattleibow,项目名称:SaltarelleCompilerSamples,代码行数:27,代码来源:PersonViewModel.cs
示例17: LoadDocument
private void LoadDocument(Observable<EditableDocumentModel> observable)
{
var serverModel = ApplicationModel.Current.Server.Value;
if (serverModel == null)
{
ApplicationModel.Current.Server.RegisterOnce(() => LoadDocument(observable));
return;
}
ApplicationModel.Current.RegisterOnceForNavigation(() => LoadDocument(observable));
var asyncDatabaseCommands = serverModel.SelectedDatabase.Value.AsyncDatabaseCommands;
var docId = ApplicationModel.Current.GetQueryParam("id");
if (docId == null)
return;
asyncDatabaseCommands.GetAsync(docId)
.ContinueOnSuccess(document =>
{
if (document == null)
{
ApplicationModel.Current.Navigate(new Uri("/DocumentNotFound?id=" + docId, UriKind.Relative));
return;
}
observable.Value = new EditableDocumentModel(document, asyncDatabaseCommands);
}
)
.Catch();
}
开发者ID:samueldjack,项目名称:studio,代码行数:30,代码来源:EditDocumentModelLocator.cs
示例18: ShouldBeAbleToChangeUnderlyingItemsAfterConstruction
public void ShouldBeAbleToChangeUnderlyingItemsAfterConstruction()
{
var item1 = new Observable<int>(1);
var item2 = new Observable<int>(2);
var observable = ReadOnlyObservable.Create(new[] { item1 }, x => x.Sum(y => y.Value));
var propertyChangedCount = 0;
observable.PropertyChanged += delegate { propertyChangedCount++; };
observable.Configure(x =>
{
x.Items.Remove(item1);
x.Items.Add(item2);
});
propertyChangedCount.ShouldBe(1);
observable.Value.ShouldBe(2);
item1.Value = 1;
propertyChangedCount.ShouldBe(1);
observable.Value.ShouldBe(2);
item2.Value = 1;
propertyChangedCount.ShouldBe(2);
observable.Value.ShouldBe(1);
}
开发者ID:JonasSamuelsson,项目名称:Handyman,代码行数:25,代码来源:ReadOnyObservableTests.cs
示例19: PeriodicBackupSettingsSectionModel
public PeriodicBackupSettingsSectionModel()
{
SectionName = "Periodic Backup";
SelectedOption = new Observable<int>();
ShowPeriodicBackup = new Observable<bool>();
var req = ApplicationModel.DatabaseCommands.ForSystemDatabase().CreateRequest("/license/status".NoCache(), "GET");
req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
{
var licensingStatus = ((RavenJObject)doc).Deserialize<LicensingStatus>(new DocumentConvention());
if (licensingStatus != null && licensingStatus.Attributes != null)
{
string active;
if (licensingStatus.Attributes.TryGetValue("PeriodicBackup", out active) == false)
ShowPeriodicBackup.Value = true;
else
{
bool result;
bool.TryParse(active, out result);
ShowPeriodicBackup.Value = result;
}
OnPropertyChanged(() => ShowPeriodicBackup);
}
});
}
开发者ID:nzaugg,项目名称:ravendb,代码行数:27,代码来源:PeriodicBackupSettingsSectionModel.cs
示例20: LogEntryCounter
public LogEntryCounter(ObservableCollection<LogEntryViewModel> entries)
{
this.Entries = entries;
Count = new Observable<LogEntryLevelCount>();
Count.Value = GetCount(Entries.ToArray());
Entries.CollectionChanged += EntriesCollectionChanged;
}
开发者ID:wallymathieu,项目名称:log4net-logviewer,代码行数:7,代码来源:LogEntryCounter.cs
注:本文中的Observable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论