Esempio n. 1
0
        public object Build(JavascriptAdapterOptions options)
        {
            dynamic model = new DynamicExpandoObject();

            model.LanguageId = 1;
            model.Api        = new
            {
                DefaultMethod = options.Api.DefaultMethod.ToString(),
                BaseUrl       = options.Api.BaseUrl,
                Protocol      = options.Api.BaseUrl.Scheme.ToString(),
                Host          = options.Api.BaseUrl.Host.ToString(),
                Port          = options.Api.BaseUrl.Port.ToString()
            };
            model.CurrentUrl = new
            {
                Method   = options.Method.ToString(),
                Protocol = options.CurrentUrl.Scheme.ToString(),
                Host     = options.CurrentUrl.Host.ToString(),
                Port     = options.CurrentUrl.Port.ToString(),
                Path     = !string.IsNullOrEmpty(options.CurrentUrl.Query)
                    ? options.CurrentUrl.PathAndQuery.Replace(options.CurrentUrl.Query, string.Empty).Replace("?", string.Empty)
                    : options.CurrentUrl.PathAndQuery.Replace("?", string.Empty),
                QueryString = options.CurrentUrl.Query,
                FullUrl     = options.CurrentUrl.ToString(),
                BaseUrl     = $"{options.CurrentUrl.Scheme}://{options.CurrentUrl.Host}:{options.CurrentUrl.Port}/"
            };

            return(string.Format("<script>var DigitalForgeOptions = {0}; </script>", JsonConvert.SerializeObject(model)));
        }
Esempio n. 2
0
        public object Build(ApplicationAdapterOption options)
        {
            dynamic model = new DynamicExpandoObject();

            model.ApplicationGuid = Guid.NewGuid().ToString();
            model.CurrentUrl      = new
            {
                Method   = options.Method.ToString(),
                Protocol = options.CurrentUrl.Scheme.ToString(),
                Host     = options.CurrentUrl.Host.ToString(),
                Port     = options.CurrentUrl.Port.ToString(),
                Path     = !string.IsNullOrEmpty(options.CurrentUrl.Query)
                    ? options.CurrentUrl.PathAndQuery.Replace(options.CurrentUrl.Query, string.Empty).Replace("?", string.Empty)
                    : options.CurrentUrl.PathAndQuery.Replace("?", string.Empty),
                QueryString = options.CurrentUrl.Query,
                FullUrl     = options.CurrentUrl.ToString(),
                BaseUrl     = $"{options.CurrentUrl.Scheme}://{options.CurrentUrl.Host}:{options.CurrentUrl.Port}/"
            };

            model.DigitalForgeJavascriptOptions = new JavascriptAdapter().Build(new JavascriptAdapterOptions
            {
                Method     = options.Method,
                CurrentUrl = options.CurrentUrl,
                Api        = new ApiOptions
                {
                    BaseUrl       = new Uri(model.CurrentUrl.BaseUrl),
                    DefaultMethod = options.Method
                }
            });

            return(model);
        }
Esempio n. 3
0
        public void TestIndex()
        {
            dynamic a = new DynamicExpandoObject();

            a[0, 0] = 222;

            Console.WriteLine(a[0, 0]);
        }
Esempio n. 4
0
        public void TestFromDynamic()
        {
            dynamic d = new DynamicExpandoObject();

            d.Name = "fireasy";

            var obj = (Data1)GenericExtension.To <Data1>(d);

            Assert.AreEqual("fireasy", obj.Name);
        }
Esempio n. 5
0
        protected virtual async Task <object> DoBuild(CancellationToken cancellationToken)
        {
            await Task.CompletedTask;

            var method = new HttpMethod(this.ControllerContext.HttpContext.Request.Method) ?? HttpMethod.Get;

            var model = new DynamicExpandoObject() as dynamic;

            model.DigitalForgeApplication = new ApplicationAdapter().Build(new ApplicationAdapterOption
            {
                Method     = method,
                CurrentUrl = this.GetUrl()
            });

            return(model);
        }