Example #1
0
 private static Exp AddRead(Exp bin, byte[] bytes, Exp.Type retType)
 {
     return(new Exp.Module(bin, bytes, (int)retType, MODULE));
 }
 /// <summary>
 /// Create expression that selects list item identified by index and returns
 /// selected data specified by returnType.
 /// </summary>
 /// <example>
 /// <code>
 /// // a[3] == 5
 /// Exp.EQ(
 ///   ListExp.GetByIndex(ListReturnType.VALUE, Type.INT, Exp.Val(3), Exp.ListBin("a")),
 ///   Exp.Val(5));
 /// </code>
 /// </example>
 /// <param name="returnType">metadata attributes to return. See <see cref="ListReturnType"/></param>
 /// <param name="valueType">		expected type of return value </param>
 /// <param name="index">			list index expression </param>
 /// <param name="bin">list bin or list value expression</param>
 /// <param name="ctx">optional context path for nested CDT</param>
 public static Exp GetByIndex(ListReturnType returnType, Exp.Type valueType, Exp index, Exp bin, params CTX[] ctx)
 {
     byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_INDEX, (int)returnType, index, ctx);
     return(AddRead(bin, bytes, valueType));
 }
 /// <summary>
 /// Create expression that selects list item identified by rank and returns selected
 /// data specified by returnType.
 /// </summary>
 /// <example>
 /// <code>
 /// // Player with lowest score.
 /// ListExp.GetByRank(ListReturnType.VALUE, Type.STRING, Exp.Val(0), Exp.ListBin("a"))
 /// </code>
 /// </example>
 /// <param name="returnType">metadata attributes to return. See <see cref="ListReturnType"/></param>
 /// <param name="valueType">expected type of return value</param>
 /// <param name="rank">rank expression</param>
 /// <param name="bin">list bin or list value expression</param>
 /// <param name="ctx">optional context path for nested CDT</param>
 public static Exp GetByRank(ListReturnType returnType, Exp.Type valueType, Exp rank, Exp bin, params CTX[] ctx)
 {
     byte[] bytes = PackUtil.Pack(ListOperation.GET_BY_RANK, (int)returnType, rank, ctx);
     return(AddRead(bin, bytes, valueType));
 }
Example #4
0
 /// <summary>
 /// Create expression that selects map item identified by key and returns selected data
 /// specified by returnType.
 /// </summary>
 /// <example>
 /// <code>
 /// // Map bin "a" contains key "B"
 /// Exp.GT(
 ///   MapExp.GetByKey(MapReturnType.COUNT, Type.INT, Exp.Val("B"), Exp.MapBin("a")),
 ///   Exp.Val(0));
 /// </code>
 /// </example>
 /// <param name="returnType">metadata attributes to return. See <see cref="MapReturnType"/> </param>
 /// <param name="valueType">		expected type of return value </param>
 /// <param name="key">			map key expression </param>
 /// <param name="bin">			bin or map value expression </param>
 /// <param name="ctx">			optional context path for nested CDT </param>
 public static Exp GetByKey(MapReturnType returnType, Exp.Type valueType, Exp key, Exp bin, params CTX[] ctx)
 {
     byte[] bytes = PackUtil.Pack(MapOperation.GET_BY_KEY, (int)returnType, key, ctx);
     return(AddRead(bin, bytes, valueType));
 }