Last change
on this file since 16984 was
16984,
checked in by dpiringe, 5 years ago
|
#2924:
- merged projects HeuristicLab.PluginInfrastructure.Runner and HeuristicLab.PluginInfrastructure
- applied changes of code reviews (13.05.2019 and 22.05.2019) -> the old Runner is now RunnerHost and uses a Runner, which is executed on the child process
- added Type GetType(string) to IApplicationManager and implemented it for LightweightApplicationManager
- removed IActivator and IActivatorContext
- deleted unused types like PluginDescriptionIterator
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.IO;
|
---|
4 | using System.Runtime.InteropServices;
|
---|
5 | using System.Text;
|
---|
6 | using System.Text.RegularExpressions;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.PluginInfrastructure {
|
---|
9 | [Serializable]
|
---|
10 | public class UniPath {
|
---|
11 |
|
---|
12 | #region Vars
|
---|
13 | private string fullPath = "";
|
---|
14 | #endregion
|
---|
15 |
|
---|
16 | #region Constructors
|
---|
17 | public UniPath(string path) {
|
---|
18 | fullPath = Path.GetFullPath(path);
|
---|
19 | }
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | private bool IsWindowsAbsolutePath(string path) => Regex.IsMatch(path, @"^[A-Z]:");
|
---|
23 |
|
---|
24 | private string Rebuild(char split, string startStr, string seperator) {
|
---|
25 | string[] splits = fullPath.Split(split);
|
---|
26 | string tmp = startStr;
|
---|
27 | int i = 1;
|
---|
28 | while (i < splits.Length - 1) {
|
---|
29 | tmp += splits[i] + seperator;
|
---|
30 | ++i;
|
---|
31 | }
|
---|
32 | tmp += splits[i];
|
---|
33 | return tmp;
|
---|
34 | }
|
---|
35 |
|
---|
36 | public override string ToString() {
|
---|
37 | bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
---|
38 | if (isWindows) {
|
---|
39 | if (IsWindowsAbsolutePath(fullPath))
|
---|
40 | return fullPath;
|
---|
41 | else return Rebuild('/', @"C:\", @"\");
|
---|
42 | } else {
|
---|
43 | if (IsWindowsAbsolutePath(fullPath))
|
---|
44 | return Rebuild('\\', "/", "/");
|
---|
45 | else return fullPath;
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.