コード例 #1
0
 public void TestStringLiteral()
 {
     Assert.AreEqual("\"\"", ZincPrintUtils.StringLiteral(string.Empty));
     Assert.AreEqual("\"a\"", ZincPrintUtils.StringLiteral("a"));
     Assert.AreEqual("\"aa\"", ZincPrintUtils.StringLiteral("aa"));
     Assert.AreEqual("\"abb\"", ZincPrintUtils.StringLiteral("abb"));
     Assert.AreEqual("\"\\\"abb\\\"\"", ZincPrintUtils.StringLiteral("\"abb\""));
 }
コード例 #2
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents the current <see cref="ZincSolveItem"/>.
        /// </summary>
        /// <returns>A <see cref="System.String"/> that represents the current <see cref="ZincSolveItem"/>.</returns>
        /// <remarks>
        /// <para>The format of this method is <c>solve annotations type expression</c> where the annotations
        /// annotate the solve item, the <c>type</c> is <c>satisfy</c>, <c>minimize</c> and <c>maximize</c>. and
        /// <c>expression</c> the expression to be minimized/maximized.</para>
        /// </remarks>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("solve ");

            if (this.Annotations != null && this.Annotations.Count > 0x00)
            {
                sb.Append(this.Annotations);
                sb.Append(' ');
            }
            sb.Append(ZincPrintUtils.SolveTypeLiteral(this.SolveType));
            if (this.SolveType != ZincSolveType.Satisfy)
            {
                sb.Append(' ');
                sb.Append(this.Expression);
            }

            return(sb.ToString());
        }
コード例 #3
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents the current <see cref="ZincIncludeItem"/>.
 /// </summary>
 /// <returns>A <see cref="System.String"/> that represents the current <see cref="ZincIncludeItem"/>.</returns>
 /// <remarks>
 /// <para>The format of this method is <c>include "name"</c> where the name is the name of the included zinc file.</para>
 /// </remarks>
 public override string ToString()
 {
     return(string.Format("include {0}", ZincPrintUtils.StringLiteral(this.Name)));
 }
コード例 #4
0
ファイル: ZincScalarType.cs プロジェクト: falcong/ZincOxide
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents the current <see cref="ZincScalarType"/>.
 /// </summary>
 /// <returns>A <see cref="System.String"/> that represents the current <see cref="ZincScalarType"/>.</returns>
 /// <remarks>
 /// <para>The result is the name of the scalar type (in lower case).</para>
 /// </remarks>
 public override string ToString()
 {
     return(ZincPrintUtils.ScalarLiteral(this.Scalar));
 }
コード例 #5
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents the current <see cref="ZincTypeInstBaseExpression"/>.
 /// </summary>
 /// <returns>A <see cref="System.String"/> that represents the current <see cref="ZincTypeInstBaseExpression"/>.</returns>
 /// <remarks>
 /// <para>The result is a string format according to <c>array [ index ] of type</c> where <c>index</c> and <c>type</c> are replaced
 /// by the textual representation of the types of the index and the type of the array.</para>
 /// </remarks>
 public override string ToString()
 {
     return(string.Format("{0} {1}", ZincPrintUtils.VarParLiteral(this.VarPar), this.Type));
 }