public static void Parse(TheMethod pMethod, CodeBuilder pBuilder, FactoryExpressionCreator pCreator) {
			if (pMethod == null) return;
			bool isInterface = pMethod.MyClass.IsInterface;

			Dictionary<string,string> nonValidMethod = new Dictionary<string, string>(_notValidMethodMod);
			if (ClassParser.IsExtension) {
				nonValidMethod.Add("static",string.Empty);
			}

			pBuilder.AppendFormat("{0}function {1}({2}):{3}{4}",
				As3Helpers.ConvertModifiers(pMethod.Modifiers, nonValidMethod),
				pMethod.Name,
				As3Helpers.GetParameters(pMethod.Arguments),
				As3Helpers.Convert(pMethod.ReturnType),
				isInterface ? ";":" {"
			);

			pBuilder.AppendLine();

			if (isInterface)
				return;

			pBuilder.AppendLine();
			BlockParser.Parse(pMethod.CodeBlock, pBuilder, pCreator);
			pBuilder.AppendLine();
			pBuilder.AppendLine("}");
			pBuilder.AppendLine();
		}
Exemple #2
0
        static void Main(string[] args)
        {
            CodeTypeDeclaration MyClass = Class("MyClass");

            MyClass.Add(Method("StrLen", Type(typeof(int))));
            TheMethod.Add(Parameter(typeof(string), "str"));
            TheMethod.Return(Expression("str.Length"));

            CSharpCodeProvider Provider = new CSharpCodeProvider();

            Provider.GenerateCodeFromType(MyClass, Console.Out, new System.CodeDom.Compiler.CodeGeneratorOptions());
            Console.ReadKey();
        }
Exemple #3
0
        public static void Parse(TheMethod pMethod, CodeBuilder pBuilder, FactoryExpressionCreator pCreator)
        {
            if (pMethod == null)
            {
                return;
            }
            bool isInterface = pMethod.MyClass.IsInterface;

            Dictionary <string, string> nonValidMethod = new Dictionary <string, string>(_notValidMethodMod);

            if (ClassParser.IsExtension)
            {
                nonValidMethod.Add("static", string.Empty);
            }

            pBuilder.AppendFormat("{0}function {1}({2}):{3}{4}",
                                  As3Helpers.ConvertModifiers(pMethod.Modifiers, nonValidMethod),
                                  pMethod.Name,
                                  As3Helpers.GetParameters(pMethod.Arguments),
                                  As3Helpers.Convert(pMethod.ReturnType),
                                  isInterface ? ";":" {"
                                  );

            pBuilder.AppendLine();

            if (isInterface)
            {
                return;
            }

            pBuilder.AppendLine();
            BlockParser.Parse(pMethod.CodeBlock, pBuilder, pCreator);
            pBuilder.AppendLine();
            pBuilder.AppendLine("}");
            pBuilder.AppendLine();
        }