Пример #1
0
        public CodeTypeDeclaration CreateClass(ClassNameDef ClassName)
        {
            var unit = new CodeCompileUnit();

            Units.Add(unit);
            var ns = new CodeNamespace(PackageName);

            unit.Namespaces.Add(ns);

            var CurrentClass = new CodeTypeDeclaration(ClassName.ActionScriptName)
            {
                IsClass = true,
            };

            ClassName2TypeDecl.Add(ClassName.ActionScriptName, CurrentClass);

            CodeAttributeDeclaration JavascriptAttrDecl = new CodeAttributeDeclaration("JavaScript", new CodeAttributeArgument("export", new CodePrimitiveExpression("false")));

            CurrentClass.CustomAttributes.Add(JavascriptAttrDecl);

            CurrentClass.TypeAttributes = CurrentClass.TypeAttributes | TypeAttributes.Public;
            unit.UserData["NameDef"]    = ClassName;
            if ((ClassName.ActionScriptName != ClassName.JavascriptName) && (ClassName.JavascriptName != null))
            {
                CurrentClass.CustomAttributes[0].Arguments.Add(new CodeAttributeArgument("name", new CodePrimitiveExpression(ClassName.JavascriptName)));
            }
            CurrentClass.UserData["references"]    = new CodeCommentStatementCollection();
            Class2Unit[ClassName.ActionScriptName] = unit;
            ns.Types.Add(CurrentClass);
            return(CurrentClass);
        }
Пример #2
0
 private static void AddHeightStyleEnum(CodeMemberField field, List<XElement> RawEnumValues)
 {
     if (Builder.GetClassByName("HeightStyles") == null)
     {
         var NameDef = new ClassNameDef() { ActionScriptName = "HeightStyles" };
         var EnumClass = Builder.CreateClass(NameDef);
         RawEnumValues.ForEach(v => CreateEnumValue(EnumClass, v));
     }
 }
Пример #3
0
 private static ClassNameDef CreateClassName(String FileName, XDocument xdoc)
 {
     ClassNameDef result = new ClassNameDef();
     String ClassName = null;
     if ((xdoc.Root.Attribute("type") != null) && (xdoc.Root.Attribute("type").Value == "widget"))
     {
         ClassName = CapitalizeName(xdoc.Root.Attribute("name").Value);
     }
     else if ((xdoc.Root.Attribute("type") != null) && (xdoc.Root.Attribute("type").Value == "method"))
     {
         ClassName = "JQueryUI";
         result.JavascriptName = "JQuery";
     }
     else if (FileName.IndexOf('.') > -1)
     {
         var parts = FileName.Split('.');
         if (parts[0].ToLower() != "jquery")
         {
             ClassName = CapitalizeName(parts[0]);
         }
         else
         {
             ClassName = "JQueryStaticUI";
             result.JavascriptName = "JQuery";
         }
     }
     else
     {
         if (xdoc.Root.Attributes("return").Count() > 0)
         {
             ClassName = CapitalizeName(xdoc.Root.Attribute("return").Value);
             result.JavascriptName  = ClassName;
             if (ClassName.Length == 0)
             {
                 return null;
             }
         }
         else
         {
             if (xdoc.Root.Name == "entries")
             {
                 ClassName = CapitalizeName(xdoc.Root.Elements("entry").ToList<XElement>()[0].Attribute("return").Value);
             }
             else
             {
                 return null;
             }
         }
     }
     ClassName = TranslateClassName(ClassName);
     ClassName = CapitalizeName(ClassName);
     result.ActionScriptName = ClassName;
     if (ClassName == "JQueryUI")
     {
         result.Extends = "JQuery";
     }
     return result;
 }
Пример #4
0
 private static string CreateTypedObjectForPlainObject(string BaseName, XElement Elm)
 {
     var propertyElms = Elm.Elements("property");
     var ClassName = new ClassNameDef() { ActionScriptName = CapitalizeName(BaseName) + "Object" };
     if (ClassLookup.ContainsKey(ClassName.ActionScriptName))
     {
         throw new Exception("Class name already exists: " + ClassName.ActionScriptName);
     }
     var classDef = Builder.CreateClass(ClassName);
     ClassLookup[ClassName.ActionScriptName] = classDef;
     foreach (var prop in propertyElms)
     {
         AddProperty(prop, classDef);
     }
     return ClassName.ActionScriptName;
 }
Пример #5
0
 private static CodeTypeDeclaration CreateArgumentObjectClass(string RawClassName, XDocument xdoc)
 {
     var Name = FormatFromHypenatedName(RawClassName);
     if (ClassLookup.ContainsKey(Name))
     {
         return ClassLookup[Name];
     }
     var NameDef = new ClassNameDef() {ActionScriptName = Name, Extends = "Argument" };
     var classDef = Builder.CreateClass(NameDef);
     ClassLookup[Name] = classDef;
     xdoc.Root.Elements("property").ToList<XElement>().ForEach(e => AddMemberFromPropertyElement(classDef, e));
     return classDef;
 }
Пример #6
0
        private static void CreateCompileUnit(JToken ClassToken, string FileName)
        {
            var className = new ClassNameDef() { ActionScriptName = FormatClassName((String)ClassToken["name"]), JavascriptName = (String)ClassToken["name"] };
            var type = Builder.CreateClass(className);
            type.Comments.Add(new CodeCommentStatement("Generated from file: " + FileName, true));

            AddMembers(type, ClassToken, true);

            if (ClassToken["classes"] != null)
            {
                AddClasses(ClassToken["classes"], FileName);
            }

            Console.WriteLine("Created: " + className.ActionScriptName);
        }
Пример #7
0
 private static void CreateClass(JToken ClassToken, string FileName)
 {
     var type = Builder.GetClassByName((String)ClassToken["name"]);
     if (type == null)
     {
         var name = new ClassNameDef() { ActionScriptName = FormatClassName((String)ClassToken["name"]), JavascriptName = (String)ClassToken["name"] };
         type = Builder.CreateClass(name);
         type.Comments.Add(new CodeCommentStatement("Generated from file: " + FileName, true));
     }
     AddMembers(type, ClassToken, false);
 }
Пример #8
0
        public CodeTypeDeclaration CreateClass(ClassNameDef ClassName)
        {
            var unit = new CodeCompileUnit();
                Units.Add(unit);
                var ns = new CodeNamespace(PackageName);
                unit.Namespaces.Add(ns);

                var CurrentClass = new CodeTypeDeclaration(ClassName.ActionScriptName) { IsClass= true, };

                ClassName2TypeDecl.Add(ClassName.ActionScriptName, CurrentClass);

                CodeAttributeDeclaration JavascriptAttrDecl = new CodeAttributeDeclaration("JavaScript", new CodeAttributeArgument("export", new CodePrimitiveExpression("false")));
                CurrentClass.CustomAttributes.Add(JavascriptAttrDecl);

                CurrentClass.TypeAttributes = CurrentClass.TypeAttributes |  TypeAttributes.Public;
                unit.UserData["NameDef"] = ClassName;
                if ((ClassName.ActionScriptName != ClassName.JavascriptName) && (ClassName.JavascriptName != null))
                {
                    CurrentClass.CustomAttributes[0].Arguments.Add(new CodeAttributeArgument("name", new CodePrimitiveExpression(ClassName.JavascriptName)));
                }
                CurrentClass.UserData["references"] = new CodeCommentStatementCollection();
                Class2Unit[ClassName.ActionScriptName] = unit;
                ns.Types.Add(CurrentClass);
                return CurrentClass;
        }