static void GenerateDesignerCode (CodeBehindWriter writer, ProjectFile xibFile, ProjectFile designerFile) { var ns = new CodeNamespace (((DotNetProject)designerFile.Project).GetDefaultNamespace (designerFile.FilePath)); var ccu = new CodeCompileUnit (); ccu.Namespaces.Add (ns); foreach (var ctd in CodeBehindGenerator.GetTypes (XDocument.Load (xibFile.FilePath), writer.Provider, writer.GeneratorOptions)) ns.Types.Add (ctd); writer.Write (ccu, designerFile.FilePath); }
internal void GenerateDesignerCode (CodeBehindWriter writer, ProjectFile xibFile, ProjectFile designerFile) { var ccu = Generate (xibFile, writer.Provider, writer.GeneratorOptions); writer.Write (ccu, designerFile.FilePath); }
private static void GenerateXibDesignCode(CodeBehindWriter writer, ProjectFile file, ProjectFile designerFile) { // Create the compilation unit CodeCompileUnit ccu = new CodeCompileUnit (); CodeNamespace ns = new CodeNamespace (((DotNetProject)file.Project).GetDefaultNamespace (designerFile.FilePath)); ccu.Namespaces.Add (ns); // Add namespaces ns.Imports.AddRange(CodeBehindGenerator.GetNamespaces(file.Project)); // Parse the XIB document to collect the class names and their definitions IBDocument document = IBDocument.LoadFromFile (file.FilePath.FullPath); ClassDescriptionCollector collector = new ClassDescriptionCollector (); document.Root.Accept (collector); // Iterate over the extracted class names foreach (String className in collector.ClassNames) { CodeTypeDeclaration ctd = CodeBehindGenerator.GetType(collector, writer, className); if (ctd != null) { ns.Types.Add(ctd); } } // Write the result writer.Write (ccu, designerFile.FilePath); }