protected static void writeOptional(ByteStream source, Encodable type, int contextId) { if (type == null) { return; } write(source, type, contextId); }
private static Encodable readWrapped(ByteStream source, Type type, int contextId) { popStart(source, contextId); Encodable result = read(source, type); popEnd(source, contextId); return(result); }
// Read and write encodable protected static void writeEncodable(ByteStream source, Encodable type, int contextId) { if (type.GetType().IsSubclassOf(typeof(Primitive.Primitive))) { ((Primitive.Primitive)type).WriteEncodable(source, contextId); } else { type.write(source, contextId); } }
protected static Encodable read(ByteStream source, Type type) { if (type.IsSubclassOf(typeof(Primitive.Primitive))) { return(Primitive.Primitive.CreatePrimitive(source)); } var constructor = type.GetConstructor(new Type[] { typeof(ByteStream) }); Encodable obj = (Encodable)constructor.Invoke(new object[] { source }); return(obj); }
protected static Encodable readSequenceType(ByteStream source, Type type, int contextId) { popStart(source, contextId); Encodable result = null; try { var constructor = type.GetConstructor(new Type[] { typeof(ByteStream), typeof(int) }); result = (Encodable)constructor.Invoke(new object[] { source, contextId }); } catch (System.Exception e) { throw new BACnetException(e); } popEnd(source, contextId); return(result); }
protected static void write(ByteStream source, Encodable type, int contextId) { type.write(source, contextId); }
// // Basic read and write. Pretty trivial. protected static void write(ByteStream source, Encodable type) { type.write(source); }