コード例 #1
0
ファイル: dbus2cs.cs プロジェクト: TallGuy74/dbus2cs
 public static void WriteInterface(XmlNode node, TabStringBuilder builder)
 {
     foreach(XmlNode doc in node.ChildNodes)
         if (doc.Name == "doc:doc")
         {
             builder.AppendLine(1, "/// <summary>");
             foreach (string line in doc.InnerText.Trim().Split(new string[] { Environment.NewLine, "\n" }, StringSplitOptions.None))
                 builder.AppendLine(1, "/// {0}", line.Trim());
             builder.AppendLine(1, "/// </summary>");
         }
     string raw = node.Attributes["name"].Value;
     builder.AppendLine(1, "[Interface(\"{0}\")]", raw);
     string[] split = raw.Split('.');
     builder.Append(1, "public interface {0}{1}\t{{{1}", split[split.Length - 1], Environment.NewLine);
     foreach (XmlNode typeNode in node.ChildNodes)
     {
         switch (typeNode.Name)
         {
             case ("method"):
                 //if (typeNode.Attributes["name"].Value.ToLower().StartsWith("get") || typeNode.Attributes["name"].Value.ToLower().StartsWith("set"))
                 //{
                 //    WriteProperty(typeNode, builder);
                 //}
                 //else
                 WriteComment(typeNode, builder);
                     WriteMethod(typeNode, builder);
                 break;
             case ("signal"):
                 WriteComment(typeNode, builder);
                 WriteEvent(typeNode, builder);
                 break;
             case ("error"):
                 break;//make custom error types?
         }
     }
     builder.AppendLine(1, "}}{0}", Environment.NewLine);
 }
コード例 #2
0
ファイル: dbus2cs.cs プロジェクト: TallGuy74/dbus2cs
 public static void WriteNamespace(XmlNode node, TabStringBuilder builder)
 {
     //string[] split = node.FirstChild.Attributes["name"].Value.Split('.');
     //builder.Append("namespace ");
     //for (int i = 1; i < split.Length; i++)
     //{
     //    builder.Append(split[i]);
     //    if (i < split.Length - 1)
     //        builder.Append(".");
     //}
     builder.Append("namespace {0}", Namespace == string.Empty ? "DefaultNamespace" : Namespace);
     builder.AppendLine("{0}{{", Environment.NewLine);
     foreach (XmlNode inter in node.SelectNodes("interface"))
     {
         WriteInterface(inter, builder);
     }
     builder.Append(StructsEtc);
     builder.Append("}");
 }