//bool can_submit_scan = false; public void writeScanInfo(IInfoContainer junk) { object oo = null; string ss = null; MsScanInformationSource ii = MsScanInformationSource.Unknown; foreach (string name in junk.Names) { if (junk.TryGetValue(name, out ss, ref ii)) { if (junk.TryGetRawValue(name, out oo, ref ii)) { if (oo.GetType() == typeof(string)) { Console.WriteLine("\t{0}: type={1}, text='{2}', raw='{3}", name, ii, ss, oo); } else if (oo is System.Double[]) { Console.WriteLine("\t{0}:", name); foreach (var item in (oo as System.Double[])) { Console.WriteLine("\t\t{0}", item.ToString()); } Console.WriteLine("\t{0} Done.", name); } else { Console.WriteLine("\t{0}: Not rendering {1} {2}.", name, oo.GetType().ToString(), oo.ToString()); } } } } }
/// <summary> /// Dump the content of a single variable to the console after testing the consistency. /// </summary> /// <param name="container">container that variable belongs to</param> /// <param name="name">name of the variable</param> private void DumpVar(IInfoContainer container, string name) { object o = null; string s = null; MsScanInformationSource i = MsScanInformationSource.Unknown; if (container.TryGetValue(name, out s, ref i)) { // i should have a reasonable value now if (container.TryGetRawValue(name, out o, ref i)) { outputln(" {0}: type={1}, text='{2}', raw='{3}'", name, i, s, o); infoTable.Add(name, s); } } }
/// <summary> /// Dump the content of a single variable to the console after testing the consistency. /// </summary> /// <param name="container">container that variable belongs to</param> /// <param name="name">name of the variable</param> /// <param name="sb">buffer to be reused for speed</param> private void DumpVar(IInfoContainer container, string name, StringBuilder sb) { sb.Length = 0; // NOTE: The whole try block performs the consistency check except that // part that is marked. You can ignore it savely. try { object o0 = null, o1, o2, o3; string s0 = null, s1, s2, s3; MsScanInformationSource i0 = MsScanInformationSource.Unknown, i1, i2; i1 = MsScanInformationSource.Unknown; if (!container.TryGetValue(name, out s1, ref i1)) { sb.Append("NO TEXT(Unk) "); } else { i0 = i1; s0 = s1; if (!container.TryGetValue(name, out s2, ref i1)) { sb.Append("NO TEXT(" + i0 + ") "); } else if (s1 != s2) { sb.Append("TEXT DIFF1 "); } } if (!container.TryGetValue(name, out s3)) { sb.Append("NO PLAIN TEXT "); } else if (s0 != s3) { sb.Append("TEXT DIFF2 "); s0 = s3; } if (i0 != MsScanInformationSource.Unknown) { for (MsScanInformationSource ss = MsScanInformationSource.Common; ss <= MsScanInformationSource.AcquisitionFixed; ss++) { if (ss == i0) { continue; } i2 = ss; if (container.TryGetValue(name, out s2, ref i2)) { sb.Append("TEXT DOUBLETTE "); } } } i2 = MsScanInformationSource.Unknown; if (!container.TryGetRawValue(name, out o1, ref i2)) { sb.Append("NO DATA(Unk) "); i0 = MsScanInformationSource.Unknown; } else { if (i2 != i0) { sb.Append("SRC DIFF "); i0 = i2; } i1 = i0; o0 = o1; if (!container.TryGetRawValue(name, out o2, ref i1)) { sb.Append("NO TEXT(" + i0 + ") "); } else if (!o1.Equals(o2)) { sb.Append("DATA DIFF1 "); } } if (!container.TryGetRawValue(name, out o3)) { sb.Append("NO PLAIN Data "); } else if (!o0.Equals(o3)) { sb.Append("DATA DIFF2 "); o0 = o3; } if (i0 != MsScanInformationSource.Unknown) { for (MsScanInformationSource ss = MsScanInformationSource.Common; ss <= MsScanInformationSource.AcquisitionFixed; ss++) { if (ss == i0) { continue; } i2 = ss; if (container.TryGetRawValue(name, out o2, ref i2)) { sb.Append("DATA DOUBLETTE "); } } } // ADD THE REAL INFORMATION sb.Append("type=" + i0); sb.Append(", text='" + s0); sb.Append("', raw='" + o0); sb.Append("'"); if (sb.ToString().Equals("NO TEXT(Unk) NO PLAIN TEXT NO DATA(Unk) NO PLAIN Data type=Unknown, text='', raw=''")) { sb.Length = 0; sb.Append("NO ACCESS"); } } finally { sb.Insert(0, " " + name + ": "); Console.WriteLine(sb.ToString()); } }