public void TestDeserializeWithEnglishUsCulture() { IStringSerializer serializer = New <IStringSerializer>(); string json = "{\r\n \"messageCulture\": \"en-US\",\r\n \"customMessage\": \"A message\"\r\n}".Replace("\r\n", Environment.NewLine); CustomMessageParameters parameters = serializer.Deserialize <CustomMessageParameters>(json); Assert.That(parameters.MessageCulture.ToString(), Is.EqualTo("en-US")); Assert.That(parameters.CustomMessage, Is.EqualTo("A message")); }
public void TestCrossFrameworkPclCultureInfoSerialization() { IStringSerializer serializer = New <IStringSerializer>(); CustomMessageParameters parameters; string json; parameters = new CustomMessageParameters(CultureInfo.CreateSpecificCulture("en-US"), "A message"); json = serializer.Serialize(parameters.MessageCulture); Assert.That(json, Is.EqualTo("\"en-US\"")); }
public void TestSerializeWithEnglishUsCulture() { IStringSerializer serializer = New <IStringSerializer>(); CustomMessageParameters parameters; string json; parameters = new CustomMessageParameters(CultureInfo.CreateSpecificCulture("en-US"), "A message"); json = serializer.Serialize(parameters); Assert.That(json, Is.EqualTo("{\r\n \"messageCulture\": \"en-US\",\r\n \"customMessage\": \"A message\"\r\n}".Replace("\r\n", Environment.NewLine))); }
public void TestSerializeWithNullCulture() { IStringSerializer serializer = New <IStringSerializer>(); CustomMessageParameters parameters; string json; parameters = new CustomMessageParameters(null, "A message"); json = serializer.Serialize(parameters); Assert.That(json, Is.EqualTo("{\r\n \"messageCulture\": null,\r\n \"customMessage\": \"A message\"\r\n}".Replace("\r\n", Environment.NewLine))); }
public static async Task <UserPublicKey> GetAsync(this KnownPublicKeys knownPublicKeys, EmailAddress email, LogOnIdentity identity) { UserPublicKey key = knownPublicKeys.PublicKeys.FirstOrDefault(upk => upk.Email == email); if (key != null && New <UserPublicKeyUpdateStatus>().Status(key) == PublicKeyUpdateStatus.RecentlyUpdated) { return(key); } if (New <AxCryptOnlineState>().IsOffline) { return(key); } if (identity == LogOnIdentity.Empty || identity.UserEmail == EmailAddress.Empty) { return(key); } IAccountService accountService = New <LogOnIdentity, IAccountService>(identity); if (await accountService.IsAccountSourceLocalAsync()) { return(key); } if (!New <LicensePolicy>().Capabilities.Has(LicenseCapability.KeySharing) && email != _licenseAuthorityEmail) { return(key); } AccountStorage accountStorage = new AccountStorage(New <LogOnIdentity, IAccountService>(identity)); CustomMessageParameters invitationMessageParameters = new CustomMessageParameters(new CultureInfo(New <UserSettings>().MessageCulture), New <UserSettings>().CustomInvitationMessage); UserPublicKey userPublicKey = await accountStorage.GetOtherUserInvitePublicKeyAsync(email, invitationMessageParameters).Free(); if (userPublicKey != null) { knownPublicKeys.AddOrReplace(userPublicKey); New <UserPublicKeyUpdateStatus>().SetStatus(userPublicKey, PublicKeyUpdateStatus.RecentlyUpdated); } return(userPublicKey); }
public async Task <UserPublicKey> OtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return((await _apiClient.PostAllAccountsOtherUserInvitePublicKeyAsync(email.Address, customParameters).Free()).ToUserPublicKey()); }
/// <summary> /// Gets the public key of any user. If the user does not exist, he or she is invited by the current user. /// The invitation is customized with the selected language/culture and personalized message. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="customParameters">The message custom parameters.</param> /// <returns></returns> public async Task <AccountKey> PostAllAccountsOtherUserInvitePublicKeyAsync(string userName, CustomMessageParameters customParameters) { if (userName == null) { throw new ArgumentNullException(nameof(userName)); } Uri resource = BaseUrl.PathCombine("users/all/accounts/invite/{0}/key".With(ApiCaller.PathSegmentEncode(userName))); RestContent content = new RestContent(Serializer.Serialize(customParameters)); RestResponse restResponse = await Caller.RestAsync(Identity, new RestRequest("POST", resource, Timeout, content)).Free(); ApiCaller.EnsureStatusOk(restResponse); AccountKey accountKey = Serializer.Deserialize <AccountKey>(restResponse.Content); return(accountKey); }
public async Task <UserPublicKey> OtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return(await OtherPublicKeyAsync(email)); }
public async Task <UserPublicKey> OtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return(await New <ICache>().GetItemAsync(_key.Subkey(email.Address).Subkey(nameof(OtherUserInvitePublicKeyAsync)), async() => await _service.OtherUserInvitePublicKeyAsync(email, customParameters)).Free()); }
public async Task <UserPublicKey> OtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return(await OtherUserPublicKeysAsync(() => _localService.OtherUserInvitePublicKeyAsync(email, null), () => _remoteService.OtherUserInvitePublicKeyAsync(email, customParameters)).Free()); }
public Task <UserPublicKey> OtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return(Task.FromResult((UserPublicKey)null)); }
public async Task <UserPublicKey> GetOtherUserInvitePublicKeyAsync(EmailAddress email, CustomMessageParameters customParameters) { return(await _service.OtherUserInvitePublicKeyAsync(email, customParameters).Free()); }