BGC Tools
Static Public Member Functions | Data Fields
BGC.Utility.ResourceUtility Class Reference
Collaboration diagram for BGC.Utility.ResourceUtility:
Collaboration graph
[legend]

Static Public Member Functions

static bool ConvertToValidResourcePath (ref string path)
 Checks path and returns true if a valid resource path was found More...
 
static string Combine (string path1, string path2)
 

Data Fields

const string ResourcesDirectory = "Resources"
 
const char FileDelimiter = '/'
 
const char Extension = '.'
 

Detailed Description

Definition at line 5 of file ResourceUtility.cs.

Member Function Documentation

◆ Combine()

static string BGC.Utility.ResourceUtility.Combine ( string  path1,
string  path2 
)
inlinestatic

Definition at line 39 of file ResourceUtility.cs.

40  {
41  bool p1NullOrEmpty = string.IsNullOrEmpty(path1);
42  bool p2NullOrEmpty = string.IsNullOrEmpty(path2);
43 
44  if (p1NullOrEmpty && p2NullOrEmpty)
45  {
46  return "";
47  }
48  else if (p1NullOrEmpty)
49  {
50  return path2;
51  }
52  else if(p2NullOrEmpty)
53  {
54  return path1;
55  }
56 
57  return $"{path1}{FileDelimiter}{path2}";
58  }

◆ ConvertToValidResourcePath()

static bool BGC.Utility.ResourceUtility.ConvertToValidResourcePath ( ref string  path)
inlinestatic

Checks path and returns true if a valid resource path was found

Parameters
path
Returns

Definition at line 16 of file ResourceUtility.cs.

17  {
18  string[] Dirs = path.Split(FileDelimiter);
19 
20  for (int i = 0; i < Dirs.Length; ++i)
21  {
22  if (Dirs[i].Equals(ResourcesDirectory))
23  {
24  Dirs = Dirs.GetRange(i + 1, Dirs.Length);
25 
26  string[] fileName = Dirs[Dirs.Length - 1].Split(Extension);
27  fileName = fileName.GetRange(0, fileName.Length - 1);
28  Dirs[Dirs.Length - 1] = fileName.Join(".");
29 
30  path = Dirs.Join(FileDelimiter.ToString());
31 
32  return true;
33  }
34  }
35 
36  return false;
37  }

Field Documentation

◆ Extension

const char BGC.Utility.ResourceUtility.Extension = '.'

Definition at line 9 of file ResourceUtility.cs.

◆ FileDelimiter

const char BGC.Utility.ResourceUtility.FileDelimiter = '/'

Definition at line 8 of file ResourceUtility.cs.

◆ ResourcesDirectory

const string BGC.Utility.ResourceUtility.ResourcesDirectory = "Resources"

Definition at line 7 of file ResourceUtility.cs.


The documentation for this class was generated from the following file: