Пример #1
0
        public static void AssertClientConfiguration(AmazonServiceClient amazonServiceClient)
        {
            IClientConfig clientConfig = amazonServiceClient.Config;

            Assert.Equal($"http://{Constants.LocalStackHost}:{Constants.EdgePort}", clientConfig.ServiceURL);
            Assert.True(clientConfig.UseHttp);

            PropertyInfo forcePathStyleProperty = clientConfig.GetType().GetProperty("ForcePathStyle", BindingFlags.Public | BindingFlags.Instance);

            if (forcePathStyleProperty != null)
            {
                bool useForcePathStyle = forcePathStyleProperty.GetValue(clientConfig) is bool && (bool)forcePathStyleProperty.GetValue(clientConfig);
                Assert.True(useForcePathStyle);
            }

            Assert.Equal(Constants.LocalStackHost, clientConfig.ProxyHost);
            Assert.Equal(Constants.EdgePort, clientConfig.ProxyPort);
        }
Пример #2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var urlHelper = urlHelperFactory.GetUrlHelper(ViewContext);

            output.TagName = "script";
            output.Attributes.Add("type", "text/javascript");

            //Add the access token path in after getting its content url
            var jObj = JObject.FromObject(config);

            //Add the action path as the page base path
            var actionInfo = ViewContext.ActionDescriptor as ControllerActionDescriptor;

            if (actionInfo != null)
            {
                var valueDictionary = new Dictionary <String, Object>();
                if (options.RouteArgsToClear != null)
                {
                    foreach (var option in options.RouteArgsToClear)
                    {
                        valueDictionary.Add(option, "");
                    }
                }

                var urlActionContext = new UrlActionContext()
                {
                    Action     = actionInfo.ActionName,
                    Controller = actionInfo.ControllerName,
                    Values     = valueDictionary
                };

                jObj.Add("PageBasePath", urlHelper.Action(urlActionContext));
            }

            var request = ViewContext.HttpContext.Request;

            foreach (var prop in config.GetType().GetProperties().Where(i => i.GetCustomAttributes(typeof(ExpandHostPathAttribute), true).Any()))
            {
                var path = jObj[prop.Name]?.ToString();
                if (path.StartsWith("~/"))
                {
                    jObj[prop.Name] = $"https://{request.Host.Value}{urlHelper.Content(path)}";
                }
            }

            if (AddRunner)
            {
                var runnerName = RunnerName;
                if (runnerName == null)
                {
                    runnerName = Path.ChangeExtension(ViewContext.View.Path, null);
                    if (runnerName[0] == '/')
                    {
                        runnerName = runnerName.Substring(1);
                    }
                }
                output.Attributes.Add("data-hr-run", runnerName);
            }

            //Convert to html this way so we don't escape the settings object.
            var html = String.Format(content, jObj.ToString());

            output.Content.SetHtmlContent(html);
        }