//=========================================================================================== private void WriteCallMethods(IndentedTextWriter writer) { foreach (MethodBase method in Methods) { string xsdMethodName = MagickNET.GetXsdName(method); ParameterInfo[] parameters = method.GetParameters(); writer.Write("XmlElement^ "); writer.Write(xsdMethodName); writer.Write(" = (XmlElement^)element->SelectSingleNode(\""); writer.Write(xsdMethodName); writer.WriteLine("\");"); writer.Write("if ("); writer.Write(xsdMethodName); writer.WriteLine(" != nullptr)"); writer.WriteLine("{"); writer.Indent++; foreach (ParameterInfo parameter in parameters) { string typeName = MagickNET.GetCppTypeName(parameter); writer.Write(typeName); writer.Write(" "); writer.Write(parameter.Name); writer.Write("_ = XmlHelper::GetAttribute<"); writer.Write(typeName); writer.Write(">("); writer.Write(xsdMethodName); writer.Write(", \""); writer.Write(parameter.Name); writer.WriteLine("\");"); } writer.Write("result->"); writer.Write(method.Name); writer.Write("("); for (int i = 0; i < parameters.Length; i++) { if (i > 0) { writer.Write(","); } writer.Write(parameters[i].Name); writer.Write("_"); } writer.WriteLine(");"); writer.Indent--; writer.WriteLine("}"); } }
//=========================================================================================== private void WriteGetValue(IndentedTextWriter writer, PropertyInfo property) { string typeName = MagickNET.GetCppTypeName(property); string xsdTypeName = MagickNET.GetXsdAttributeType(property); if (xsdTypeName != null) { WriteGetElementValue(writer, typeName, MagickNET.GetXsdName(property)); } else { WriteCreateMethod(writer, typeName); writer.Write("("); WriteSelectElement(writer, typeName, MagickNET.GetXsdName(property)); 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;"); } }
//=========================================================================================== private void WriteExecute(IndentedTextWriter writer) { writer.Write(ReturnType); writer.Write(" MagickScript::Execute"); writer.Write(ExecuteName); writer.Write("(XmlElement^ element, "); writer.Write(ExecuteArgument); writer.WriteLine(")"); WriteStartColon(writer); IEnumerable <string> names = (from property in Properties select MagickNET.GetXsdName(property)).Concat( from method in Methods select MagickNET.GetXsdName(method[0])).Concat( CustomMethods); WriteSwitch(writer, names, 0); writer.WriteLine("throw gcnew NotImplementedException(element->Name);"); WriteEndColon(writer); }