/// <inheritdoc/> public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom) { base.ShowInView(htmlView, variables, redirectedFrom); IStoryBoardService storyBoardService = Ioc.GetOrCreate <IStoryBoardService>(); SerializeableCloudStorageCredentials credentials = storyBoardService.ActiveStory.LoadFromSession <SerializeableCloudStorageCredentials>(SynchronizationStorySessionKey.CloudStorageCredentials); _viewModel = new CloudStorageAccountViewModel( Ioc.GetOrCreate <INavigationService>(), Ioc.GetOrCreate <ILanguageService>(), Ioc.GetOrCreate <ISvgIconService>(), Ioc.GetOrCreate <IThemeService>(), Ioc.GetOrCreate <IBaseUrlService>(), storyBoardService, Ioc.GetOrCreate <IFeedbackService>(), Ioc.GetOrCreate <ICloudStorageClientFactory>(), credentials); Bindings.BindCommand("GoBack", _viewModel.GoBackCommand); Bindings.BindCommand("OkCommand", _viewModel.OkCommand); Bindings.BindCommand("CancelCommand", _viewModel.CancelCommand); Bindings.BindText("Url", null, (v) => _viewModel.Url = v, null, null, HtmlViewBindingMode.OneWayToViewmodel); Bindings.BindText("Username", null, (v) => _viewModel.Username = v, null, null, HtmlViewBindingMode.OneWayToViewmodel); Bindings.BindText("Password", () => SecureStringExtensions.SecureStringToString(_viewModel.Password), (v) => _viewModel.Password = SecureStringExtensions.StringToSecureString(v), _viewModel, nameof(_viewModel.Password), HtmlViewBindingMode.TwoWayPlusOneTimeToView); Bindings.BindCheckbox("Secure", null, (v) => _viewModel.Secure = v, null, null, HtmlViewBindingMode.OneWayToViewmodel); string html = _viewService.GenerateHtml(_viewModel); View.LoadHtml(html); }
public void CorrectlyConvertsUtf8BytesToSecureString() { byte[] candidate = Encoding.UTF8.GetBytes("lazy 🐢🖐🏿 doc."); SecureString result = SecureStringExtensions.BytesToSecureString(candidate, Encoding.UTF8); Assert.IsNotNull(result); Assert.AreEqual("lazy 🐢🖐🏿 doc.", SecureStringExtensions.SecureStringToString(result)); candidate = null; result = SecureStringExtensions.BytesToSecureString(candidate, Encoding.UTF8); Assert.IsNull(result); }
public void CorrectlyConvertsSecureStringToString() { SecureString secureCandidate = new SecureString(); secureCandidate.AppendChar('F'); secureCandidate.AppendChar('o'); secureCandidate.AppendChar('x'); string retrievedCandidate = SecureStringExtensions.SecureStringToString(secureCandidate); Assert.AreEqual("Fox", retrievedCandidate); secureCandidate = SecureStringExtensions.StringToSecureString(null); Assert.IsNull(secureCandidate); }
public void CorrectlyConvertsStringToSecureString() { string candidate = "The brown fox jumps over the lazy 🐢🖐🏿 doc."; SecureString result = SecureStringExtensions.StringToSecureString(candidate); Assert.IsNotNull(result); Assert.AreEqual("The brown fox jumps over the lazy 🐢🖐🏿 doc.", SecureStringExtensions.SecureStringToString(result)); candidate = null; result = SecureStringExtensions.StringToSecureString(candidate); Assert.IsNull(result); candidate = string.Empty; result = SecureStringExtensions.StringToSecureString(candidate); Assert.AreEqual(0, result.Length); }
internal bool TryFormatForView(VueBindingDescription binding, object value, out string formattedValue) { PropertyInfo propertyInfo = _dotnetViewModel.GetType().GetProperty(binding.PropertyName); if (propertyInfo != null) { Type propertyType = propertyInfo.PropertyType; if (value == null) { formattedValue = "null"; return(true); } else if (propertyType == typeof(string)) { formattedValue = "'" + WebviewUtils.EscapeJavaScriptString(value.ToString()) + "'"; return(true); } else if (typeof(IEnumerable <string>).IsAssignableFrom(propertyType)) { IEnumerable <string> valueList = (IEnumerable <string>)value; formattedValue = string.Join( ",", valueList.Select(v => "'" + WebviewUtils.EscapeJavaScriptString(v) + "'")); formattedValue = "[" + formattedValue + "]"; return(true); } else if (propertyType == typeof(bool)) { formattedValue = value.ToString().ToLowerInvariant(); return(true); } else if (propertyType == typeof(int)) { formattedValue = value.ToString(); return(true); } else if (propertyType == typeof(SecureString)) { // HTML doesn't know the concept of a SecureString, so this is the moment we have to switch. string unprotectedValue = SecureStringExtensions.SecureStringToString((SecureString)value); formattedValue = "'" + WebviewUtils.EscapeJavaScriptString(unprotectedValue) + "'"; return(true); } } formattedValue = null; return(false); }