/// <summary> /// 输出多行_主函数_内部. /// </summary> /// <param name="isfull">显示全部信息.</param> /// <param name="iw">带缩进输出者.</param> /// <param name="obj">object. Can be null.</param> /// <param name="context">State Object. Can be null.</param> /// <returns>返回是否成功输出.</returns> private static bool outl_main_core(bool isfull, IIndentedWriter iw, object obj, IndentedWriterContext context) { if (null == iw) { return(false); } iw.WriteLine("# zinfodraw"); if (isfull) { iw.WriteLine("Brushes:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(Brushes), context); } iw.WriteLine("BufferedGraphicsManager:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(BufferedGraphicsManager), context); // Font: 无静态属性. 可用 SystemFonts 枚举 . iw.WriteLine("FontFamily:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(FontFamily), context); if (isfull) { iw.WriteLine("Pens:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(Pens), context); iw.WriteLine("StringFormat:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(StringFormat), context); iw.WriteLine("SystemBrushes:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(SystemBrushes), context); iw.WriteLine("SystemColors:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(SystemColors), context); } iw.WriteLine("SystemFonts:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(SystemFonts), context); iw.WriteLine("SystemIcons:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(SystemIcons), context); if (isfull) { iw.WriteLine("SystemPens:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(SystemPens), context); iw.WriteLine("Color:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(Color), context); } iw.WriteLine("Encoder:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(Encoder), context); iw.WriteLine("FrameDimension:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(FrameDimension), context); iw.WriteLine("ImageCodecInfo:"); outl_static_ImageCodecInfo(iw, null, context); iw.WriteLine("ImageFormat:"); IndentedWriterUtil.WriteTypeStatic(iw, typeof(ImageFormat), context); iw.WriteLine("InstalledFontCollection:"); IndentedObjectFunctor.CommonProc(iw, new InstalledFontCollection(), context); //IndentedWriterUtil.WriteTypeStatic(iw, typeof(InstalledFontCollection), context); return(true); }
/// <summary> /// 输出信息_程序集的属性. /// </summary> /// <param name="iw">输出者.</param> /// <param name="context">输出时的环境.</param> /// <param name="assembly">程序集.</param> /// <returns>是否成功.</returns> private static bool WriteInfo_AssemblyProperty(IIndentedWriter iw, IndentedWriterContext context, Assembly assembly) { bool rt = false; if (null == iw) { return(false); } if (null == assembly) { return(false); } iw.WriteLine("Assembly:"); IndentedObjectFunctor.CommonProc(iw, assembly, context); #if (NETFX_CORE) // Windows Store App 下反射获取Assembly的属性值时总是失败. 于是手动获取属性值. iw.WriteLine("Assembly info 2:"); iw.Indent(assembly); iw.WriteLine("# <System.Reflection.Assembly>"); iw.WriteLine("ToString():\t{0}", assembly.ToString()); iw.WriteLine("FullName:\t{0}", assembly.FullName); iw.WriteLine("IsDynamic:\t{0}", assembly.IsDynamic); iw.WriteLine("GetName():"); IndentedObjectFunctor.CommonProc(iw, assembly.GetName(), context); iw.WriteLine("ManifestModule:"); IndentedObjectFunctor.CommonProc(iw, assembly.ManifestModule, context); iw.WriteLine("Modules:"); IndentedObjectFunctor.CommonProc(iw, assembly.Modules, context); iw.Unindent(); #endif return(rt); }
/// <summary> /// 输出多行_文化信息. /// </summary> /// <param name="iw">带缩进输出者.</param> /// <param name="obj">object. Can be null.</param> /// <param name="context">State Object. Can be null.</param> /// <returns>返回是否成功输出.</returns> public static bool outl_static_CultureInfo(IIndentedWriter iw, object obj, IndentedWriterContext context) { if (null == iw) { return(false); } Type tp = typeof(CultureInfo); if (!iw.Indent(tp)) { return(false); } iw.WriteLine(string.Format("# <{0}>", tp.FullName)); IndentedWriterMemberOptions options = IndentedWriterMemberOptions.AllowMethod | IndentedWriterMemberOptions.OnlyStatic; IndentedWriterUtil.ForEachMember(iw, null, tp, options, delegate(object sender, IndentedWriterMemberEventArgs e) { MethodInfo memberinfo = e.MemberInfo as MethodInfo; if (null != memberinfo) { //if (!memberinfo.IsSpecialName) { // e.HasDefault = true; //} string name = memberinfo.Name; int cntparam = memberinfo.GetParameters().Length; if (false) { } #if (!NETFX_CORE) else if (IndentedWriterUtil.StringComparer.Equals(name, "GetCultures")) { if (cntparam == 1) { e.IsCancel = true; IndentedWriterUtil.WriteLineValue(iw, e.MemberName, e.Value, e.ValueOptions, e.AppendComment); CultureInfo[] lst = null; iw.Indent(null); try { object[] args = new object[1]; args[0] = CultureTypes.AllCultures; lst = (CultureInfo[])memberinfo.Invoke(null, args); // 显示短格式. foreach (CultureInfo p in lst) { int lcid = -1; iw.Write("{0}:\t", p.Name); #if (!NETFX_PORTABLE) lcid = p.LCID; #endif if (lcid != -1) { iw.Write("0x{0:X}", lcid); } iw.WriteLine("\t# {0}, {1}", p.EnglishName, p.NativeName); } } catch { // 忽略. } finally { iw.Unindent(); } // 显示详细. if (ShowDetail) { IndentedWriterUtil.WriteLineValue(iw, e.MemberName, e.Value, e.ValueOptions, "Detail"); IndentedObjectFunctor.CommonProc(iw, lst, context); } } } #endif } }, context); iw.Unindent(); return(true); }
/// <summary> /// 输出多行_主函数. /// </summary> /// <param name="iw">带缩进输出者.</param> /// <param name="obj">object. Can be null.</param> /// <param name="context">State Object. Can be null.</param> /// <returns>返回是否成功输出.</returns> public static bool outl_main(IIndentedWriter iw, object obj, IndentedWriterContext context) { if (null == iw) { return(false); } Assembly myAssembly; #if (NETFX_CORE) Type tp = typeof(MyInfo); TypeInfo ti = tp.GetTypeInfo(); myAssembly = ti.Assembly; #else myAssembly = Assembly.GetEntryAssembly(); #endif iw.WriteLine("# zinfoenvironment"); // test. //iw.WriteLine("Hello!"); //for (int i = 0; i < 3; ++i) { // iw.WriteLine(i); // iw.Indent(); //} //iw.IndentLevel = 0; //IndentedWriterObjectLnProc lwo = outl_Version; //IndentedWriterObjectLnProc[] lwos = new IndentedWriterObjectLnProc[] { lwo }; //IEnumerable<IndentedWriterObjectLnProc> lwoe = lwos; //foreach (IndentedWriterObjectLnProc p in lwoe) { // p(iw, ""); //} //lwo(iw, ""); //lwo.Invoke(iw, ""); //decimal? dec = new decimal(1); //IndentedWriterUtil.WriteLineValue(iw, "dec", dec, IndentedWriterValueOptions.Default); //IndentedObjectFunctor.CommonProc(iw, dec); //IndentedWriterUtil.WriteLineValue(iw, "enum", IndentedWriterValueOptions.ExistName, IndentedWriterValueOptions.Default, null); //IndentedWriterUtil.WriteLineValue(iw, "char", 'A', IndentedWriterValueOptions.Default, null); //IndentedWriterUtil.WriteLineValue(iw, "int", 255, IndentedWriterValueOptions.Default, null); //IndentedWriterUtil.WriteLineValue(iw, "string", Environment.NewLine, IndentedWriterValueOptions.Default, null); //IndentedWriterUtil.WriteLineValue(iw, "char(2)", '\t', IndentedWriterValueOptions.Default, null); //IndentedWriterUtil.WriteLineValue(iw, "string(2)", "\\\'\"", IndentedWriterValueOptions.Default, null); //iw.WriteLine(MemberInfoFormat.GetMemberName(typeof(KeyValuePair<int, object>), MemberNameOptions.All)); //iw.WriteLine(MemberInfoFormat.GetMemberName(typeof(KeyValuePair<int, object>[]), MemberNameOptions.All)); //iw.WriteLine(MemberInfoFormat.GetMemberName(typeof(List<KeyValuePair<int, object>>), MemberNameOptions.All)); //IndentedObjectFunctor.CommonProc(iw, TypeUtil.GetEnumValues(typeof(Environment.SpecialFolder)) ,null); Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("a", "abc"); dict.Add("b", "base"); dict.Add("ver", myAssembly.GetName().Version); iw.WriteLine("Test Dictionary:"); IndentedObjectFunctor.CommonProc(iw, dict, context); // show. iw.WriteLine("IntPtr:"); outl_static_IntPtr(iw, null, context); iw.WriteLine("Environment:"); //IndentedObjectFunctor.CommonProc(iw, Environment.OSVersion, context); outl_Environment(iw, null, context); //iw.WriteLine("Application Assembly:"); //IndentedObjectFunctor.CommonProc(iw, myAssembly, context); iw.WriteLine("Application AssemblyName:"); IndentedObjectFunctor.CommonProc(iw, myAssembly.GetName(), context); return(true); }