public static void InvertBit(this ITagOp tagOp, string tag) { try { bool current = (bool)tagOp.ReadTag(tag); bool toggle = !current; tagOp.WriteTag(tag, toggle); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public static bool?ReadBit(this ITagOp tagOp, string tag) { try { var bit = tagOp.ReadTag(tag); if (bit == null) { return(null); } else { return((bool)bit); } }catch (Exception ex) { } return(null); }