public override void Execute(EditFieldCommandContext context) { var enumData = (EnumData)context.Field; var buffer = enumData.Span.Buffer; var pos = enumData.Span.Span.Start; switch (enumData.Span.Length.ToUInt64()) { case 1: buffer.Replace(pos, (byte)enumFieldInfo.Value); break; case 2: buffer.Replace(pos, (ushort)enumFieldInfo.Value); break; case 4: buffer.Replace(pos, (uint)enumFieldInfo.Value); break; case 8: buffer.Replace(pos, (ulong)enumFieldInfo.Value); break; default: Debug.Fail($"Unknown size: {enumData.Span.Length}"); break; } }
public override bool IsChecked(EditFieldCommandContext context) { var enumData = (EnumData)context.Field; var buffer = enumData.Span.Buffer; var pos = enumData.Span.Span.Start; switch (enumData.Span.Length.ToUInt64()) { case 1: return(buffer.ReadByte(pos) == enumFieldInfo.Value); case 2: return(buffer.ReadUInt16(pos) == enumFieldInfo.Value); case 4: return(buffer.ReadUInt32(pos) == enumFieldInfo.Value); case 8: return(buffer.ReadUInt64(pos) == enumFieldInfo.Value); default: Debug.Fail($"Unknown size: {enumData.Span.Length}"); return(false); } }
public override void Execute(EditFieldCommandContext context) { var flagsData = (FlagsData)context.Field; var buffer = flagsData.Span.Buffer; var pos = flagsData.Span.Span.Start; if (isFlag) { switch (flagsData.Span.Length.ToUInt64()) { case 1: if ((buffer.ReadByte(pos) & flagInfo.Mask) != 0) { buffer.Replace(pos, (byte)(buffer.ReadByte(pos) & ~flagInfo.Mask)); } else { buffer.Replace(pos, (byte)((buffer.ReadByte(pos) & ~flagInfo.Mask) | flagInfo.Value)); } break; case 2: if ((buffer.ReadUInt16(pos) & flagInfo.Mask) != 0) { buffer.Replace(pos, (ushort)(buffer.ReadUInt16(pos) & ~flagInfo.Mask)); } else { buffer.Replace(pos, (ushort)((buffer.ReadUInt16(pos) & ~flagInfo.Mask) | flagInfo.Value)); } break; case 4: if ((buffer.ReadUInt32(pos) & flagInfo.Mask) != 0) { buffer.Replace(pos, (uint)(buffer.ReadUInt32(pos) & ~flagInfo.Mask)); } else { buffer.Replace(pos, (uint)((buffer.ReadUInt32(pos) & ~flagInfo.Mask) | flagInfo.Value)); } break; case 8: if ((buffer.ReadUInt64(pos) & flagInfo.Mask) != 0) { buffer.Replace(pos, (ulong)(buffer.ReadUInt64(pos) & ~flagInfo.Mask)); } else { buffer.Replace(pos, (ulong)((buffer.ReadUInt64(pos) & ~flagInfo.Mask) | flagInfo.Value)); } break; default: Debug.Fail($"Unknown size: {flagsData.Span.Length}"); break; } } else { switch (flagsData.Span.Length.ToUInt64()) { case 1: buffer.Replace(pos, (byte)((buffer.ReadByte(pos) & ~flagInfo.Mask) | flagInfo.Value)); break; case 2: buffer.Replace(pos, (ushort)((buffer.ReadUInt16(pos) & ~flagInfo.Mask) | flagInfo.Value)); break; case 4: buffer.Replace(pos, (uint)((buffer.ReadUInt32(pos) & ~flagInfo.Mask) | flagInfo.Value)); break; case 8: buffer.Replace(pos, (ulong)((buffer.ReadUInt64(pos) & ~flagInfo.Mask) | flagInfo.Value)); break; default: Debug.Fail($"Unknown size: {flagsData.Span.Length}"); break; } } }
public override void Execute(EditFieldCommandContext context) { }