private async Task GetPreferences(string nodeId) { var preferences = new PreferenceWrapper(this); var settings = new WearPreferences(preferences.DefaultCategory); var json = JsonConvert.SerializeObject(settings); var data = Encoding.UTF8.GetBytes(json); await WearableClass.GetMessageClient(this) .SendMessageAsync(nodeId, GetPreferencesCapability, data); }
private async Task GetSyncBundle(string nodeId) { await _authenticatorView.LoadFromPersistenceAsync(); var auths = new List <WearAuthenticator>(); var authCategories = await _authenticatorCategoryRepository.GetAllAsync(); foreach (var auth in _authenticatorView) { var bindings = authCategories .Where(c => c.AuthenticatorSecret == auth.Secret) .Select(c => new WearAuthenticatorCategory(c.CategoryId, c.Ranking)) .ToList(); var item = new WearAuthenticator( auth.Type, auth.Secret, auth.Icon, auth.Issuer, auth.Username, auth.Period, auth.Digits, auth.Algorithm, auth.Ranking, bindings); auths.Add(item); } var categories = (await _categoryRepository.GetAllAsync()).Select(c => new WearCategory(c.Id, c.Name)) .ToList(); var customIconIds = (await _customIconRepository.GetAllAsync()).Select(i => i.Id).ToList(); var preferenceWrapper = new PreferenceWrapper(this); var preferences = new WearPreferences( preferenceWrapper.DefaultCategory, preferenceWrapper.SortMode, preferenceWrapper.CodeGroupSize); var bundle = new WearSyncBundle(auths, categories, customIconIds, preferences); var json = JsonConvert.SerializeObject(bundle); var data = Encoding.UTF8.GetBytes(json); await WearableClass.GetMessageClient(this).SendMessageAsync(nodeId, GetSyncBundleCapability, data); }