/** <inheritdoc /> */ public IBinaryObject PersonMethodBinary(IBinaryObject person) { return(person .ToBuilder() .SetField("Id", person.GetField <int>("Id") + 1) .Build()); }
/** <inheritDoc /> */ public IBinaryObject testBinaryObject(IBinaryObject x) { if (x == null) { return(null); } return(x.ToBuilder().SetField("field", 15).Build()); }
/// <summary> /// Reads binary object fields and modifies them. /// </summary> /// <param name="cache">Cache.</param> private static void ReadModifyExample(ICache <int, IBinaryObject> cache) { const int id = 1; IBinaryObject person = cache[id]; string name = person.GetField <string>(NameField); Console.WriteLine(); Console.WriteLine($">>> Name of the person with id {id}: {name}"); // Modify the binary object. cache[id] = person.ToBuilder().SetField("Name", $"{name} Jr.").Build(); Console.WriteLine($">>> Modified person with id {id}: {cache[1]}"); }
/// <summary> /// Reads binary object fields and modifies them. /// </summary> /// <param name="cache">Cache.</param> private static void ReadModifyExample(ICacheClient <int, IBinaryObject> cache) { const int id = 1; IBinaryObject person = cache[id]; string name = person.GetField <string>(NameField); Console.WriteLine(); Console.WriteLine(">>> Name of the person with id {0}: {1}", id, name); // Modify the binary object. cache[id] = person.ToBuilder().SetField("Name", name + " Jr.").Build(); Console.WriteLine(">>> Modified person with id {0}: {1}", id, cache[1]); }