BioLib  4.3.0
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.Recorder Class Reference

Static Public Member Functions

static void Clear ()
 
static void Record (MethodInfo inf, bool isInternal, params object[] args)
 
static void Record (string code)
 
static void AddLine (string s, bool isInternal)
 
static MethodInfo GetCurrentMethodInfo ()
 

Static Public Attributes

static bool Internal = false
 
static bool outputConsole = true
 

Properties

static string[] Lines [get]
 

Member Function Documentation

◆ AddLine()

static void BioLib.Recorder.AddLine ( string s,
bool isInternal )
static
107 {
108 if (!isInternal || Internal)
109 rec.Add(s);
110 }
static bool Internal
Definition Recorder.cs:13

◆ Clear()

static void BioLib.Recorder.Clear ( )
static
17 {
18 rec.Clear();
19 }

◆ GetCurrentMethodInfo()

static MethodInfo BioLib.Recorder.GetCurrentMethodInfo ( )
static
112 {
113 StackTrace stackTrace = new StackTrace();
114 StackFrame stackFrame = stackTrace.GetFrame(1); // 1 to get the current method, 0 would get the GetCurrentMethodInfo itself
115 MethodBase methodBase = stackFrame.GetMethod();
116 return methodBase as MethodInfo;
117 }

◆ Record() [1/2]

static void BioLib.Recorder.Record ( MethodInfo inf,
bool isInternal,
params object[] args )
static
21 {
22 if (!isInternal || Internal)
23 {
24 string name = inf.DeclaringType.FullName.Replace("<", "").Replace("+",".");
25 if(name.Contains('<'))
26 name = name.Substring(0, name.LastIndexOf('>'));
27 string code = name + "." + inf.Name + "(";
28 for (int i = 0; i < args.Length; i++)
29 {
30 Type t = args[i].GetType();
31 if (args[i] is Array)
32 {
33 Array ar = (Array)args[i];
34 code += "";
35 for (int a = 0; a < ar.Length; a++)
36 {
37 if (t == typeof(string))
38 {
39 if (i == 0)
40 code += "new " + t.Name + "[]{\"" + ar.GetValue(a).ToString() + "\"";
41 else
42 code += ",\"" + ar.GetValue(a).ToString() + "\"";
43 if (i == ar.Length - 1)
44 code += ";";
45 }
46 else
47 if (t == typeof(bool))
48 {
49 if (i == 0)
50 code += "new " + "bool" + "[]{" + ar.GetValue(a).ToString().ToLower();
51 else
52 code += ",\"" + ar.GetValue(a).ToString() + "\"";
53 if (i == ar.Length - 1)
54 code += "}";
55 }
56 else
57 {
58 if (i == 0)
59 code += "new " + t.Name + "{\"" + ar.GetValue(a).ToString() + "\"";
60 else
61 code += "," + ar.GetValue(a).ToString();
62 if (i == ar.Length - 1)
63 code += "}";
64 }
65 }
66 }
67 else
68 if (t == typeof(string))
69 {
70 if (i == 0)
71 code += "\"" + args[i].ToString() + "\"";
72 else
73 code += ",\"" + args[i].ToString() + "\"";
74 }
75 else
76 if (t == typeof(bool))
77 {
78 if (i == 0)
79 code += args[i].ToString().ToLower();
80 else
81 code += "," + args[i].ToString().ToLower();
82 }
83 else
84 if (i == 0)
85 code += args[i];
86 else
87 code += "," + args[i];
88 }
89 code += ");";
90 Console.WriteLine(code);
91 rec.Add(code);
92 }
93 }

◆ Record() [2/2]

static void BioLib.Recorder.Record ( string code)
static
96 {
97 rec.Add(code);
98 }

Member Data Documentation

◆ Internal

bool BioLib.Recorder.Internal = false
static

◆ outputConsole

bool BioLib.Recorder.outputConsole = true
static

Property Documentation

◆ Lines

string [] BioLib.Recorder.Lines
staticget
100 {
101 get
102 {
103 return rec.ToArray();
104 }
105 }

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