コード例 #1
0
		public void Format(XpidlFile xpidlFile, TextWriter textWriter)
		{
			using (var codeDomProvider = CodeDomProvider.CreateProvider(Language))
			{
				CodeNamespace codeNamespace = CreateCodeNamespace(xpidlFile);
				codeDomProvider.GenerateCodeFromNamespace(codeNamespace, textWriter, Options);
			}
		}
コード例 #2
0
		private static CodeNamespace CreateCodeNamespace(XpidlFile xpidlFile)
		{
			var codeNamespace = new CodeNamespace("Xpcom.Interop");
			codeNamespace.Imports.Add(new CodeNamespaceImport("System"));
			codeNamespace.Imports.Add(new CodeNamespaceImport("System.Runtime.InteropServices"));

			// Add type declarations to namespace
			BuildCodeNamespace(codeNamespace, xpidlFile);

			return codeNamespace;
		}
コード例 #3
0
		private static void BuildCodeNamespace(CodeNamespace codeNamespace, XpidlFile xpidlFile)
		{
			for (Int32 i = 0; i < xpidlFile.ChildNodes.Count; ++i)
			{
				XpidlNode xpidlNode = xpidlFile.ChildNodes[i];

				if (xpidlNode is XpidlInterface)
				{
					var xpidlInterface = (XpidlInterface) xpidlNode;

					CodeTypeDeclaration codeConstClassDeclaration;
					CodeTypeDeclaration codeInterfaceDeclaration = CraeteCodeInterfaceDeclaration(xpidlInterface, out codeConstClassDeclaration);

					if (codeConstClassDeclaration != null)
					{
						codeConstClassDeclaration.Comments.AddComment(String.Format("Constants for {0} ( \"{1}\" ) interface", xpidlInterface.Name, xpidlInterface.Uuid));
						codeNamespace.Types.Add(codeConstClassDeclaration);
					}

					codeInterfaceDeclaration.Comments.AddPrecedingComments(xpidlFile, i);
					codeNamespace.Types.Add(codeInterfaceDeclaration);
				}
			}
		}