public void Int_Center(uint id)
        {
            var pathString = $"/path/to/{id}/next";

            var options = new HttpRequestDurationsOptions {
                CustomNormalizePath = new Dictionary <Regex, string> {
                    { _intRegex, _intValue }
                }
            };

            var path = NormalizePath.Execute(pathString, options);

            Assert.Equal($"/path/to/id/next", path);
        }
        public void Int_Right_WithSlash(uint id) // ID - can't be less 0
        {
            var pathString = $"/path/to/{id}/";

            var options = new HttpRequestDurationsOptions {
                CustomNormalizePath = new Dictionary <Regex, string> {
                    { _intRegex, _intValue }
                }
            };

            var path = NormalizePath.Execute(pathString, options);

            Assert.Equal($"/path/to/id/", path);
        }
        public void Guid_Right_WithSlash(string guid)
        {
            var pathString = $"/path/to/{guid}/";

            var options = new HttpRequestDurationsOptions {
                CustomNormalizePath = new Dictionary <Regex, string> {
                    { _guidRegex, _guidValue }
                }
            };

            var path = NormalizePath.Execute(pathString, options);

            Assert.Equal($"/path/to/guid/", path);
        }
 /** 作成。すべて。
  *
  *      a_assets_path					: 「Assets」からの相対パス。
  *
  */
 public static System.Collections.Generic.List <string> CreateAll(string a_assets_path)
 {
     System.Collections.Generic.List <string> t_list = new System.Collections.Generic.List <string>();
     {
         System.Collections.Generic.Stack <string> t_work = new System.Collections.Generic.Stack <string>();
         {
             string t_assets_path_root = NormalizePath.NormalizeSeparateAndLast(a_assets_path);
             System.Collections.Generic.List <string> t_directory_name_list = CreateTopOnly(t_assets_path_root);
             if (t_assets_path_root.Length == 0)
             {
                 foreach (string t_directoryname in t_directory_name_list)
                 {
                     t_list.Add(t_directoryname);
                     t_work.Push(t_directoryname);
                 }
             }
             else
             {
                 foreach (string t_directoryname in t_directory_name_list)
                 {
                     string t_assets_path = t_assets_path_root + "\\" + t_directoryname;
                     t_list.Add(t_assets_path);
                     t_work.Push(t_assets_path);
                 }
             }
         }
         {
             while (t_work.Count > 0)
             {
                 string t_assets_path_current = t_work.Pop();
                 System.Collections.Generic.List <string> t_directory_name_list = CreateTopOnly(t_assets_path_current);
                 foreach (string t_directoryname in t_directory_name_list)
                 {
                     string t_assets_path = t_assets_path_current + "\\" + t_directoryname;
                     t_list.Add(t_assets_path);
                     t_work.Push(t_assets_path);
                 }
             }
         }
     }
     return(t_list);
 }
        /** 作成。すべて。
         *
         *      a_full_path						: フルパス。
         *
         */
        public static System.Collections.Generic.List <string> CreateAll(string a_full_path)
        {
            System.Collections.Generic.Stack <string> t_work = new System.Collections.Generic.Stack <string>();
            {
                t_work.Push(NormalizePath.NormalizeSeparateAndLast(a_full_path));
            }

            System.Collections.Generic.List <string> t_list = new System.Collections.Generic.List <string>();
            {
                while (t_work.Count > 0)
                {
                    string t_full_path_current = t_work.Pop();
                    System.Collections.Generic.List <string> t_directory_name_list = CreateTopOnly(t_full_path_current);
                    foreach (string t_directoryname in t_directory_name_list)
                    {
                        string t_full_path = t_full_path_current + '\\' + t_directoryname;
                        t_list.Add(t_full_path);
                        t_work.Push(t_full_path);
                    }
                }
            }
            return(t_list);
        }
示例#6
0
 /** 作成。すべて。
  *
  *      a_full_path						: フルパス。
  *
  */
 public static System.Collections.Generic.List <string> CreateAll(string a_full_path)
 {
     System.Collections.Generic.List <string> t_list = new System.Collections.Generic.List <string>();
     {
         System.Collections.Generic.List <string> t_full_path_directory_list;
         {
             string t_full_path = NormalizePath.NormalizeSeparateAndLast(a_full_path);
             t_full_path_directory_list = CreateDirectoryNameListWithFullPath.CreateAll(t_full_path);
             t_full_path_directory_list.Add(t_full_path);
         }
         {
             foreach (string t_full_path in t_full_path_directory_list)
             {
                 System.Collections.Generic.List <string> t_filename_list = CreateTopOnly(t_full_path);
                 foreach (string t_filename in t_filename_list)
                 {
                     t_list.Add(t_full_path + '\\' + t_filename);
                 }
             }
         }
     }
     return(t_list);
 }
        /** 作成。すべて。
         *
         *      a_assets_path					: 「Assets」からの相対パス。
         *
         */
        public static System.Collections.Generic.List <string> CreateAll(string a_assets_path)
        {
            System.Collections.Generic.List <string> t_list = new System.Collections.Generic.List <string>();
            {
                string t_assets_path_root = NormalizePath.NormalizeSeparateAndLast(a_assets_path);

                if (t_assets_path_root.Length == 0)
                {
                    System.Collections.Generic.List <string> t_file_name_list = CreateTopOnly(t_assets_path_root);
                    foreach (string t_filename in t_file_name_list)
                    {
                        t_list.Add(t_filename);
                    }
                }
                else
                {
                    System.Collections.Generic.List <string> t_file_name_list = CreateTopOnly(t_assets_path_root);
                    foreach (string t_filename in t_file_name_list)
                    {
                        t_list.Add(t_assets_path_root + '\\' + t_filename);
                    }
                }
                {
                    System.Collections.Generic.List <string> t_assets_path_directory_list = CreateDirectoryNameListWithAssetsPath.CreateAll(t_assets_path_root);
                    foreach (string t_assets_path in t_assets_path_directory_list)
                    {
                        System.Collections.Generic.List <string> t_file_name_list = CreateTopOnly(t_assets_path);
                        foreach (string t_filename in t_file_name_list)
                        {
                            t_list.Add(t_assets_path + '\\' + t_filename);
                        }
                    }
                }
            }
            return(t_list);
        }
示例#8
0
 return(new UnixRelativePath(NormalizePath(path, UnixSeparator), UnixSeparator));
示例#9
0
 return(new WinRelativePath(NormalizePath(path), WinSeparator));
示例#10
0
 return(new RelativePath(NormalizePath(path)));
示例#11
0
 /** AssetLib
  */
 static AssetLib()
 {
     s_application_data_path            = NormalizePath.NormalizeSeparateAndLast(UnityEngine.Application.dataPath);
     s_application_streamingassets_path = NormalizePath.NormalizeSeparateAndLast(UnityEngine.Application.streamingAssetsPath);
 }
        public async Task Invoke(HttpContext context)
        {
            var path = string.Empty;

#if HasRoutes
            // If we are going to set labels for Controller or Action -- then we need to make them readily available
            if (_options.IncludeController || _options.IncludeAction)
            {
                TryCaptureRouteData(context);
            }

            if (_options.UseRouteName)
            {
                path = context.GetRouteName();
            }
#endif
            if (string.IsNullOrEmpty(path))
            {
                path = context.Request.Path.ToString();
            }

            path = NormalizePath.Execute(path, _options);

            if (_options.IgnoreRoutesStartWith != null && _options.IgnoreRoutesStartWith.Any(i => path.StartsWith(i)))
            {
                await _next.Invoke(context);

                return;
            }

            if (_options.IgnoreRoutesContains != null && _options.IgnoreRoutesContains.Any(i => path.Contains(i)))
            {
                await _next.Invoke(context);

                return;
            }

            if (_options.IgnoreRoutesConcrete != null && _options.IgnoreRoutesConcrete.Any(i => path == i))
            {
                await _next.Invoke(context);

                return;
            }

            if (_options.ShouldMeasureRequest != null && !_options.ShouldMeasureRequest(context.Request))
            {
                await _next.Invoke(context);

                return;
            }

            string statusCode = null;
            var    method     = context.Request.Method;

            var controller = string.Empty;
            var action     = string.Empty;

#if HasRoutes
            controller = context.GetControllerName();
            action     = context.GetActionName();
#endif

            var ts = Stopwatch.GetTimestamp();

            try
            {
                await _next.Invoke(context);
            }
            catch (Exception)
            {
                statusCode = "500";
                throw;
            }
            finally
            {
                if (string.IsNullOrEmpty(statusCode))
                {
                    statusCode = context.Response.StatusCode.ToString();
                }

                double ticks = Stopwatch.GetTimestamp() - ts;
                WriteMetrics(statusCode, method, controller, action, path, ticks / Stopwatch.Frequency);
            }
        }