コード例 #1
0
ファイル: Case.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (PreConditions.Count > 0)
            {
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }

                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine(" THEN");

                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
            else
            {
                explanation.WriteLine();
                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
        }
コード例 #2
0
ファイル: Case.cs プロジェクト: JamesOakey/ERTMSFormalSpecs
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (PreConditions.Count > 0)
            {
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }

                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine(" THEN");

                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
            else
            {
                explanation.WriteLine();
                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
        }