Example #1
0
        /// <summary>
        /// Return a url for this item within a specific context, github, rest.
        /// </summary>
        /// <returns>The URL</returns>
        /// <param name="urlType">URL type.</param>
        public string GetUrl(urltypes urlType, params object[] parameters)
        {
            if (urlType == urltypes.YouTube)
            {
                int index = 0;

                if (parameters.Length > 0)
                {
                    index = Mathf.Max(0, (int)parameters[0]);
                }


                Hashtable metaData = (Hashtable)RawData["metaData"];
                if (metaData != null)
                {
                    ArrayList _list = (ArrayList)metaData["YoutubeVideos"];
                    if (_list != null && _list.Count > index)
                    {
                        return((string)_list[index]);
                    }
                }
                return(null);
            }


            string    itemPath        = (string)RawData["path"];
            Hashtable rep             = (Hashtable)RawData["repository"];
            string    repositoryPath  = (string)rep["full_name"];
            string    itemPathEscaped = itemPath.Replace(" ", "%20");


            switch (urlType)
            {
            case urltypes.RestDownload:
                string url = EcosystemBrowser.__REST_URL_BASE__ + "download?repository=" + Uri.EscapeDataString(repositoryPath) + "&file=" + Uri.EscapeDataString(itemPathEscaped);

                RawData["RepositoryRawUrl"] = url;

                return(url);

            case urltypes.GithubRaw:
                return("https://raw.github.com/" + repositoryPath + "/master/" + itemPathEscaped);

            case urltypes.GithubPreview:
                return("https://github.com/" + repositoryPath + "/blob/master/" + itemPathEscaped);
            }

            return(null);
        }
		/// <summary>
		/// Return a url for this item within a specific context, github, rest.
		/// </summary>
		/// <returns>The URL</returns>
		/// <param name="urlType">URL type.</param>
		public string GetUrl(urltypes urlType,params object[] parameters)
		{

			if (urlType == urltypes.YouTube)
			{
				int index = 0;

				if (parameters.Length>0)
				{
					index = Mathf.Max(0,(int)parameters[0]);
				}


				Hashtable metaData = (Hashtable)RawData["metaData"];
				if (metaData!=null)
				{
					ArrayList _list = (ArrayList)metaData["YoutubeVideos"];
					if (_list!=null && _list.Count>index)
						return (string)_list[index];
				}
				return null;
			}



			string itemPath = (string)RawData["path"];
			Hashtable rep = (Hashtable)RawData["repository"];



			if (_RepositoryType == RepositoryTypes.Github)
			{
				string itemPathEscaped = itemPath.Replace(" ","%20");
				string repositoryPath = (string)rep["full_name"];

				switch (urlType)
				{
				case urltypes.RestDownload:
					string url = EcosystemBrowser.__REST_URL_BASE__ +"download?type=Github&repository="+ Uri.EscapeDataString(repositoryPath)+"&file="+ Uri.EscapeDataString(itemPathEscaped);
					
					RawData["RepositoryRawUrl"] = url;
					
					return url;
					
				case urltypes.Raw:
					return "https://raw.github.com/"+ repositoryPath+"/master/"+ itemPathEscaped;
					
				case urltypes.Preview:
					return "https://github.com/"+ repositoryPath+"/blob/master/"+ itemPathEscaped;
				}


			}else if (_RepositoryType == RepositoryTypes.Snipt)
			{
				switch (urlType)
				{
				case urltypes.RestDownload:
					string url = EcosystemBrowser.__REST_URL_BASE__ +"download?type=Snipt&url="+ Uri.EscapeDataString((string)rep["raw_url"])+"&slug="+ Uri.EscapeDataString((string)RawData["slug"]);
					
					RawData["RepositoryRawUrl"] = url;
					
					return url;
					
				case urltypes.Raw:
					return (string)rep["raw_url"];
					
				case urltypes.Preview:
					return (string)rep["preview_url"];
				}
			}




		
			return null;
		}