Exemple #1
0
        public string GetProxy(bool noAuthenticated = false, bool forceClearPassword = false, bool ignoreDomain = false)
        {
            System.UriBuilder builder = new System.UriBuilder();

            // host
            builder.Host = UserData.ProxyHost;

            // port
            if (!string.IsNullOrEmpty(UserData.ProxyPort))
            {
                builder.Port = int.Parse(UserData.ProxyPort);
            }
            else
            {
                builder.Port = -1;
            }

            if (!noAuthenticated)
            {
                builder.UserName = GetProxyUsername();
                builder.Password = GetProxyPassword(forceClearPassword);
            }

            return(builder.ToString());
        }
Exemple #2
0
        public static HtmlBuilder CopyDirectUrlToClipboard(this HtmlBuilder hb, SiteSettings ss)
        {
            var queryString = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query);
            var view        = (HttpContext.Current.Session["View" + ss.SiteId] as View)?.ToJson();

            if (!view.IsNullOrEmpty())
            {
                queryString["View"] = view;
            }
            var directUrl = new System.UriBuilder(HttpContext.Current.Request.Url.AbsoluteUri)
            {
                Query = queryString.ToString()
            }.ToString();

            return(hb.Div(
                       attributes: new HtmlAttributes()
                       .Id("CopyToClipboards"),
                       action: () => hb
                       .Div(
                           attributes: new HtmlAttributes()
                           .Id("CopyDirectUrlToClipboard")
                           .Class("display-control")
                           .OnClick("$p.copyDirectUrlToClipboard('" + directUrl + "');"),
                           action: () => hb
                           .Span(css: "ui-icon ui-icon-link")
                           .Text(text: ""))));
        }
Exemple #3
0
        /// <summary>
        /// OAuth認証のリクエストトークン取得。リクエストトークンと組み合わせた認証用のUriも生成する
        /// </summary>
        /// <param name="requestTokenUrl">リクエストトークンの取得先URL</param>
        /// <param name="authorizeUrl">ブラウザで開く認証用URLのベース</param>
        /// <param name="requestToken">[OUT]取得したリクエストトークン</param>
        /// <returns>取得結果真偽値</returns>
        private Uri GetAuthenticatePageUri(string requestTokenUrl, string authorizeUrl, ref string requestToken)
        {
            const string tokenKey = "oauth_token";

            // リクエストトークン取得
            string content = "";
            NameValueCollection reqTokenData;

            if (this.GetOAuthToken(new Uri(requestTokenUrl), "", "", null, ref content, callbackUrl: "oob") != HttpStatusCode.OK)
            {
                return(null);
            }
            reqTokenData = base.ParseQueryString(content);

            if (reqTokenData != null)
            {
                requestToken = reqTokenData[tokenKey];
                // Uri生成
                UriBuilder ub = new UriBuilder(authorizeUrl);
                ub.Query = string.Format("{0}={1}", tokenKey, requestToken);
                return(ub.Uri);
            }
            else
            {
                return(null);
            }
        }
 internal void Connect(string Name)
 {
     _Name = Name;
     System.UriBuilder TestServerUri = new System.UriBuilder("ws", "localhost", 27418, "game");
     Debug.Log(TestServerUri.Uri.ToString());
     conn.Connect(TestServerUri.Uri);
 }
 public static string GetAssemblyDirectory(System.Reflection.Assembly ass)
 {
     string codeBase = ass.CodeBase;
     System.UriBuilder uri = new System.UriBuilder(codeBase);
     string path = System.Uri.UnescapeDataString(uri.Path);
     //return System.IO.Path.GetDirectoryName(path);
     return path;
 }
        static void Main(string[] args)
        {
            // Create a request to get the capabilities document from the server.
            System.UriBuilder serverUri =
                new System.UriBuilder(@"http://viz.globe.gov/viz-bin/wmt.cgi");
            Wms.Client.CapabilitiesRequestBuilder capsRequest =
                new Wms.Client.CapabilitiesRequestBuilder(serverUri.Uri);

            // Retrieve the capabilities document and cache it locally.
            System.Net.WebRequest wr = System.Net.WebRequest.Create(capsRequest.Uri);

            // Handle any proxy the system may have defined.
            System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
            if (proxy.Address != null)
            {
                wr.Proxy = proxy;
            }

            System.Net.WebResponse response = wr.GetResponse();
            string fileName = System.IO.Path.GetTempPath() + @"capabilities.xml";

            copyStreamToFile(response.GetResponseStream(), fileName);

            // Parse the capabilities document and create a capabilities object
            // for reading the parsed information. This is done by creating a Server
            // object to represent the server associated with the capabilities.
            Wms.Client.Server       server = new Wms.Client.Server(fileName);
            Wms.Client.Capabilities caps   = server.Capabilities;

            // Create a GetMap request using the MapRequestBuilder class. When
            // creating the request, use the URI given in the server's capabilities
            // document. This URI may be different than the one used to get the
            // capabilities document.
            Wms.Client.MapRequestBuilder mapRequest =
                new Wms.Client.MapRequestBuilder(new System.Uri(caps.GetMapRequestUri));
            mapRequest.Layers      = "COASTLINES,RATMIN";
            mapRequest.Styles      = ",";        // use default style for each layer
            mapRequest.Format      = "image/gif";
            mapRequest.Srs         = "EPSG:4326";
            mapRequest.BoundingBox = "-180.0,-90.0,180.0,90.0";
            mapRequest.Height      = 300;
            mapRequest.Width       = 600;
            mapRequest.Transparent = false;

            // Retrieve the map and cache it locally.
            System.Net.WebRequest mwr = System.Net.WebRequest.Create(mapRequest.Uri);
            if (proxy.Address != null)
            {
                mwr.Proxy = proxy;
            }
            System.Net.WebResponse mresponse = mwr.GetResponse();
            string mapFileName = System.IO.Path.GetTempPath() + @"wmsmap.gif";

            copyStreamToFile(mresponse.GetResponseStream(), mapFileName);

            // Use Internet Explorer to display the map.
            invokeIe(mapFileName);
        }
        public static string GetAssemblyDirectory(System.Reflection.Assembly ass)
        {
            string codeBase = ass.CodeBase;

            System.UriBuilder uri  = new System.UriBuilder(codeBase);
            string            path = System.Uri.UnescapeDataString(uri.Path);

            //return System.IO.Path.GetDirectoryName(path);
            return(path);
        } // End Function GetAssemblyDirectory
Exemple #8
0
        void Clone()
        {
            Init();

            System.Uri        uri     = new System.Uri(url);
            System.UriBuilder builder = new System.UriBuilder(uri);
            builder.UserName = username;
            builder.Password = password;

            bashProcess = initProcess("remote add --track master origin " + builder.Uri);
            bashProcess = initProcess("pull -q");
        }
Exemple #9
0
        private static System.Uri GetUri(Microsoft.AspNetCore.Http.HttpRequest request)
        {
            System.UriBuilder uriBuilder = new System.UriBuilder();
            uriBuilder.Scheme = request.Scheme;
            uriBuilder.Host   = request.Host.Host;

            if (request.Host.Port.HasValue)
            {
                uriBuilder.Port = request.Host.Port.Value;
            }

            uriBuilder.Path  = request.Path.ToString();
            uriBuilder.Query = request.QueryString.ToString();
            return(uriBuilder.Uri);
        } // End Function GetUri
Exemple #10
0
        public static tCLIFile *WrapMonoAssembly(/*char**/ byte *pAssemblyName)
        {
            tCLIFile *    pRet;
            tFilesLoaded *pNewFile;
            tMetaData *   pMetaData;

            System.Reflection.Assembly assembly = null;

            string assemblyName = Marshal.PtrToStringAnsi((System.IntPtr)pAssemblyName);

            System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
            for (int i = 0; i < assemblies.Length; i++)
            {
                System.Reflection.Assembly assem = assemblies[i];
                if (assem.GetName().Name == assemblyName)
                {
                    assembly = assem;
                    break;
                }
            }

            if (assembly == null)
            {
                Sys.Crash("Unable to load assembly file %s", (PTR)pAssemblyName);
            }

            pRet = ((tCLIFile *)Mem.malloc((SIZE_T)sizeof(tCLIFile)));
            Mem.memset(pRet, 0, (SIZE_T)sizeof(tCLIFile));

            pRet->pMetaData = pMetaData = MetaData.New();
            MetaData.WrapMonoAssembly(pMetaData, assembly);

            string codeBase = assembly.CodeBase;

            System.UriBuilder uri      = new System.UriBuilder(codeBase);
            string            path     = System.Uri.UnescapeDataString(uri.Path);
            string            assmName = System.IO.Path.GetFileNameWithoutExtension(path);

            pRet->assemblyName = new S(assmName);

            // Record that we've loaded this file
            pNewFile           = ((tFilesLoaded *)Mem.mallocForever((SIZE_T)sizeof(tFilesLoaded)));
            pNewFile->pCLIFile = pRet;
            pNewFile->pNext    = pFilesLoaded;
            pFilesLoaded       = pNewFile;

            return(pRet);
        }
Exemple #11
0
        public static string LocalPath()
        {
            var request    = AspNetCoreHttpContext.Current.Request;
            var uriBuilder = new System.UriBuilder();

            uriBuilder.Scheme = request.Scheme;
            uriBuilder.Host   = request.Host.Host;
            if (request.Host.Port.HasValue)
            {
                uriBuilder.Port = request.Host.Port.Value;
            }
            uriBuilder.Path  = request.Path.ToString();
            uriBuilder.Query = request.QueryString.ToString();
            var uri = uriBuilder.Uri.LocalPath;

            return(uri);
        }
Exemple #12
0
        protected override TenantIdentifier GetTenantDistinguisher(HttpContextBase context)
        {
            var uri = context.Request.GetUri();

            //var authorityUriString = new StringBuilder(uri.ToString().Length)
            //    .Append(uri.Scheme)
            //    .Append(SchemeDelimiter)
            //    .Append(uri.Host)
            //    //.Append(uri.PathAndQuery)
            //    //.Append(queryString)
            //    .ToString();

            var authorityUriBuilder = new System.UriBuilder(uri);

            authorityUriBuilder.Path  = null;
            authorityUriBuilder.Query = null;
            return(new TenantIdentifier(authorityUriBuilder.Uri));
        }
Exemple #13
0
        public void buildurlsz()
        {
            string imageVirtualPath = System.IO.Path.Combine("imageFolder", "blog.UniqueName", "fileName");

            Microsoft.AspNetCore.Http.HttpRequest request = HttpContext.Request;
            System.UriBuilder uriBuilder = new System.UriBuilder
            {
                Host   = request.Host.Host,
                Scheme = request.Scheme,
                Path   = imageVirtualPath
            };

            if (request.Host.Port.HasValue)
            {
                uriBuilder.Port = request.Host.Port.Value;
            }

            string url = uriBuilder.ToString();
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var canAcess = false;

            var referer = filterContext.HttpContext.Request.Headers["Referer"].ToString();

            if (!string.IsNullOrEmpty(referer))
            {
                var rUri = new System.UriBuilder(referer).Uri;
                var req  = filterContext.HttpContext.Request;
                if (req.Host.Host == rUri.Host && req.Host.Port == rUri.Port && req.Scheme == rUri.Scheme)
                {
                    canAcess = true;
                }
            }

            if (!canAcess)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Home", action = "Index", area = "" }));
            }
        }
        public async System.Threading.Tasks.Task <System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.IEventListener callback, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Runtime.ISendAsync next)
        {
            string search   = "Search=";
            string splitter = "&";
            string query    = request.RequestUri.Query;
            int    start    = query.IndexOf(search, System.StringComparison.OrdinalIgnoreCase);
            int    end      = 0;

            if (start >= 0 && query.Length > start + search.Length - 1)
            {
                start += search.Length;

                end = query.IndexOf(splitter, start, System.StringComparison.OrdinalIgnoreCase);
                if (start == end)
                {
                    return(await next.SendAsync(request, callback));
                }
                if (end == -1)
                {
                    end = query.Length;
                }
                search = query.Substring(start, end - start);
                //Remove " in search query
                search = System.Text.RegularExpressions.Regex.Replace(search, "^%22|%22$", "");

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(query.Substring(0, start));
                sb.Append("\"");
                sb.Append(search);
                sb.Append("\"");
                sb.Append(query.Substring(end));
                System.UriBuilder ub = new System.UriBuilder(request.RequestUri);
                ub.Query           = sb.ToString();
                request.RequestUri = ub.Uri;
            }

            return(await next.SendAsync(request, callback));
        }
        static void Main(string[] args)
        {
            System.UriBuilder uri = new System.UriBuilder(@"http://viz.globe.gov/viz-bin/wmt.cgi");
            uri.Query = "SERVICE=WMS&REQUEST=GetCapabilities";
            System.Net.WebRequest wr = System.Net.WebRequest.Create(uri.Uri);

            // Handle any proxy the system may have defined.
            System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
            if (proxy.Address != null)
            {
                wr.Proxy = proxy;
            }

            System.Net.WebResponse response = wr.GetResponse();
            System.IO.StreamReader sr       = new System.IO.StreamReader(response.GetResponseStream());
            string fileName = System.IO.Path.GetTempPath() + @"capabilities.xml";

            System.IO.StreamWriter sw = System.IO.File.CreateText(fileName);
            sw.Write(sr.ReadToEnd());
            sr.Close();
            sw.Close();
            invokeIe(fileName);
        }
Exemple #17
0
        } // End Function ToAwsString

        public static string ModifyUrl(string url)
        {
            System.Collections.Specialized.NameValueCollection originalQuery = System.Web.HttpUtility.ParseQueryString(new System.Uri(url).Query);
            System.Uri        uri     = new System.Uri(originalQuery["path"].Replace("$amp$", "&"));
            System.UriBuilder builder = new System.UriBuilder(uri);

            System.Collections.Specialized.NameValueCollection nameValues = System.Web.HttpUtility.ParseQueryString(uri.Query); //.Get("param1");
            nameValues.Remove("uu");
            nameValues.Remove("F");
            nameValues.Remove("dx");
            nameValues.Remove("dy");


            // string projname = "COR_Demo_Portal";
            string projname = nameValues["p"];
            // string d = "0001_GB01_OG14_0000";
            string d = nameValues["d"];


            ApertureBounds apb = GetBounds(d, projname);

            System.Console.WriteLine(apb);

            nameValues["xul"] = apb.XUL.ToString();
            nameValues["yul"] = apb.YUL.ToString();

            nameValues["xlr"] = apb.XLR.ToString();
            nameValues["ylr"] = apb.YLR.ToString();

            builder.Query = nameValues.ToString();
            System.Uri result = builder.Uri;
            string     newUrl = result.OriginalString;

            newUrl = newUrl.Replace(":80/", "/");

            return(newUrl);
        }
Exemple #18
0
        public static async Task <bool> downloadUpdate()
        {
            try {
                HttpClient http = new HttpClient();
                http.DefaultRequestHeaders.Add("User-Agent", "TheOtherRoles Updater");
                var response = await http.GetAsync(new System.Uri(updateURI), HttpCompletionOption.ResponseContentRead);

                if (response.StatusCode != HttpStatusCode.OK || response.Content == null)
                {
                    System.Console.WriteLine("Server returned no data: " + response.StatusCode.ToString());
                    return(false);
                }
                string            codeBase = Assembly.GetExecutingAssembly().CodeBase;
                System.UriBuilder uri      = new System.UriBuilder(codeBase);
                string            fullname = System.Uri.UnescapeDataString(uri.Path);
                if (File.Exists(fullname + ".old")) // Clear old file in case it wasnt;
                {
                    File.Delete(fullname + ".old");
                }

                File.Move(fullname, fullname + ".old"); // rename current executable to old

                using (var responseStream = await response.Content.ReadAsStreamAsync()) {
                    using (var fileStream = File.Create(fullname)) { // probably want to have proper name here
                        responseStream.CopyTo(fileStream);
                    }
                }
                showPopup(ModTranslation.getString("updateRestart"));
                return(true);
            } catch (System.Exception ex) {
                TheOtherRolesPlugin.Instance.Log.LogError(ex.ToString());
                System.Console.WriteLine(ex);
            }
            showPopup(ModTranslation.getString("updateFailed"));
            return(false);
        }
Exemple #19
0
 public static System.UriBuilder appendId(System.UriBuilder builder, long id)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// OAuth認証のリクエストトークン取得。リクエストトークンと組み合わせた認証用のUriも生成する
        /// </summary>
        /// <param name="accessTokenUrl">リクエストトークンの取得先URL</param>
        /// <param name="authorizeUrl">ブラウザで開く認証用URLのベース</param>
        /// <param name="requestToken">[OUT]取得したリクエストトークン</param>
        /// <returns>取得結果真偽値</returns>
        private Uri GetAuthenticatePageUri( string requestTokenUrl, string authorizeUrl, ref string requestToken )
        {
            const string tokenKey = "oauth_token";

            // リクエストトークン取得
            string content = "";
            NameValueCollection reqTokenData;
            if ( this.GetOAuthToken( new Uri( requestTokenUrl ), "", "", null, ref content) != HttpStatusCode.OK )
                return null;
            reqTokenData = base.ParseQueryString( content );

            if ( reqTokenData != null )
            {
                requestToken = reqTokenData[ tokenKey ];
                // Uri生成
                UriBuilder ub = new UriBuilder( authorizeUrl );
                ub.Query = string.Format( "{0}={1}", tokenKey, requestToken );
                return ub.Uri;
            }
            else
            {
                return null;
            }
        }
Exemple #21
0
        public override string ToString()
        {
            var stringBuilder = new StringBuilder();

            // Namespace
            stringBuilder.AppendLine("namespace Schema.NET");
            stringBuilder.AppendLine("{");

            // Using statements
            stringBuilder.AppendIndentLine(4, "using System.Runtime.Serialization;");
            stringBuilder.AppendIndentLine(4, "using Newtonsoft.Json;");
            stringBuilder.AppendIndentLine(4, "using Newtonsoft.Json.Converters;");
            stringBuilder.AppendLine();

            // Comment
            stringBuilder.AppendIndentLine(4, "/// <summary>");
            stringBuilder.AppendCommentLine(4, this.Description);
            stringBuilder.AppendIndentLine(4, "/// </summary>");

            // Enum
            stringBuilder.AppendIndentLine(4, $"[JsonConverter(typeof(StringEnumConverter))]");
            stringBuilder.AppendIndentLine(4, $"public enum {this.Name}");
            stringBuilder.AppendIndentLine(4, "{");

            // Values
            if (this.Values.Count > 0)
            {
                var i = 0;
                foreach (var value in this.Values)
                {
                    var isLast = i == (this.Values.Count - 1);

                    // Convert enumeration values to https for future proofing
                    // https://schema.org/docs/faq.html#19
                    // "Over time we will migrate the schema.org site itself towards using https:
                    //  as the default version of the site and our preferred form in examples."
                    var httpsValueUri = new System.UriBuilder(value.Uri)
                    {
                        Scheme = System.Uri.UriSchemeHttps,
                        Port   = value.Uri.IsDefaultPort ? -1 : value.Uri.Port // -1 => default port for scheme
                    }.Uri;

                    stringBuilder.AppendCommentSummary(8, value.Description);
                    stringBuilder.AppendIndentLine(8, $"[EnumMember(Value = \"{httpsValueUri}\")]");
                    stringBuilder.AppendIndent(8, value.Name);
                    if (!isLast)
                    {
                        stringBuilder.AppendLine(",");
                    }

                    stringBuilder.AppendLine();

                    ++i;
                }
            }

            stringBuilder.AppendIndentLine(4, "}");
            stringBuilder.AppendLine("}");

            return(stringBuilder.ToString());
        }
Exemple #22
0
 public RequestBuilder(System.Uri uri)
 {
     this.uri = new System.UriBuilder(uri.Scheme, uri.Host, uri.Port, uri.AbsolutePath);
     this.initializeParams();
     this.clientInfo = new System.Collections.Hashtable();
 }