MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / TX

Class TX

src/NodeRTLib/Reflector.cs:286–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284 }
285
286 public static class TX
287 {
288 public static dynamic MainModel;
289 public static dynamic CppTemplates = new DynamicTemplate("CppTemplates", ".cpp");
290 public static dynamic JsDefinitionTemplates = new DynamicTemplate(@"DefinitonTemplates\Js", ".js");
291 public static dynamic TsDefinitionTemplates = new DynamicTemplate(@"DefinitonTemplates\Ts", ".ts");
292
293 public static ITemplate<dynamic> LoadTemplate(string templateName, string templateLocation, string templateExtension)
294 {
295 Stream stream;
296
297 try
298 {
299 stream = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, string.Format(@"{0}\{1}{2}", templateLocation, templateName, templateExtension)));
300 }
301 catch (Exception)
302 {
303 return null;
304 }
305
306 using (var reader = new StreamReader(stream))
307 {
308 var rawTemplate = reader.ReadToEnd();
309 return Template
310 .WithBaseType<TemplateBase>()
311 .AddNamespace("NodeRTLib")
312 .Compile(rawTemplate);
313 }
314 }
315
316 public static bool ShouldIgnoreMethod(MethodInfo info)
317 {
318 if (info.Name.Equals("Close") && info.DeclaringType.GetInterface("IDisposable") != null)
319 {
320 return true;
321 }
322
323 return false;
324 }
325
326 public static Func<dynamic, String> LazyTemplate(string templateName, string templateLocation, string templateExtension)
327 {
328 ITemplate<dynamic> template = LoadTemplate(templateName, templateLocation, templateExtension);
329 if (template == null)
330 {
331 return null;
332 }
333
334 return (dynamic model) =>
335 {
336 return template.Render(model);
337 };
338 }
339
340
341 // http://stackoverflow.com/a/1363212/1060807
342 public static string TypeToString(Type type)
343 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected