~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/Sharpen/Sharpen/Runtime.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
namespace Sharpen
13
13
{
14
 
        internal class Runtime
 
14
        public class Runtime
15
15
        {
16
16
                private static Runtime instance;
17
17
                private List<ShutdownHook> shutdownHooks = new List<ShutdownHook> ();
18
18
 
19
 
                public void AddShutdownHook (Runnable r)
 
19
                internal void AddShutdownHook (Runnable r)
20
20
                {
21
21
                        ShutdownHook item = new ShutdownHook ();
22
22
                        item.Runnable = r;
23
23
                        this.shutdownHooks.Add (item);
24
24
                }
25
25
 
26
 
                public int AvailableProcessors ()
 
26
                internal int AvailableProcessors ()
27
27
                {
28
28
                        return Environment.ProcessorCount;
29
29
                }
30
30
 
31
 
                public static long CurrentTimeMillis ()
 
31
                internal static long CurrentTimeMillis ()
32
32
                {
33
33
                        return DateTime.UtcNow.ToMillisecondsSinceEpoch ();
34
34
                }
35
35
 
36
 
                public SystemProcess Exec (string[] cmd, string[] envp, FilePath dir)
 
36
                internal SystemProcess Exec (string[] cmd, string[] envp, FilePath dir)
37
37
                {
38
38
                        try {
39
39
                                ProcessStartInfo psi = new ProcessStartInfo ();
59
59
                        }
60
60
                }
61
61
 
62
 
                public static string Getenv (string var)
 
62
                internal static string Getenv (string var)
63
63
                {
64
64
                        return Environment.GetEnvironmentVariable (var);
65
65
                }
66
66
 
67
 
                public static IDictionary<string, string> GetEnv ()
 
67
                internal static IDictionary<string, string> GetEnv ()
68
68
                {
69
69
                        Dictionary<string, string> dictionary = new Dictionary<string, string> ();
70
70
                        foreach (DictionaryEntry v in Environment.GetEnvironmentVariables ()) {
73
73
                        return dictionary;
74
74
                }
75
75
 
76
 
                public static IPAddress GetLocalHost ()
 
76
                internal static IPAddress GetLocalHost ()
77
77
                {
78
78
                        return Dns.GetHostEntry (Dns.GetHostName ()).AddressList[0];
79
79
                }
85
85
                        if (properties == null) {
86
86
                                properties = new Hashtable ();
87
87
                                properties ["jgit.fs.debug"] = "false";
88
 
                                properties ["user.home"] = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
 
88
                                var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile).Trim ();
 
89
                                if (string.IsNullOrEmpty (home))
 
90
                                        home = Environment.GetFolderPath (Environment.SpecialFolder.Personal).Trim ();
 
91
                                properties ["user.home"] = home;
89
92
                                properties ["java.library.path"] = Environment.GetEnvironmentVariable ("PATH");
90
93
                                if (Path.DirectorySeparatorChar != '\\')
91
94
                                        properties ["os.name"] = "Unix";
102
105
                
103
106
                public static void SetProperty (string key, string value)
104
107
                {
105
 
//                      throw new NotImplementedException ();
 
108
                        GetProperties () [key] = value;
106
109
                }
107
110
 
108
111
                public static Runtime GetRuntime ()
113
116
                        return instance;
114
117
                }
115
118
 
116
 
                public static int IdentityHashCode (object ob)
 
119
                internal static int IdentityHashCode (object ob)
117
120
                {
118
121
                        return RuntimeHelpers.GetHashCode (ob);
119
122
                }
120
123
 
121
 
                public long MaxMemory ()
 
124
                internal long MaxMemory ()
122
125
                {
123
126
                        return int.MaxValue;
124
127
                }
133
136
                        }
134
137
                }
135
138
                
136
 
                public static void DeleteCharAt (StringBuilder sb, int index)
 
139
                internal static void DeleteCharAt (StringBuilder sb, int index)
137
140
                {
138
141
                        sb.Remove (index, 1);
139
142
                }
140
143
                
141
 
                public static byte[] GetBytesForString (string str)
 
144
                internal static byte[] GetBytesForString (string str)
142
145
                {
143
146
                        return Encoding.UTF8.GetBytes (str);
144
147
                }
145
148
 
146
 
                public static byte[] GetBytesForString (string str, string encoding)
 
149
                internal static byte[] GetBytesForString (string str, string encoding)
147
150
                {
148
151
                        return Encoding.GetEncoding (encoding).GetBytes (str);
149
152
                }
150
153
 
151
 
                public static FieldInfo[] GetDeclaredFields (Type t)
 
154
                internal static FieldInfo[] GetDeclaredFields (Type t)
152
155
                {
153
156
                        return t.GetFields (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
154
157
                }
155
158
 
156
 
                public static void NotifyAll (object ob)
 
159
                internal static void NotifyAll (object ob)
157
160
                {
158
161
                        Monitor.PulseAll (ob);
159
162
                }
160
163
 
161
 
                public static void PrintStackTrace (Exception ex)
 
164
                internal static void PrintStackTrace (Exception ex)
162
165
                {
163
166
                        Console.WriteLine (ex);
164
167
                }
165
168
 
166
 
                public static void PrintStackTrace (Exception ex, TextWriter tw)
 
169
                internal static void PrintStackTrace (Exception ex, TextWriter tw)
167
170
                {
168
171
                        tw.WriteLine (ex);
169
172
                }
170
173
 
171
 
                public static string Substring (string str, int index)
 
174
                internal static string Substring (string str, int index)
172
175
                {
173
176
                        return str.Substring (index);
174
177
                }
175
178
 
176
 
                public static string Substring (string str, int index, int endIndex)
 
179
                internal static string Substring (string str, int index, int endIndex)
177
180
                {
178
181
                        return str.Substring (index, endIndex - index);
179
182
                }
180
183
 
181
 
                public static void Wait (object ob)
 
184
                internal static void Wait (object ob)
182
185
                {
183
186
                        Monitor.Wait (ob);
184
187
                }
185
188
 
186
 
                public static bool Wait (object ob, long milis)
 
189
                internal static bool Wait (object ob, long milis)
187
190
                {
188
191
                        return Monitor.Wait (ob, (int)milis);
189
192
                }
190
193
                
191
 
                public static Type GetType (string name)
 
194
                internal static Type GetType (string name)
192
195
                {
193
196
                        foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
194
197
                                Type t = a.GetType (name);
198
201
                        throw new InvalidOperationException ("Type not found: " + name);
199
202
                }
200
203
                
201
 
                public static void SetCharAt (StringBuilder sb, int index, char c)
 
204
                internal static void SetCharAt (StringBuilder sb, int index, char c)
202
205
                {
203
206
                        sb [index] = c;
204
207
                }
205
208
                
206
 
                public static bool EqualsIgnoreCase (string s1, string s2)
 
209
                internal static bool EqualsIgnoreCase (string s1, string s2)
207
210
                {
208
211
                        return s1.Equals (s2, StringComparison.CurrentCultureIgnoreCase);
209
212
                }
210
213
                
211
 
                public static long NanoTime ()
 
214
                internal static long NanoTime ()
212
215
                {
213
216
                        return Environment.TickCount * 1000 * 1000;
214
217
                }
215
218
                
216
 
                public static int CompareOrdinal (string s1, string s2)
 
219
                internal static int CompareOrdinal (string s1, string s2)
217
220
                {
218
221
                        return string.CompareOrdinal (s1, s2);
219
222
                }
220
223
 
221
 
                public static string GetStringForBytes (byte[] chars)
 
224
                internal static string GetStringForBytes (byte[] chars)
222
225
                {
223
226
                        return Encoding.UTF8.GetString (chars);
224
227
                }
225
228
 
226
 
                public static string GetStringForBytes (byte[] chars, string encoding)
 
229
                internal static string GetStringForBytes (byte[] chars, string encoding)
227
230
                {
228
231
                        return GetEncoding (encoding).GetString (chars);
229
232
                }
230
233
 
231
 
                public static string GetStringForBytes (byte[] chars, int start, int len)
 
234
                internal static string GetStringForBytes (byte[] chars, int start, int len)
232
235
                {
233
236
                        return Encoding.UTF8.GetString (chars, start, len);
234
237
                }
235
238
 
236
 
                public static string GetStringForBytes (byte[] chars, int start, int len, string encoding)
 
239
                internal static string GetStringForBytes (byte[] chars, int start, int len, string encoding)
237
240
                {
238
241
                        return GetEncoding (encoding).Decode (chars, start, len);
239
242
                }
240
243
                
241
 
                public static Encoding GetEncoding (string name)
 
244
                internal static Encoding GetEncoding (string name)
242
245
                {
243
246
//                      Encoding e = Encoding.GetEncoding (name, EncoderFallback.ExceptionFallback, DecoderFallback.ExceptionFallback);
244
247
                        Encoding e = Encoding.GetEncoding (name.Replace ('_','-'));