コード例 #1
0
        public void Load(string FileName)
        {
            XmlReaderSettings xrs = new XmlReaderSettings();

            XmlReader reader = XmlTextReader.Create(FileName, xrs);

            reader.ReadToFollowing("Project");
            string vers = reader.GetAttribute("FileVersion");

            if (vers == null || Convert.ToInt32(vers) != ProjectFileVersion)
            {
                throw new TooOldProjectFileVersion();
            }
            name = reader.GetAttribute("Name");
            path = FileName;
            string proj_dir = System.IO.Path.GetDirectoryName(FileName);

            //_project_directory = proj_dir;
            //path = reader.GetAttribute("Path");
            main_file        = System.IO.Path.Combine(proj_dir, reader.GetAttribute("MainFile"));
            output_file_name = reader.GetAttribute("OutputFileName");
            output_directory = System.IO.Path.Combine(proj_dir, reader.GetAttribute("OutputDirectory"));
            string s = reader.GetAttribute("ProjectType");

            project_type           = (ProjectType)ProjectType.Parse(typeof(ProjectType), s);
            include_debug_info     = Convert.ToBoolean(reader.GetAttribute("IncludeDebugInfo"));
            generate_xml_doc       = Convert.ToBoolean(reader.GetAttribute("GenerateXMLDoc"));
            command_line_arguments = reader.GetAttribute("CommandLineArguments");
            if (!string.IsNullOrEmpty(reader.GetAttribute("AppIcon")))
            {
                app_icon = System.IO.Path.Combine(proj_dir, reader.GetAttribute("AppIcon"));
            }
            delete_exe       = Convert.ToBoolean(reader.GetAttribute("DeleteEXE"));
            delete_pdb       = Convert.ToBoolean(reader.GetAttribute("DeletePDB"));
            product          = reader.GetAttribute("Product");
            company          = reader.GetAttribute("Company");
            trademark        = reader.GetAttribute("Trademark");
            copyright        = reader.GetAttribute("Copyright");
            major_version    = Convert.ToInt32(reader.GetAttribute("MajorVersion"));
            minor_version    = Convert.ToInt32(reader.GetAttribute("MinorVersion"));
            build_version    = Convert.ToInt32(reader.GetAttribute("BuildVersion"));
            revision_version = Convert.ToInt32(reader.GetAttribute("RevisionVersion"));
            reader.ReadToDescendant("Items");
            reader.ReadToDescendant("Item");
            string type = reader.GetAttribute("Type");

            if (type == "SourceFile")
            {
                SourceCodeFileInfo src = new SourceCodeFileInfo();
                src.name = reader.GetAttribute("Name");
                src.path = System.IO.Path.Combine(proj_dir, reader.GetAttribute("Path"));
                source_files.Add(src);
            }
            else if (type == "Reference")
            {
                ReferenceInfo ref_info = new ReferenceInfo();
                ref_info.assembly_name      = reader.GetAttribute("AssemblyName");
                ref_info.full_assembly_name = reader.GetAttribute("FullAssemblyName");
                references.Add(ref_info);
            }
            else if (type == "Resource")
            {
                ResourceInfo res_info = new ResourceInfo();
                res_info.name = reader.GetAttribute("Name");
                resources.Add(res_info);
            }
            while (reader.ReadToNextSibling("Item"))
            {
                type = reader.GetAttribute("Type");
                if (type == "SourceFile")
                {
                    SourceCodeFileInfo src = new SourceCodeFileInfo();
                    src.name = reader.GetAttribute("Name");
                    src.path = System.IO.Path.Combine(proj_dir, reader.GetAttribute("Path"));
                    source_files.Add(src);
                }
                else if (type == "Reference")
                {
                    ReferenceInfo ref_info = new ReferenceInfo();
                    ref_info.assembly_name      = reader.GetAttribute("AssemblyName");
                    ref_info.full_assembly_name = reader.GetAttribute("FullAssemblyName");
                    references.Add(ref_info);
                }
                else if (type == "Resource")
                {
                    ResourceInfo res_info = new ResourceInfo();
                    res_info.name = reader.GetAttribute("Name");
                    resources.Add(res_info);
                }
            }
            reader.ReadEndElement();
            reader.ReadEndElement();
            reader.Close();
        }
コード例 #2
0
ファイル: ProjectInfo.cs プロジェクト: lisiynos/pascalabcnet
		public void Load(string FileName)
		{
			XmlReaderSettings xrs = new XmlReaderSettings();
		    
			XmlReader reader = XmlTextReader.Create(FileName,xrs);
        	reader.ReadToFollowing("Project");
            string vers = reader.GetAttribute("FileVersion");
            if (vers == null || Convert.ToInt32(vers) != ProjectFileVersion)
                throw new TooOldProjectFileVersion();
        	name = reader.GetAttribute("Name");
            path = FileName;
            string proj_dir = System.IO.Path.GetDirectoryName(FileName);
            //_project_directory = proj_dir;
            //path = reader.GetAttribute("Path");
        	main_file = System.IO.Path.Combine(proj_dir, reader.GetAttribute("MainFile"));
        	output_file_name = reader.GetAttribute("OutputFileName");
        	output_directory = System.IO.Path.Combine(proj_dir, reader.GetAttribute("OutputDirectory"));
        	string s = reader.GetAttribute("ProjectType");
        	project_type = (ProjectType)ProjectType.Parse(typeof(ProjectType),s);
        	include_debug_info = Convert.ToBoolean(reader.GetAttribute("IncludeDebugInfo"));
        	generate_xml_doc = Convert.ToBoolean(reader.GetAttribute("GenerateXMLDoc"));
            command_line_arguments = reader.GetAttribute("CommandLineArguments");
            if (!string.IsNullOrEmpty(reader.GetAttribute("AppIcon")))
                app_icon = System.IO.Path.Combine(proj_dir, reader.GetAttribute("AppIcon"));
            delete_exe = Convert.ToBoolean(reader.GetAttribute("DeleteEXE"));
            delete_pdb = Convert.ToBoolean(reader.GetAttribute("DeletePDB"));
            product = reader.GetAttribute("Product");
            company = reader.GetAttribute("Company");
            trademark = reader.GetAttribute("Trademark");
            copyright = reader.GetAttribute("Copyright");
            major_version = Convert.ToInt32(reader.GetAttribute("MajorVersion"));
            minor_version = Convert.ToInt32(reader.GetAttribute("MinorVersion"));
            build_version = Convert.ToInt32(reader.GetAttribute("BuildVersion"));
            revision_version = Convert.ToInt32(reader.GetAttribute("RevisionVersion"));
            reader.ReadToDescendant("Items");
        	reader.ReadToDescendant("Item");
        	string type = reader.GetAttribute("Type");
        	if (type == "SourceFile")
        	{
        		SourceCodeFileInfo src = new SourceCodeFileInfo();
        		src.name = reader.GetAttribute("Name");
        		src.path = System.IO.Path.Combine(proj_dir, reader.GetAttribute("Path"));
        		source_files.Add(src);
        	}
        	else if (type == "Reference")
        	{
        		ReferenceInfo ref_info = new ReferenceInfo();
        		ref_info.assembly_name = reader.GetAttribute("AssemblyName");
        		ref_info.full_assembly_name = reader.GetAttribute("FullAssemblyName");
        		references.Add(ref_info);
        	}
        	else if (type == "Resource")
        	{
        		ResourceInfo res_info = new ResourceInfo();
        		res_info.name = reader.GetAttribute("Name");
        		resources.Add(res_info);
        	}
        	while (reader.ReadToNextSibling("Item"))
			{
        		type = reader.GetAttribute("Type");
        		if (type == "SourceFile")
        		{
        			SourceCodeFileInfo src = new SourceCodeFileInfo();
        			src.name = reader.GetAttribute("Name");
        			src.path = System.IO.Path.Combine(proj_dir, reader.GetAttribute("Path"));
        			source_files.Add(src);
        		}
        		else if (type == "Reference")
        		{
        			ReferenceInfo ref_info = new ReferenceInfo();
        			ref_info.assembly_name = reader.GetAttribute("AssemblyName");
        			ref_info.full_assembly_name = reader.GetAttribute("FullAssemblyName");
        			references.Add(ref_info);
        		}
        		else if (type == "Resource")
        		{
        			ResourceInfo res_info = new ResourceInfo();
        			res_info.name = reader.GetAttribute("Name");
        			resources.Add(res_info);
        		}
        	}
        	reader.ReadEndElement();
        	reader.ReadEndElement();
        	reader.Close();
		}