//=========================================================================================== private ExceptionGenerator() : base(@"GraphicsMagick.NET.AnyCPU\Generated") { _Exceptions = (from type in GraphicsMagickNET.GetPublicTypes(false) where type.IsSubclassOf(typeof(Exception)) select type).ToArray(); }
//=========================================================================================== protected Type[] GetTypes(bool withEnums) { return((from type in GraphicsMagickNET.GetPublicTypes(withEnums) where !type.IsSubclassOf(typeof(Exception)) orderby type.Name select type).ToArray()); }
//=========================================================================================== private XsdGenerator(QuantumDepth depth) { _Depth = depth; _GraphicsMagickNET = new GraphicsMagickNET(depth); _Namespaces = new XmlNamespaceManager(new NameTable()); _Namespaces.AddNamespace("xs", _Namespace.ToString()); }
//=========================================================================================== private void CopyXmlResources() { string folder = GraphicsMagickNET.GetFolderName(GraphicsMagickNET.Depth); DirectoryInfo source = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\..\GraphicsMagick.NET\Resources\xml"); string destination = OutputFolder + @"..\Resources\xml\"; Directory.CreateDirectory(Path.GetDirectoryName(destination)); foreach (FileInfo file in source.GetFiles("*.mgk")) { File.Copy(file.FullName, destination + file.Name, true); } }
//=========================================================================================== private void Write() { string folder = GraphicsMagickNET.GetFolderName(_Depth); string outputFile = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\..\GraphicsMagick.NET\Resources\" + folder + @"\MagickScript.xsd"); Console.WriteLine("Creating: " + outputFile); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; using (XmlWriter writer = XmlWriter.Create(outputFile, settings)) { _Document.Save(writer); } }
//=========================================================================================== private void WriteExecute(IndentedTextWriter writer, MethodBase[] methods) { writer.Write(ReturnType); writer.Write(" MagickScript::Execute"); writer.Write(GraphicsMagickNET.GetName(methods[0])); writer.Write("("); if (!IsStatic(methods)) { writer.Write("XmlElement^ element, "); } writer.Write(ExecuteArgument); writer.WriteLine(")"); WriteStartColon(writer); WriteMethod(writer, methods); WriteEndColon(writer); }
//=========================================================================================== private void WriteHeader(IndentedTextWriter writer, MethodBase[] methods) { bool isStatic = IsStatic(methods); if (isStatic) { writer.Write("static "); } writer.Write(ReturnType); writer.Write(" Execute"); writer.Write(GraphicsMagickNET.GetName(methods[0])); writer.Write("("); if (!isStatic) { writer.Write("XmlElement^ element, "); } writer.Write(ExecuteArgument); writer.WriteLine(");"); }
//=========================================================================================== private void WriteExecute(IndentedTextWriter writer, string name) { MemberInfo member = (from property in Properties where MagickNET.GetXsdName(property).Equals(name, StringComparison.OrdinalIgnoreCase) select property).FirstOrDefault(); if (member == null) { member = (from overloads in Methods let method = overloads[overloads.Length - 1] where MagickNET.GetXsdName(method).Equals(name, StringComparison.OrdinalIgnoreCase) select method).FirstOrDefault(); } if (ReturnType != "void") { writer.Write("return "); } writer.Write("Execute"); if (member == null) { writer.Write(char.ToUpper(name[0])); writer.Write(name.Substring(1)); } else { writer.Write(GraphicsMagickNET.GetName(member)); } writer.Write("("); if (member == null || !IsStatic(member)) { writer.Write("element, "); } writer.Write(ExecuteArgument.Split(' ').Last()); writer.WriteLine(");"); if (ReturnType == "void") { writer.WriteLine("return;"); } }
//=========================================================================================== public string GetXsdName(MemberInfo member) { return(GetXsdName(GraphicsMagickNET.GetName(member))); }
//=========================================================================================== protected CodeGenerator() { _GraphicsMagickNET = new GraphicsMagickNET(QuantumDepth.Q16); }
//=========================================================================================== protected FileGenerator(string outputFolder, QuantumDepth depth) { OutputFolder = SetOutputFolder(outputFolder + "\\" + GraphicsMagickNET.GetFolderName(depth)); _GraphicsMagickNET = new GraphicsMagickNET(depth); }
//=========================================================================================== protected FileGenerator(string outputFolder) { OutputFolder = SetOutputFolder(outputFolder); _GraphicsMagickNET = new GraphicsMagickNET(QuantumDepth.Q16); }
//=========================================================================================== protected static void WriteType(IndentedTextWriter writer, Type type) { writer.Write(GraphicsMagickNET.GetTypeName(type)); }