本文整理汇总了C#中Observable类的典型用法代码示例。如果您正苦于以下问题:C# Observable类的具体用法?C# Observable怎么用?C# Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Observable类属于命名空间,在下文中一共展示了Observable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogEntryCounter
public LogEntryCounter(ObservableCollection<LogEntry> entries)
{
this.Entries = entries;
Entries.CollectionChanged += Entries_CollectionChanged;
Count = new Observable<LogEntryLevelCount>();
Count.Value = GetCount(Entries);
}
示例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();
}
示例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;
};
}
示例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);
}
示例5: AllDocumentsModel
static AllDocumentsModel()
{
Documents = new Observable<DocumentsModel>();
Documents.Value = new DocumentsModel();
SetTotalResults();
ApplicationModel.Database.PropertyChanged += (sender, args) => SetTotalResults();
}
示例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));
}
示例7: MainWindowViewModel
public MainWindowViewModel()
{
Directories = new Observable<string>(string.Empty);
IsExecuting = new Observable<bool>();
Candidates = new Observable<IEnumerable<DuplicateCandidateGroup>>();
ExecuteCommand = new RelayCommand(Execute, CanExecute);
}
示例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);
}
示例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);
}
}
示例10: SettingsMenu
public SettingsMenu(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
DisplayName = Observable("DisplayName", "Settings");
Volume = Observable("Volume", .25f);
}
示例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();
}
示例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();
}
示例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);
});
}
示例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));
}
示例15: ValidValueShouldNotResultInAnyValidationErrors
public void ValidValueShouldNotResultInAnyValidationErrors()
{
var observable = new Observable<int>();
observable.Error.ShouldBe(string.Empty);
observable["Value"].ShouldBe(string.Empty);
}