public override uint memorySize() { T Data = (T)Property.Get; setValue(Data); //ensure the DDMLValue is updated return(DDMLValue.sizeBytes()); }
public override void unpack(byte[] messageData) { DDMLValue.setData(messageData, messageData.Length, 0); setPropertyValue(); //store the Value property T Data = Value; Property.SetObject(Data); }
public override void unpack(TTypedValue src) { DDMLValue.setValue(src); setPropertyValue(); //store the Value property T Data = Value; Property.SetObject(Data); }
/// <summary> /// Pack the field values for this Generic type /// into the MessageData. /// </summary> /// <param name="MessageData">The packed data from this Generic type</param> public override void pack(out byte[] MessageData) { for (int i = 0; i < Fields.Count; i++) { byte[] msgData; Fields[i].pack(out msgData); DDMLValue.item((uint)i + 1).setData(msgData, msgData.Length); } MessageData = new byte[memorySize()]; DDMLValue.getData(ref MessageData); }
/// <summary> /// Upack the message data into this Generic type. /// </summary> /// <param name="MessageData">Incoming message data</param> public override void unpack(byte[] MessageData) { //##It would be nice to improve this code a little - NH //populate DDMLValue from MessageData DDMLValue.setData(MessageData, MessageData.Length, 0); for (uint i = 1; i <= DDMLValue.count(); i++) //for each member { byte[] b = new byte[DDMLValue.item(i).sizeBytes()]; DDMLValue.getData(ref b); Fields[(int)i - 1].unpack(b); //unpack each field } }
private void setValue(object value) { tType = typeof(T); Value = (T)Convert.ChangeType(value, tType); if (tType == typeof(Boolean)) { DDMLValue.setValue(Convert.ToBoolean(value)); } else if (tType == typeof(Int32)) { DDMLValue.setValue(Convert.ToInt32(value)); } else if (tType == typeof(Single)) { DDMLValue.setValue(Convert.ToSingle(value)); } else if (tType == typeof(double)) { DDMLValue.setValue(Convert.ToDouble(value)); } else if (tType == typeof(String)) { DDMLValue.setValue(Convert.ToString(value)); } else if (tType == typeof(Boolean[])) { DDMLValue.setValue((Boolean[])Convert.ChangeType(value, tType)); } else if (tType == typeof(Int32[])) { DDMLValue.setValue((Int32[])Convert.ChangeType(value, tType)); } else if (tType == typeof(Single[])) { DDMLValue.setValue((Single[])Convert.ChangeType(value, tType)); } else if (tType == typeof(Double[])) { DDMLValue.setValue((Double[])Convert.ChangeType(value, tType)); } else if (tType == typeof(String[])) { DDMLValue.setValue((String[])Convert.ChangeType(value, tType)); } else if (tType == typeof(DateTime)) { double JulianDate = DateUtility.DateTimeToJulianDayNumber((DateTime)Convert.ChangeType(value, tType)); DDMLValue.setValue(JulianDate); } }
/// <summary> /// Set the internal Value from the DDMLValue that was set in the unpack() /// </summary> private void setPropertyValue() { tType = typeof(T); if (tType == typeof(Boolean)) { Value = (T)(Convert.ChangeType(DDMLValue.asBool(), tType)); } else if (tType == typeof(Int32)) { Value = (T)(Convert.ChangeType(DDMLValue.asInt(), tType)); } else if (tType == typeof(Single)) { Value = (T)(Convert.ChangeType(DDMLValue.asSingle(), tType)); } else if (tType == typeof(double)) { Value = (T)(Convert.ChangeType(DDMLValue.asDouble(), tType)); } else if (tType == typeof(String)) { Value = (T)(Convert.ChangeType(DDMLValue.asStr(), tType)); } else if (tType == typeof(Boolean[])) { Value = (T)(Convert.ChangeType(DDMLValue.asBooleanArray(), tType)); } else if (tType == typeof(Int32[])) { Value = (T)(Convert.ChangeType(DDMLValue.asIntArray(), tType)); } else if (tType == typeof(Single[])) { Value = (T)(Convert.ChangeType(DDMLValue.asSingleArray(), tType)); } else if (tType == typeof(double[])) { Value = (T)(Convert.ChangeType(DDMLValue.asDoubleArray(), tType)); } else if (tType == typeof(String[])) { Value = (T)(Convert.ChangeType(DDMLValue.asStringArray(), tType)); } else if (tType == typeof(DateTime)) { double JulianDate = DDMLValue.asDouble(); //stored as a double DateTime jDate = DateUtility.JulianDayNumberToDateTime((int)Math.Truncate(JulianDate)); Value = (T)(Convert.ChangeType(jDate, typeof(T))); } }
/// <summary> /// Set the internal Value from the DDMLValue that was set in the unpack() /// </summary> private void setVariableValue() { if (tType == typeof(Boolean)) { Value = (T)(Convert.ChangeType(DDMLValue.asBool(), typeof(T))); } else if (tType == typeof(Int32)) { Value = (T)(Convert.ChangeType(DDMLValue.asInt(), typeof(T))); } else if (tType == typeof(Single)) { Value = (T)(Convert.ChangeType(DDMLValue.asSingle(), typeof(T))); } else if (tType == typeof(double)) { Value = (T)(Convert.ChangeType(DDMLValue.asDouble(), typeof(T))); } else if (tType == typeof(String)) { Value = (T)(Convert.ChangeType(DDMLValue.asStr(), typeof(T))); } else if (tType == typeof(Boolean[])) { Value = (T)(Convert.ChangeType(DDMLValue.asBooleanArray(), typeof(T))); } else if (tType == typeof(Int32[])) { Value = (T)(Convert.ChangeType(DDMLValue.asIntArray(), typeof(T))); } else if (tType == typeof(Single[])) { Value = (T)(Convert.ChangeType(DDMLValue.asSingleArray(), typeof(T))); } else if (tType == typeof(double[])) { Value = (T)(Convert.ChangeType(DDMLValue.asDoubleArray(), typeof(T))); } else if (tType == typeof(String[])) { Value = (T)(Convert.ChangeType(DDMLValue.asStringArray(), typeof(T))); } else if (tType == typeof(DateTime)) { double JulianDate = DDMLValue.asDouble(); //stored as a double DateTime jDate = TTimeValue.JDToDateTime(JulianDate); Value = (T)(Convert.ChangeType(jDate, typeof(T))); } }
public override uint memorySize() { setValue(Value); //ensure the DDMLValue is updated return(DDMLValue.sizeBytes()); }
public override void unpack(byte[] messageData) { //::unpackWithConverter(messageData, Value); DDMLValue.setData(messageData, messageData.Length, 0); setVariableValue(); }
public override void unpack(TTypedValue src) { DDMLValue.setValue(src); setVariableValue(); }
public override void pack(out byte[] messageData) { setValue(Value); messageData = new byte[DDMLValue.sizeBytes()]; DDMLValue.getData(ref messageData); }