コード例 #1
0
        /// <summary>
        /// Generate the compete spec from the include files
        /// </summary>
        /// <returns></returns>
        protected string GetCompleteSpecFromIncludeFiles()
        {
            //add the original model
            string completeSpec = InputModelText;

            ParsingException.FileOffset.Clear();
            ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(completeSpec), new string[] { FilePath });

            //add the included models one by one
            foreach (string file in IncludeFiles)
            {
                try
                {
                    //cannot add the same file twice.
                    if (file != FilePath)
                    {
                        completeSpec += "\r\n" + System.IO.File.ReadAllText(file, Encoding.UTF8);
                        ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(completeSpec), new string[] { file });
                    }
                }
                catch (Exception exception)
                {
                    throw new ParsingException("Error happend in loading \"" + file + "\":" + exception.Message, -1, -1, "");
                }
            }

            //clear the included files after the inclusion
            IncludeFiles.Clear();
            return(completeSpec);
        }
コード例 #2
0
ファイル: TAModel.cs プロジェクト: vu111293/pat-design
        public string ToSpecificationString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(Declaration);
            string file = "";

            foreach (string[] eraCanvase in ParsingException.FileOffset.Values)
            {
                file = eraCanvase[0];
            }
            ParsingException.FileOffset.Clear();
            ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(sb.ToString()), new string[] { file, "Declaration" });

            foreach (TACanvas canvas in Processes)
            {
                sb.AppendLine(canvas.ToSpecificationString());
                ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(sb.ToString()), new string[] { file, canvas.Node.Text });
            }
            foreach (TACanvas canvas in Properties)
            {
                sb.AppendLine(canvas.ToSpecificationString().Replace("Process ", "Property "));
                ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(sb.ToString()), new string[] { file, canvas.Node.Text });
            }
            return(sb.ToString());
        }
コード例 #3
0
        protected SpecificationBase(string spec, string filePath)
        {
            InputModelText = spec;

            //get the name of the specification
            if (spec.StartsWith(@"//@@"))
            {
                int index = spec.IndexOf("@@", 4);
                if (index != -1)
                {
                    SpecificationName = spec.Substring(4, index - 4);
                }
            }

            FilePath = filePath;
            Errors.Clear();
            Warnings.Clear();

            IncludeFiles = new HashSet <string>();

            ParsingException.FileOffset.Clear();
            ParsingException.FileOffset.Add(ParsingException.CountLinesInFile(spec), new string[] { FilePath });
        }