Ejemplo n.º 1
0
 private static void RegisterEntryPointControllerDescriptionBuilder(this IComponentProvider container, Url entryPoint)
 {
     container.Register<IHttpControllerDescriptionBuilder, EntryPointControllerDescriptionBuilder>(
         entryPoint.ToString().Substring(1),
         () => new EntryPointControllerDescriptionBuilder(entryPoint, container.Resolve<IDefaultValueRelationSelector>()),
         Lifestyles.Singleton);
 }
Ejemplo n.º 2
0
 public async Task<Instrument> GetInstrument (Url<Instrument> instrumentUrl)
 {
     Instrument instrument = null;
     if (!_instrumentKeyToIntrument.TryGetValue(instrumentUrl.ToString(), out instrument))
     {
         instrument = await _client.DownloadInstrument(instrumentUrl);
         addInstrument(instrument);
     }
     return instrument;
 }
Ejemplo n.º 3
0
        public void it_can_create_with_a_host()
        {
            // Arrange
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, DEFAULT_PORT.ToString());

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(DEFAULT_PORT, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
        }
Ejemplo n.º 4
0
        public void it_can_create_with_a_host_and_port()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, port.ToString());

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(port, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
        }
Ejemplo n.º 5
0
        public void it_can_create_with_a_host_and_port_and_database()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote?edgemart={2}", SERVER_NAME, port.ToString(), EDGEMART_NAME);

            // Act
            var url = new Url(connectionString);

            // Assert
            Assert.AreEqual(connectionString, url.ToString());
            Assert.AreEqual(port, url.Server.Port);
            Assert.AreEqual(SERVER_NAME, url.Server.Host);
            Assert.AreEqual(EDGEMART_NAME, url.EdgeMartName);
        }
        /// <summary>
        /// Generates a cache key from the supplied Request
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public string Get(Request request)
        {
            if (request == null || request.Url == null)
                return string.Empty;

            var query = new Dictionary<string, string>();

            if (request.Query is DynamicDictionary)
            {
                var dynDict = (request.Query as DynamicDictionary);
                foreach (var key in dynDict.Keys)
                {
                    query[key] = (string)dynDict[key];
                }
            }

            if (request.Form is DynamicDictionary)
            {
                var dynDict = (request.Form as DynamicDictionary);
                foreach (var key in dynDict.Keys)
                {
                    query[key] = (string)dynDict[key];
                }
            }

            var removeParamKeys = query.Where(a => !_varyParams.Contains(a.Key.Replace("?", "").ToLower())).Select(a => a.Key).ToArray();
            foreach (var removeParamKey in removeParamKeys)
                query.Remove(removeParamKey);

            var url = new Url
            {
                BasePath = request.Url.BasePath,
                Fragment = request.Url.Fragment,
                HostName = request.Url.HostName,
                Path = request.Url.Path,
                Port = request.Url.Port,
                Query = (query.Count > 0 ? "?" : string.Empty) + string.Join("&", query.Select(a => string.Join("=", a.Key, a.Value))),
                Scheme = request.Url.Scheme,
            };

            return url.ToString();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Get a page reference from the url
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static int GetReferenceFromUrl(Url url)
 {
     if (url != null)
     {
         var reference = UrlResolver.Current.Route(new UrlBuilder(url.ToString()));
         if (reference != null && reference.ContentLink.ID > 0)
         {
             return reference.ContentLink.ID;
         }
     }
     return -1;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Get a page reference from the url
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static int GetReferenceFromUrl(Url url)
 {
     if (url != null)
     {
         var reference = PermanentLinkUtility.GetContentReference(new UrlBuilder(url.ToString()));
         if (reference != null && reference.ID > 0)
         {
             return reference.ID;
         }
     }
     return -1;
 }
Ejemplo n.º 9
0
 public Task<string> GetSymbol (Url<Instrument> instrumentUrl)
 {
     return this.GetSymbol(instrumentUrl.ToString());
 }
Ejemplo n.º 10
0
 public void Should_Not_Add_Equals_Without_Value()
 {
     var url = new Url("http://example.com?123456");
     Assert.AreEqual("http://example.com?123456", url.ToString());
 }
		/// <summary>
		/// Formats the uri.
		/// </summary>
		/// <param name="url"></param>
		/// <returns></returns>
		protected static string FormatUri(Url url)
		{
			// validate arguments
			if (url == null)
				throw new ArgumentNullException("url");

			return url.ToString().Trim(Dispatcher.Constants.UrlPartTrimCharacters) + '/';
		}
Ejemplo n.º 12
0
		public void encodes_plus() {
			var url = new Url("http://www.mysite.com").SetQueryParam("x", "1+2");
			Assert.AreEqual("http://www.mysite.com?x=1%2B2", url.ToString());
		}
Ejemplo n.º 13
0
		public void can_encode_space_as_plus() {
			var url = new Url("http://www.mysite.com/foo+bar?x=1+2");
			Assert.AreEqual("http://www.mysite.com/foo+bar?x=1+2", url.ToString(true));
		}
Ejemplo n.º 14
0
		public void interprets_plus_as_space() {
			var url = new Url("http://www.mysite.com/foo+bar?x=1+2");
			Assert.AreEqual("1 2", url.QueryParams["x"]);
			// encode + in query string but not path segment
			Assert.AreEqual("http://www.mysite.com/foo+bar?x=1%202", url.ToString());
		}