Esempio n. 1
0
        /// <summary>
        /// Attempt to enable the channel by fetching intercept.json
        /// </summary>
        public bool TryInit()
        {
            InterceptChannel channel = null;
            if (InterceptChannel.TryCreate(_source, _cache, out channel))
            {
                _channel = channel;
                _initialized = true;
                return true;
            }

            return false;
        }
Esempio n. 2
0
        /// <summary>
        /// Attempt to enable the channel by fetching intercept.json
        /// </summary>
        public bool TryInit()
        {
            InterceptChannel channel = null;

            if (InterceptChannel.TryCreate(_source, _cache, out channel))
            {
                _channel     = channel;
                _initialized = true;
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public static bool TryCreate(string source, IShimCache cache, out InterceptChannel channel)
        {
            // create the interceptor from the intercept.json file. exper
            string interceptUrl = String.Format(CultureInfo.InvariantCulture, "{0}/intercept.json", source);

            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            var reqTask = client.GetAsync(interceptUrl);
            reqTask.Wait();
            HttpResponseMessage response = reqTask.Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var resTask = response.Content.ReadAsStringAsync();
                resTask.Wait();
                JObject obj = JObject.Parse(resTask.Result);

                channel = new InterceptChannel(source, obj, cache);
                return true;
            }

            channel = null;
            return false;
        }
Esempio n. 4
0
        public static bool TryCreate(string source, IShimCache cache, out InterceptChannel channel)
        {
            // create the interceptor from the intercept.json file. exper
            string interceptUrl = String.Format(CultureInfo.InvariantCulture, "{0}/intercept.json", source);

            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            var reqTask = client.GetAsync(interceptUrl);

            reqTask.Wait();
            HttpResponseMessage response = reqTask.Result;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var resTask = response.Content.ReadAsStringAsync();
                resTask.Wait();
                JObject obj = JObject.Parse(resTask.Result);

                channel = new InterceptChannel(source, obj, cache);
                return(true);
            }

            channel = null;
            return(false);
        }