public static void Forward(Type type, StringBuilder sb) { if (typeof(string) == type) { NameSpaceWriter.Write(typeof(string), sb, (targetType, StringBuilder, indent) => { sb.AppendLine(indent + "class Type;"); sb.AppendLine(indent + "class Array;"); sb.AppendLine(indent); }); NameSpaceWriter.Write(typeof(System.Globalization.CultureInfo), sb, (targetType, StringBuilder, indent) => { sb.AppendLine(indent + "class CultureInfo;"); sb.AppendLine(indent); }); } if (typeof(IFormatProvider) == type || typeof(System.Reflection.ICustomAttributeProvider) == type || typeof(System.Runtime.InteropServices._MemberInfo) == type) { NameSpaceWriter.Write(typeof(string), sb, (targetType, StringBuilder, indent) => { sb.AppendLine(indent + "class Type;"); sb.AppendLine(indent); }); } }
public static void DoForward_(Type type, StringBuilder sb, IEnumerable <Type> types) { var assemblies = types.Select(x => x.Assembly.GetName().Name).Distinct(); foreach (var assembly in assemblies) { var ns = types.Where(x => x.Assembly.GetName().Name == assembly).Select(x => x.Namespace).Distinct(); foreach (var nsItem in ns) { NameSpaceWriter.Write(assembly, nsItem, sb, (sbuilder, indent) => { var nsTypes = types.Where(x => x.Assembly.GetName().Name == assembly && x.Namespace == nsItem); foreach (var typeItem in nsTypes) { if (typeItem.IsGenericType) { sb.AppendLine(indent + "\ttemplate<" + string.Join(", ", typeItem.GetGenericArguments().Select(x => "typename " + (x.FullName == null ? x.Name : x.FullName))) + ">"); } sbuilder.AppendLine(indent + "class " + typeItem.ClassName() + ";"); } sb.AppendLine(indent); }); } } }