internal void AddTypeMetadata(CodeAttributeDeclarationCollection metadata, Type type, string defaultName, string name, string ns, bool includeInSchema) {
CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(type.FullName);
if (name == null || name.Length == 0) {
attribute.Arguments.Add(new CodeAttributeArgument("AnonymousType", new CodePrimitiveExpression(true)));
}
else {
if (defaultName != name) {
attribute.Arguments.Add(new CodeAttributeArgument("TypeName", new CodePrimitiveExpression(name)));
}
if (ns != null && ns.Length != 0) {
attribute.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(ns)));
}
}
if (!includeInSchema) {
attribute.Arguments.Add(new CodeAttributeArgument("IncludeInSchema", new CodePrimitiveExpression(false)));
}
if (attribute.Arguments.Count > 0) {
metadata.Add(attribute);
}
}