protected Nodes() { try { KnownNodes.Add((T)typeof(T).GetProperty("This").GetValue(null, null)); } catch (NullReferenceException) { throw new MissingMethodException($"{typeof(T).Name} class is missing a static get property named 'This' that returns a {typeof(T).Name} object.\n public static {typeof(T).Name} This{{ get {{...}}}}\n public static {typeof(T).Name} This => new {typeof(T).Name}();"); } NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions <ProtobufSerializer, LZMACompressor>(); }
/// <summary> /// Adds a node to the list of known nodes. /// </summary> /// <param name="node">The node to add.</param> /// <returns> /// The index of the node in the list of known nodes /// after the addition. /// </returns> public int AddToKnownNodes(NodeT node) { int i = KnownNodes.IndexOf(node); if (i < 0) { i = KnownNodes.Count; KnownNodes.Add(node); } return(i); }