public static CSharpSourceFile FromObject(ApiObject obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } var sourceFile = new CSharpSourceFile { Name = obj.Name.ToBeautifiedName(), Usings = DefaultUsings }; if (obj.IsEnum()) { sourceFile.Enum = CSharpEnum.FromObject(obj); } else if (obj.IsClass()) { sourceFile.Class = CSharpClass.Map(obj); } else { return(null); } return(sourceFile); }
public static CSharpSourceFile FromMethods(ApiMethod[] methods, bool asInterface) { var name = methods[0].Category.ToBeautifiedName(); var sourceFile = new CSharpSourceFile { Name = asInterface ? 'I' + name : name, Usings = DefaultUsings, Namespace = NamespaceName }; if (asInterface) { sourceFile.Interface = CSharpInterface.FromMethods(methods); } else { sourceFile.Class = CSharpClass.FromMethods(methods); } return(sourceFile); }