コード例 #1
0
ファイル: ConfigObjC.cs プロジェクト: BoldonJames/Dubrovnik
        /// <summary>
        /// Object startup.
        /// </summary>
        private void Startup(string xmlPath)
        {
            // we want to remove relative path information in this method as its quite easy to
            // trigger PathTooLongException when iterating over the reference list
            xmlPath = Path.GetFullPath(xmlPath);

            AssemblyFolder = System.IO.Path.GetDirectoryName(xmlPath);

            // Process the reference list
            // and load other xml config data to be merged into the current configuration.
            // This process educates the current object about the types in
            // referenced assemblies eg: type skipping info.
            foreach (string refPath in ReferenceList)
            {
                string path = refPath;
                // fix up relative reference path
                if (!Path.IsPathRooted(refPath))
                {
                    path = Path.Combine(AssemblyFolder, refPath);
                    path = Path.GetFullPath(path);
                }
                ConfigObjC config = ConfigObjCForAssembly(path);
                Merge(config);
            }
        }
コード例 #2
0
        // This method is referenced in the t4 file
        private void _TransformText()
        {
            // build an operation log
            StringBuilder log = new StringBuilder();

            // get configuration info for the assembly
            Config = ConfigObjC.ConfigObjCForAssembly(XMLFilePath);

            // generate the interface
            log.AppendFormat("Generating interface file {0}...\n", this.InterfaceFile);
            OutputFileType = OutputType.Interface;
            GenerateObjC(null);
            InterfaceOutput = Output();
            log.AppendFormat("Interface file {0} done\n", this.InterfaceFile);

            // generate the implementation
            string include = string.Format("#import \"{0}\"", this.InterfaceFile);

            log.AppendFormat("Generating implementation file {0}...\n", this.ImplementationFile);
            OutputFileType = OutputType.Implementation;
            GenerateObjC(include);
            ImplementationOutput = Output();
            log.AppendFormat("Implementation file {0} done\n", this.ImplementationFile);

            // write the log string as the final output of this template
            WriteLine(log.ToString());
        }
コード例 #3
0
ファイル: ConfigObjC.cs プロジェクト: Numpsy/Dubrovnik
 private static void Persist(ConfigObjC config, string path)
 {
     XmlSerializer serializer = new XmlSerializer(config.GetType());
     using (XmlWriter writer = XmlWriter.Create(path)) {
         serializer.Serialize(writer, config);
     }
 }
コード例 #4
0
ファイル: ConfigObjC.cs プロジェクト: Numpsy/Dubrovnik
        public static ConfigObjC ConfigObjCForAssembly(string assemblyXmlPath)
        {
            ConfigObjC config = null;
            string path = null;

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

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

            if (config == null)
            {
                config = new ConfigObjC();
            }

            return config;
        }
コード例 #5
0
ファイル: ConfigObjC.cs プロジェクト: BoldonJames/Dubrovnik
        private static void Persist(ConfigObjC config, string path)
        {
            XmlSerializer serializer = new XmlSerializer(config.GetType());

            using (XmlWriter writer = XmlWriter.Create(path)) {
                serializer.Serialize(writer, config);
            }
        }
コード例 #6
0
ファイル: ConfigObjC.cs プロジェクト: BoldonJames/Dubrovnik
 /// <summary>
 /// Merge another object representing a dependency into this object.
 /// </summary>
 /// <param name="config">Object to merge in.</param>
 private void Merge(ConfigObjC config)
 {
     foreach (string name in config.TypeNameSkipList)
     {
         if (!TypeNameSkipList.Contains(name))
         {
             TypeNameSkipList.Add(name);
         }
     }
     foreach (string name in config.TypeNameWhiteList)
     {
         if (!TypeNameWhiteList.Contains(name))
         {
             TypeNameWhiteList.Add(name);
         }
     }
 }
コード例 #7
0
ファイル: ConfigObjC.cs プロジェクト: BoldonJames/Dubrovnik
        public static ConfigObjC ConfigObjCForAssembly(string assemblyXmlPath)
        {
            ConfigObjC config = null;
            string     path   = null;

            if (assemblyXmlPath != null)
            {
                // get the config path
                if (Path.GetExtension(assemblyXmlPath).ToLower() != ".xml")
                {
                    throw new ArgumentException($"Assembly XML file path does not have .xml extension : {assemblyXmlPath}");
                }
                path = Path.ChangeExtension(assemblyXmlPath, "codegen.config.objc.xml");

                // load the config xml
                if (File.Exists(path))
                {
                    XmlSerializer deserializer = new XmlSerializer(typeof(ConfigObjC));
                    try {
                        using (XmlReader reader = XmlReader.Create(path)) {
                            config = (ConfigObjC)deserializer.Deserialize(reader);
                        }

                        config.Startup(path);
                    } catch (Exception e) {
                        throw e;
                    }
                }
                else
                {
                    Console.WriteLine($"WARNING: Assembly configuration file not found at : {path}");
                }
            }

            if (config == null)
            {
                config = new ConfigObjC();
            }

            return(config);
        }
コード例 #8
0
        /// <summary>
        /// Object startup.
        /// </summary>
        private void Startup(string xmlPath)
        {
            // we want to remove relative path information in this method as its quite easy to
            // trigger PathTooLongException when iterating over the reference list
            xmlPath = Path.GetFullPath(xmlPath);

            AssemblyFolder = System.IO.Path.GetDirectoryName(xmlPath);

            const char nixDirSeparator = '/';
            const char winDirSeparator = '\\';

            char currentDirSeparator = Path.DirectorySeparatorChar;

            // If we're running on Windows, replace all occurences of the *NIX dir separator (slash) with the Windows dir separator (bashslash)
            // On the other hand, if we're running on *NIX, replace all occurrences of the Windows dir separator (backslash) with the *NIX dir separator (slash)
            char dirSeparatorToReplace = currentDirSeparator == winDirSeparator ? nixDirSeparator : winDirSeparator;

            // Process the reference list
            // and load other xml config data to be merged into the current configuration.
            // This process educates the current object about the types in
            // referenced assemblies eg: type skipping info.
            foreach (string refPath in ReferenceList)
            {
                string path = refPath.Replace(dirSeparatorToReplace, currentDirSeparator);

                string fullPath = path;

                // fix up relative reference path
                if (!Path.IsPathRooted(path))
                {
                    fullPath = Path.Combine(AssemblyFolder, path);
                    fullPath = Path.GetFullPath(fullPath);
                }
                ConfigObjC config = ConfigObjCForAssembly(fullPath);
                Merge(config);
            }
        }