/// <summary> /// Return a string representing the TypeData as a Class. /// </summary> /// <returns></returns> public override string ToString() { var super = "BaseIfc"; var newMod = string.Empty; if (Subs.Any()) { super = Subs[0].Name;; newMod = "new"; } var modifier = IsAbstract? "abstract":string.Empty; // Create two constructors, one which includes optional parameters and // one which does not. We need to check whether any of the parent types // have optional attributes as well, to avoid the case where the current type // doesn't have optional parameters, but a base type does. string constructors; if (ParentsAndSelf().SelectMany(e => e.Attributes.Where(a => a.IsOptional)).Any()) { constructors = $@" /// <summary> /// Construct a {Name} with all required attributes. /// </summary> public {Name}({ConstructorParams(false)}):base({BaseConstructorParams(false)}) {{ {Assignments(false)} }} /// <summary> /// Construct a {Name} with required and optional attributes. /// </summary> [JsonConstructor] public {Name}({ConstructorParams(true)}):base({BaseConstructorParams(true)}) {{ {Assignments(true)} }}" ; } else { constructors = $@" /// <summary> /// Construct a {Name} with all required attributes. /// </summary> [JsonConstructor] public {Name}({ConstructorParams(false)}):base({BaseConstructorParams(false)}) {{ {Assignments(false)} }}" ; } var classStr = $@" /// <summary> /// <see href=""http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/{Name.ToLower()}.htm""/> /// </summary> public {modifier} partial class {Name} : {super} {{{Properties()}{constructors} public static {newMod} {Name} FromJSON(string json) {{ return JsonConvert.DeserializeObject<{Name}>(json); }} }}" ; return(classStr); }