public static ulong GetEnumValue(Enum e) { byte[] buf = new byte[sizeof(ulong)]; Type uType = Enum.GetUnderlyingType(e.GetType()); buf.CopyTo(Globs.GetBytes(Convert.ChangeType(e, uType)), 0); return(BitConverter.ToUInt64(buf, 0)); }
void ToNetValueType(Object o, string name) { if (Repr == DataRepresentation.Tpm) { Buffer.Append(Globs.HostToNet(o)); return; } if (Repr == DataRepresentation.LittleEndian) { Buffer.Append(Globs.GetBytes(o)); } throw new Exception("Unsupported marshaling type"); }