コード例 #1
0
 public static void MergeClasses(List <ClassExpression> classes, ClassExpression class2)
 {
     if (classes == null)
     {
         classes = new List <ClassExpression> {
             class2
         };
         return;
     }
     if (class2 == null || class2.getName() == null)
     {
         return;
     }
     foreach (ClassExpression cl in classes)
     {
         // add new functions to existed class
         if (cl.getName() == class2.getName())
         {
             var newListFunc = class2.getListFunction();
             if (newListFunc != null && newListFunc.Count > 0)
             {
                 foreach (var newFunc in newListFunc)
                 {
                     MergeFunctions(cl.getListFunction(), newFunc);
                 }
             }
             return;
         }
     }
     // add new class
     NormalizeClass(class2);
     classes.Add(class2);
 }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="classExpression"></param>
        /// <param name="projectPath"></param>
        /// <param name="name_space"></param>
        /// <param name="listUIElements"></param>
        /// <param name="mapAliasWithNode"></param>
        /// <param name="myLog"></param>
        /// <param name="instanceName"></param>
        /// <returns>relative file path</returns>
        private string GenerateClassExpScripts(ClassExpression classExpression, string projectPath, string name_space,
                                               ListUIElements listUIElements, Dictionary <string, string> mapAliasWithNode, MyLog myLog, string instanceName)
        {
            if (classExpression.getName() == null || classExpression.getListFunction() == null ||
                classExpression.getListFunction().Count <= 0)
            {
                return(null);
            }
            string functionsScripts = "";

            foreach (FunctionExpression func in classExpression.getListFunction())
            {
                if (functionsScripts != "")
                {
                    functionsScripts += NEW_LINE;
                }
                functionsScripts += GenerateFunctionExpScripts(func, listUIElements, mapAliasWithNode, myLog, instanceName);
            }
            // create new file
            string classContent = GetTemplateUCClassContent()
                                  //.Replace(GLOBAL_REPLACE, "") disabled by @duongtd 05/29
                                  .Replace(CLASS_REPLACE, classExpression.getName())
                                  .Replace(CONTENT_REPLACE, functionsScripts);
            string filePath            = Path.Combine(classExpression.GetCorrectWorkspace(), classExpression.getName() + ".cs");
            string fileContentTemplate = GetTemplateRunCsFileContent()
                                         .Replace(NAMESPACE_REPLACE, name_space);

            CreateNewFile(fileContentTemplate, classContent, Path.Combine(projectPath, filePath));
            return(filePath);
        }
コード例 #3
0
 public static void MergeClassesExpression(List <ClassExpression> @base, ClassExpression addition)
 {
     foreach (ClassExpression existed in @base.ToList())
     {
         if (existed.getName() == addition.getName())
         {
             List <FunctionExpression> newListFuncs = addition.getListFunction();
             if (newListFuncs != null)
             {
                 foreach (FunctionExpression newFunc in newListFuncs.ToList())
                 {
                     if (newFunc != null)
                     {
                         MergeFunctions(existed.getListFunction(), newFunc);
                     }
                 }
             }
             return;
         }
     }
     if (addition != null)
     {
         @base.Add(addition);
     }
 }
コード例 #4
0
        public bool Equals(object other)
        {
            if (!(other is ClassExpression))
            {
                return(false);
            }
            ClassExpression other1 = (ClassExpression)other;

            return(compareStr(this.getName(), other1.getName()));
            //                compareStr(this.getWorkspace(), other1.getWorkspace());
        }
コード例 #5
0
        public List <ClassExpression> parse(FunctionDescriptionSheet funcSheet, MyLog myLog)
        {
            // parseOneFile title row
            Excel.Range xlRange     = funcSheet.getSheet().UsedRange;
            int         rowCount    = xlRange.Rows.Count;
            int         columnCount = xlRange.Columns.Count;

            Excel.Range firstRow = funcSheet.getSheet().Rows[1];
            setColumnIndex(firstRow, myLog, ref columnCount);
            if (columnCount < 0)
            {
                return(null);
            }

            List <ClassExpression> classExpressions = new List <ClassExpression>();
            ClassExpression        classExpression  = new ClassExpression();

            for (int fi = 2; fi <= rowCount; fi++)
            {
                Excel.Range row      = funcSheet.getSheet().Rows[fi];
                string      funcName = getValueCell(row, FUNCTION_NAME_COLUMN_INDEX);
                // indicate end sheet
                if (funcName == null || funcName.Equals(""))
                {
                    break;
                }
                string workspace      = getValueCell(row, WORKSPACE_COLUMN_INDEX);
                string _class         = getValueCell(row, CLASS_COLUMN_INDEX);
                string accessibility  = getValueCell(row, ACCESSIBILITY_COLUMN_INDEX);
                string summary        = getValueCell(row, SUMMARY_COLUMN_INDEX);
                string parameters     = getValueCell(row, PARAMETERS_COLUMN_INDEX);
                string _returns       = getValueCell(row, RETURNS_COLUMN_INDEX);
                string implementation = getValueCell(row, IMPLEMENTATION_COLUMN_INDEX);

                string last_workspace = workspace == null || workspace.Equals("") ?
                                        classExpression.getWorkspace() : workspace;
                string last_class = _class == null || _class.Equals("") ?
                                    classExpression.getName() : _class;
                if (last_workspace == null || last_workspace.Equals(""))
                {
                    myLog.Warn("Not know workspace for row #" + (fi + 1) +
                               " in \"" + funcSheet.getSheet().Name + "\" sheet", logger);
                }
                if (last_class == null || last_workspace.Equals(""))
                {
                    myLog.Warn("Not know workspace for row #" + (fi + 1) +
                               " in \"" + funcSheet.getSheet().Name + "\" sheet", logger);
                }
                if (workspace != null && !workspace.Equals("") ||
                    (_class != null && !_class.Equals("")))
                {
                    classExpression = new ClassExpression(last_workspace, last_class);
                    classExpressions.Add(classExpression);
                }
                List <ParameterExpression> _params = parseParams(parameters, myLog);
                FunctionExpression         funcEpx = new FunctionExpression(
                    funcName, accessibility, summary, _params);
                funcEpx.setReturnDescription(_returns);
                funcEpx.setContent(implementation);

                if (classExpression.getListFunction() == null)
                {
                    classExpression.setListFunction(new List <FunctionExpression>());
                }
                classExpression.getListFunction().Add(funcEpx);
            }
            return(classExpressions);
        }