Beispiel #1
0
        }                                       // run the postflight

        public static PostflightObjC PostflightObjCForAssembly(string assemblyXmlPath)
        {
            PostflightObjC postflight = null;
            string         path       = null;

            if (assemblyXmlPath != null)
            {
                // get the postflight path
                path = Path.ChangeExtension(assemblyXmlPath, "codegen.postflight.objc.xml");

                if (File.Exists(path))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(PostflightObjC));
                    try
                    {
                        using (XmlReader reader = XmlReader.Create(path))
                        {
                            postflight = (PostflightObjC)deserializer.Deserialize(reader);
                        }
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }

            if (postflight == null)
            {
                postflight = new PostflightObjC();
            }

            return(postflight);
        }
Beispiel #2
0
 private static void Persist(PostflightObjC postflight, string path)
 {
     XmlSerializer serializer = new XmlSerializer(postflight.GetType());
     using (XmlWriter writer = XmlWriter.Create(path)) {
         serializer.Serialize(writer, postflight);
     } 
 }
Beispiel #3
0
        public bool RunPostflight { get; set; } // run the postflight

        public static PostflightObjC PostflightObjCForAssembly(string assemblyXmlPath)
        {
            PostflightObjC postflight = null;
            string path = null;

            if (assemblyXmlPath != null)
            {
                // get the postflight path
                path = Path.ChangeExtension(assemblyXmlPath, "codegen.postflight.objc.xml");

                if (File.Exists(path))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof (PostflightObjC));
                    try
                    {
                        using (XmlReader reader = XmlReader.Create(path))
                        {
                            postflight = (PostflightObjC) deserializer.Deserialize(reader);
                        }
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }

            if (postflight == null)
            {
                postflight = new PostflightObjC();
            }

            return postflight;
        }
Beispiel #4
0
        private static void Persist(PostflightObjC postflight, string path)
        {
            XmlSerializer serializer = new XmlSerializer(postflight.GetType());

            using (XmlWriter writer = XmlWriter.Create(path)) {
                serializer.Serialize(writer, postflight);
            }
        }
Beispiel #5
0
        private void ExportButton_Click(object sender, EventArgs args)
        {
            // get an export folder
            string outputPath = Properties.Settings.Default.ExportPath;

            if (string.IsNullOrEmpty(outputPath))
            {
                outputPath = Path.GetDirectoryName(_XMLFileName);
            }

            var dialog = new FolderBrowserDialog {
                ShowNewFolderButton = true, Description = "Select export folder:", SelectedPath = outputPath
            };

            if (FolderBrowserLauncher.ShowFolderBrowser(dialog, this) != DialogResult.OK || string.IsNullOrEmpty(dialog.SelectedPath))
            {
                return;
            }

            // generate output filenames
            string interfaceFile      = Path.Combine(dialog.SelectedPath, _codeGen.N2ObjC.InterfaceFile);
            string implementationFile = Path.Combine(dialog.SelectedPath, _codeGen.N2ObjC.ImplementationFile);

            try
            {
                bool ouputMonolithicInterface      = false;
                bool ouputMonolithicImplementation = false;

                // output interface
                if (ouputMonolithicInterface)
                {
                    File.WriteAllText(interfaceFile, _codeGen.N2ObjC.InterfaceOutput, Encoding.UTF8);
                }
                else
                {
                    GeneratedFileExporter.WriteAllText(Net2ObjC.OutputType.Interface, interfaceFile,
                                                       _codeGen.N2ObjC.InterfaceOutput);
                }

                // output implementation
                if (ouputMonolithicImplementation)
                {
                    File.WriteAllText(implementationFile, _codeGen.N2ObjC.ImplementationOutput, Encoding.UTF8);
                }
                else
                {
                    GeneratedFileExporter.WriteAllText(Net2ObjC.OutputType.Implementation, implementationFile,
                                                       _codeGen.N2ObjC.ImplementationOutput);
                }

                // do post flight processing
                PostflightObjC postflight = PostflightObjC.PostflightObjCForAssembly(_codeGen.N2ObjC.XMLFilePath);
                if (!postflight.Process())
                {
                    // problems
                    MessageBox.Show(string.Format("The code was exported to {0} but problems occurred during the postflight processing.", dialog.SelectedPath));
                }
                else
                {
                    // success
                    MessageBox.Show(string.Format("The code was successfully exported to {0}.", dialog.SelectedPath));
                }

                // persistence is not futile
                Properties.Settings.Default.ExportPath = dialog.SelectedPath;
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Exception: {0}.", e.ToString()));
            }
        }