Esempio n. 1
0
        private async void GoLive(IWebViewComponent viewControl)
        {
            if (Mode != ApplicationMode.Dev)
            {
                return;
            }

            var resourceLoader = new ResourceReader("SetUp.script", this);
            var createOverlay  = resourceLoader.Load("loading.js");

            viewControl.ExecuteJavascript(createOverlay);

            var updateOverlay = resourceLoader.Load("update.js");
            var messageCount  = 0;

            void OnNpmLog(string information)
            {
                if (messageCount++ < 2)
                {
                    return;
                }

                var text = JavascriptNamer.GetCreateExpression(information);
                var code = updateOverlay.Replace("{information}", text);

                viewControl.ExecuteJavascript(code);
            }

            UpdateSetUp(await _Builder.BuildFromMode(ApplicationMode.Live, OnNpmLog));
            await viewControl.SwitchViewAsync(Uri);
        }
Esempio n. 2
0
        public override string ToString()
        {
            if (CValue == null)
            {
                return("null");
            }

            if (CValue is string)
            {
                return(JavascriptNamer.GetCreateExpressionDoubleQuote((string)CValue));
            }

            object unBoxed = CValue;

            if (unBoxed is DateTime)
            {
                var dt = (DateTime)unBoxed;
                return($@"""{dt.Year:0000}-{dt.Month:00}-{dt.Day:00}T{dt.Hour:00}:{dt.Minute:00}:{dt.Second:00}.{dt.Millisecond:000}Z""");
            }

            if (unBoxed is bool)
            {
                var boolValue = (bool)unBoxed;
                return($"{(boolValue ? "true" : "false")}");
            }

            return(CValue.ToString());
        }
Esempio n. 3
0
 private static Action <string, string> GetDispatchAction(IWebView target, Func <string, string, string> codeBuilder)
 {
     return((channel, message) =>
     {
         var transformed = JavascriptNamer.GetCreateExpression(message);
         target.ExecuteJavaScript(codeBuilder($"'{channel}'", transformed));
     });
 }
Esempio n. 4
0
        private async Task DoGoLive(IWebViewComponent viewControl, CancellationToken token)
        {
            var resourceLoader = GetResourceReader();
            var updateOverlay  = resourceLoader.Load("update.js");

            void OnNpmLog(string information)
            {
                if (information == null)
                {
                    return;
                }

                var text = JavascriptNamer.GetCreateExpression(information);
                var code = updateOverlay.Replace("{information}", text);

                viewControl.ExecuteJavascript(code);
            }

            UpdateSetUp(await _Builder.BuildFromMode(ApplicationMode.Live, token, OnNpmLog));
        }
Esempio n. 5
0
        public override string ToString()
        {
            switch (CValue)
            {
            case null:
                return("null");

            case string stringValue:
                return(JavascriptNamer.GetCreateExpressionDoubleQuote(stringValue));
            }

            object unBoxed = CValue;

            switch (unBoxed)
            {
            case DateTime dt:
                return($@"""{dt.Year:0000}-{dt.Month:00}-{dt.Day:00}T{dt.Hour:00}:{dt.Minute:00}:{dt.Second:00}.{dt.Millisecond:000}Z""");

            case bool boolValue:
                return($"{(boolValue ? "true" : "false")}");
            }

            return(CValue.ToString());
        }
Esempio n. 6
0
 public string GetCreationCode() => JavascriptNamer.GetCreateDoubleString(TypedValue);
Esempio n. 7
0
        private IJavascriptObject Get(object @object)
        {
            var code = JavascriptNamer.GetCreateExpression(@object);

            return(Factory.CreateFromExcecutionCode(new[] { code }).Single());
        }
Esempio n. 8
0
 public override string ToString() => JavascriptNamer.GetCreateCharString(TypedValue);
Esempio n. 9
0
        public void GetCreateExpression_Returns_Correct_Information(string value, string expected)
        {
            var actual = JavascriptNamer.GetCreateExpression(value);

            actual.Should().Be(expected);
        }
Esempio n. 10
0
 public override string ToString() => JavascriptNamer.GetCreateExpressionDoubleQuote(TypedValue);
Esempio n. 11
0
 public string GetCreationCode() => JavascriptNamer.GetCreateExpression(TypedValue);
Esempio n. 12
0
 private string CreateStringValue(IEnumerable <object> from)
 {
     return($"[{string.Join(",", from.Select(v => JavascriptNamer.GetCreateExpression(v)))}]");
 }