Exemplo n.º 1
0
		public static string Print(string name, string type, string scope, string access, ExtDescription desc) {
			ExtProperty prop = new ExtProperty {
				Name = name,
				Type = type,
				Scope = scope,
				Access = access,
				Description = desc
			};
			return prop.ToExtSharp();
		}
Exemplo n.º 2
0
		public string ToExtSharp() {
			string newName = ExtType.ParseClassName(FullyQualifiedName);
			if (newName != Name) {
				SourceConverter.ClassAliases.Add(FullyQualifiedName, FullyQualifiedName.Replace(Name, newName));
			}

			StringBuilder sb = new StringBuilder();
			sb.AppendLine("using System;");
			sb.AppendLine("using System.DotWeb;");
			sb.AppendLine("using DotWeb.Client;");
			sb.AppendLine();

			sb.AppendLine("namespace " + (String.IsNullOrEmpty(Namespace) ? "Ext" : Namespace) + " {");

			if (SourceConverter.ShowDoc)
				sb.AppendFormat("\t/// <summary>{0}</summary>\r\n", Description.GetDocComment("\t"));
			sb.AppendFormat("\t/// <jssource>{0}</jssource>\r\n", SourceFile);
			if (String.IsNullOrEmpty(Namespace)) 
				sb.AppendLine("\t[JsNamespace()]");
			if (string.IsNullOrEmpty(SuperClass))
				sb.AppendLine("\t[JsObject]");
			sb.AppendFormat("\tpublic class {0} ", newName);
			if (!String.IsNullOrEmpty(SuperClass))
				sb.Append(": " + ExtType.ParseType(SuperClass));
			sb.AppendLine(" {");
			sb.AppendLine();

			sb.Append(Constructors.ToExtSharp());
			sb.AppendLine();

			sb.AppendLine("\t\t/// <summary></summary>");
			ExtDescription desc = new ExtDescription("The reference to the prototype the every object of this type is constructed with");
			sb.Append(ExtProperty.Print("prototype", newName, "static", "public", desc));
			sb.AppendLine();

			desc = new ExtDescription("The reference to the constructor function");
			sb.Append(ExtProperty.Print("constructor", "Delegate", "static", "public", desc));
			sb.AppendLine();

			if (!String.IsNullOrEmpty(SuperClass)) {
				desc = new ExtDescription("The reference to the class that this class inherits from");
				sb.Append(ExtProperty.Print("superclass", ExtType.ParseType(SuperClass), "static", "public", desc));
				sb.AppendLine();
			}
			sb.Append(Properties.ToExtSharp());
			sb.AppendLine();

			sb.Append(Methods.ToExtSharp());
			sb.AppendLine();

			sb.Append(SourceConverter.GetMissingCode(FullyQualifiedName));
			sb.AppendLine();

			sb.AppendLine("\t}"); // class
			if (Configs.Any()) {
				sb.AppendLine();
				sb.Append(Configs.ToExtSharp(this));
			}
			if (Events.Any()) {
				sb.AppendLine();
				sb.Append(Events.ToExtSharp(Name));
				sb.AppendLine();
				sb.Append(Events.Delegates(Name));
			}
			sb.AppendLine("}"); // namespace
			return sb.ToString();
		}