public Value(byte[] bytes, ValueFlag type) { byte[] b = new byte[bytes.Length + 1]; b [0] = (byte)type; Array.Copy (bytes, 0, b, 1, bytes.Length); _bytes = new ByteArray (b); }
public Value(byte[] bytes, ValueFlag type) { byte[] b = new byte[bytes.Length + 1]; b [0] = (byte)type; Array.Copy(bytes, 0, b, 1, bytes.Length); _bytes = new ByteArray(b); }
public void TestUnquoteUsageBool(string name, bool defaultValue, string usage, string expectedName, string expectedUsage) { var f = new ValueFlag <bool>(name, defaultValue, usage); var(n, u) = f.UnquoteUsage(); Assert.True(expectedName == n, $"expected name does not match, got: {n}, wanted: {expectedName}"); Assert.True(expectedUsage == u, $"expected usage does not match, got: {u}, wanted: {expectedUsage}"); }
public static string GetStringByStatus(ValueFlag valFlag) { if (valFlag == ValueFlag.ValueNotInit) { return("Unknown"); } else if (valFlag == ValueFlag.ValueOk) { return("OnLine"); } else { return("OffLine"); } }
static void Main(string[] args) { args = new[] { "-book", "The Hitchhiker's Guide to the Galaxy", "-book", "The Restaurant at the End of the Universe", "-book", "Life, the Universe and Everything" }; var fs = Flag.NewFlagSet("ArrayBuilder", ErrorHandling.ContinueOnError); var bookFlag = new ValueFlag <string[]>("book", new string[0], "No b", ParseArray); fs.Var(bookFlag); fs.Parse(args); Console.WriteLine("Books:"); foreach (var b in bookFlag.Value) { Console.WriteLine($"\t{b}"); } }