public override void DoOutput() { XmlNode parametersNode = document.CreateElement("parameters", null); parent.AppendChild(parametersNode); foreach (var parameter in parameters) { XmlNode paramNode = document.CreateElement("parameter", null); parametersNode.AppendChild(paramNode); AddAttribute(paramNode, "name", parameter.Name); AddAttribute(paramNode, "position", parameter.Position.ToString(CultureInfo.InvariantCulture)); AddAttribute(paramNode, "attrib", ((int)parameter.Attributes).ToString()); string direction = "in"; if (parameter.ParameterType.IsByRef) { direction = parameter.IsOut ? "out" : "ref"; } var t = parameter.ParameterType; AddAttribute(paramNode, "type", t.ToString()); if (parameter.IsOptional) { AddAttribute(paramNode, "optional", "true"); if (parameter.DefaultValue != DBNull.Value) { AddAttribute(paramNode, "defaultValue", (parameter.DefaultValue == null) ? "NULL" : parameter.DefaultValue.ToString()); } } if (direction != "in") { AddAttribute(paramNode, "direction", direction); } //2008-08-18 tsv ([email protected]) - enabled reflection only context //AttributeData.OutputAttributes(document, paramNode, parameter.GetCustomAttributes(false)); AttributeData.OutputAttributes(document, paramNode, parameter); } }
public override void DoOutput() { XmlNode mclass = document.CreateElement(ParentTag, null); parent.AppendChild(mclass); foreach (MemberInfo member in members) { XmlNode mnode = document.CreateElement(Tag, null); mclass.AppendChild(mnode); AddAttribute(mnode, "name", GetName(member)); if (!NoMemberAttributes) { AddAttribute(mnode, "attrib", GetMemberAttributes(member)); } AttributeData.OutputAttributes(document, mnode, member.GetCustomAttributes(false)); AddExtraData(mnode, member); } }
public override void DoOutput() { XmlNode mclass = document.CreateElement(ParentTag, null); parent.AppendChild(mclass); foreach (var member in members) { XmlNode mnode = document.CreateElement(Tag, null); mclass.AppendChild(mnode); AddAttribute(mnode, "name", GetName(member)); if (!NoMemberAttributes) { AddAttribute(mnode, "attrib", GetMemberAttributes(member)); } //2008-08-18 tsv ([email protected]) - enabled reflection only context //AttributeData.OutputAttributes(document, mnode, member.GetCustomAttributes(false)); AttributeData.OutputAttributes(document, mnode, member); AddExtraData(mnode, member); } }
protected override void AddExtraData(XmlNode p, MemberInfo member) { base.AddExtraData(p, member); ParameterData parms = new ParameterData(document, p, ((MethodBase)member).GetParameters()); parms.DoOutput(); if (!(member is MethodBase)) { return; } MethodBase mbase = (MethodBase)member; if (mbase.IsAbstract) { AddAttribute(p, "abstract", "true"); } if (mbase.IsVirtual) { AddAttribute(p, "virtual", "true"); } if (mbase.IsStatic) { AddAttribute(p, "static", "true"); } if (!(member is MethodInfo)) { return; } MethodInfo method = (MethodInfo)member; AddAttribute(p, "returntype", method.ReturnType.ToString()); AttributeData.OutputAttributes(document, p, method.ReturnTypeCustomAttributes.GetCustomAttributes(false)); #if NET_2_0 // Generic constraints Type [] gargs = method.GetGenericArguments(); XmlElement ngeneric = (gargs.Length == 0) ? null : document.CreateElement("generic-method-constraints"); foreach (Type garg in gargs) { Type [] csts = garg.GetGenericParameterConstraints(); if (csts.Length == 0 || csts [0] == typeof(object)) { continue; } XmlElement el = document.CreateElement("generic-method-constraint"); el.SetAttribute("name", garg.ToString()); el.SetAttribute("generic-attribute", garg.GenericParameterAttributes.ToString()); ngeneric.AppendChild(el); foreach (Type ct in csts) { XmlElement cel = document.CreateElement("type"); cel.AppendChild(document.CreateTextNode(ct.FullName)); el.AppendChild(cel); } } if (ngeneric != null && ngeneric.FirstChild != null) { p.AppendChild(ngeneric); } #endif }
public override void DoOutput() { if (document == null) { throw new InvalidOperationException("Document not set"); } XmlNode nclass = document.CreateElement("class", null); AddAttribute(nclass, "name", type.Name); string classType = GetClassType(type); AddAttribute(nclass, "type", classType); if (type.BaseType != null) { AddAttribute(nclass, "base", type.BaseType.ToString()); } if (type.IsSealed) { AddAttribute(nclass, "sealed", "true"); } if (type.IsAbstract) { AddAttribute(nclass, "abstract", "true"); } if (type.IsSerializable) { AddAttribute(nclass, "serializable", "true"); } string charSet = GetCharSet(type); AddAttribute(nclass, "charset", charSet); string layout = GetLayout(type); if (layout != null) { AddAttribute(nclass, "layout", layout); } parent.AppendChild(nclass); AttributeData.OutputAttributes(document, nclass, type.GetCustomAttributes(false)); Type [] interfaces = type.GetInterfaces(); if (interfaces != null && interfaces.Length > 0) { XmlNode ifaces = document.CreateElement("interfaces", null); nclass.AppendChild(ifaces); foreach (Type t in interfaces) { if (!t.IsPublic) { // we're only interested in public interfaces continue; } XmlNode iface = document.CreateElement("interface", null); AddAttribute(iface, "name", t.ToString()); ifaces.AppendChild(iface); } } #if NET_2_0 // Generic constraints Type [] gargs = type.GetGenericArguments(); XmlElement ngeneric = (gargs.Length == 0) ? null : document.CreateElement("generic-type-constraints"); foreach (Type garg in gargs) { Type [] csts = garg.GetGenericParameterConstraints(); if (csts.Length == 0 || csts [0] == typeof(object)) { continue; } XmlElement el = document.CreateElement("generic-type-constraint"); el.SetAttribute("name", garg.ToString()); el.SetAttribute("generic-attribute", garg.GenericParameterAttributes.ToString()); ngeneric.AppendChild(el); foreach (Type ct in csts) { XmlElement cel = document.CreateElement("type"); cel.AppendChild(document.CreateTextNode(ct.FullName)); el.AppendChild(cel); } } if (ngeneric != null && ngeneric.FirstChild != null) { nclass.AppendChild(ngeneric); } #endif ArrayList members = new ArrayList(); FieldInfo[] fields = GetFields(type); if (fields.Length > 0) { Array.Sort(fields, MemberInfoComparer.Default); FieldData fd = new FieldData(document, nclass, fields); // Special case for enum fields if (classType == "enum") { string etype = fields [0].GetType().ToString(); AddAttribute(nclass, "enumtype", etype); } members.Add(fd); } ConstructorInfo [] ctors = GetConstructors(type); if (ctors.Length > 0) { Array.Sort(ctors, MemberInfoComparer.Default); members.Add(new ConstructorData(document, nclass, ctors)); } PropertyInfo[] properties = GetProperties(type); if (properties.Length > 0) { Array.Sort(properties, MemberInfoComparer.Default); members.Add(new PropertyData(document, nclass, properties)); } EventInfo [] events = GetEvents(type); if (events.Length > 0) { Array.Sort(events, MemberInfoComparer.Default); members.Add(new EventData(document, nclass, events)); } MethodInfo [] methods = GetMethods(type); if (methods.Length > 0) { Array.Sort(methods, MemberInfoComparer.Default); members.Add(new MethodData(document, nclass, methods)); } foreach (MemberData md in members) { md.DoOutput(); } Type [] nested = type.GetNestedTypes(); if (nested != null && nested.Length > 0) { XmlNode classes = document.CreateElement("classes", null); nclass.AppendChild(classes); foreach (Type t in nested) { TypeData td = new TypeData(document, classes, t); td.DoOutput(); } } }
public override void DoOutput() { if (document == null) { throw new InvalidOperationException("Document not set"); } XmlNode nassembly = document.CreateElement("assembly", null); AssemblyName aname = ass.GetName(); AddAttribute(nassembly, "name", aname.Name); AddAttribute(nassembly, "version", aname.Version.ToString()); parent.AppendChild(nassembly); AttributeData.OutputAttributes(document, nassembly, ass.GetCustomAttributes(false)); Type [] types = ass.GetExportedTypes(); if (types == null || types.Length == 0) { return; } Array.Sort(types, TypeComparer.Default); XmlNode nss = document.CreateElement("namespaces", null); nassembly.AppendChild(nss); string currentNS = "$%&$&"; XmlNode ns = null; XmlNode classes = null; foreach (Type t in types) { if (t.Namespace == null || t.Namespace == "") { continue; } if (t.IsNotPublic) { continue; } if (t.IsNestedPublic || t.IsNestedAssembly || t.IsNestedFamANDAssem || t.IsNestedFamORAssem || t.IsNestedPrivate) { continue; } if (t.DeclaringType != null) { continue; // enforce !nested } if (t.Namespace != currentNS) { currentNS = t.Namespace; ns = document.CreateElement("namespace", null); AddAttribute(ns, "name", currentNS); nss.AppendChild(ns); classes = document.CreateElement("classes", null); ns.AppendChild(classes); } TypeData bd = new TypeData(document, classes, t); bd.DoOutput(); } }