internal static void WriteInner(AccessorMembers members, IReadAccessor reader, Utf8JsonWriter writer, IShaped value, JsonSerializerOptions options) { if (value.Body != null) { foreach (var field in value.Fields) { if (!members.TryGetValue(field, out var member)) { continue; } if (!member.CanRead) { continue; } // key: var propertyName = options.PropertyNamingPolicy?.ConvertName(member.Name) ?? member.Name; writer.WritePropertyName(propertyName); // value (can be null): reader.TryGetValue(value.Body, member.Name, out var item); JsonSerializer.Serialize(writer, item, options); } } }
public static Instruction MarkLabel(IReadAccessor <Label> input) { return(new Instruction( input, il => { il.MarkLabel(input.Item); } )); }
/// <inheritdoc /> public void Configure(IReadAccessor <string> reader) { ArgumentGuard.NotNull(reader, nameof(reader)); string traceMsg = Tracer.FormatCall("Configure"); try { logger_.Log(traceMsg); #pragma warning disable IDE0018 // Inline variable declaration string value; #pragma warning restore IDE0018 // Inline variable declaration if (reader.TryGetValue(this, "MonitorHost", out value)) { MonitorHost = bool.Parse(value); } if (reader.TryGetValue(this, "MonitorProcessesByName", out value)) { MonitorProcessesByName = string.IsNullOrEmpty(value) ? null : new Regex(value); } if (reader.TryGetValue(this, "MonitorProcessesById", out value)) { MonitorProcessesById = value.ToInt32(); } if (reader.TryGetValue(this, "MonitorWindowsByTitle", out value)) { MonitorWindowsByTitle = string.IsNullOrEmpty(value) ? null : new Regex(value); } if (reader.TryGetValue(this, "CapturePadding", out value)) { CapturePadding = string.IsNullOrEmpty(value) ? default(RectangularMargins) : RectangularMargins.Parse(value); } logger_.Verbose("{0} succeeded", traceMsg); } catch (Exception ex) { CommonUtils.LogExceptionStackTrace(logger_, Stage.Check, StageType.CaptureScreenshot, ex); throw; } }
internal static void WriteInner(AccessorMembers members, IReadAccessor reader, Utf8JsonWriter writer, DeltaAnnotated <T> value, JsonSerializerOptions options) { if (value.Data != null) { foreach (var member in members) { if (!member.CanRead) { continue; } // key: var propertyName = options.PropertyNamingPolicy?.ConvertName(member.Name) ?? member.Name; writer.WritePropertyName(propertyName); // value (can be null): reader.TryGetValue(value.Data, member.Name, out var item); JsonSerializer.Serialize(writer, item, options); } } WriteAnnotation(writer, value); }
private static object ResolveValue(object @object, IEnumerable <IFieldTransform> transforms, IReadAccessor accessor, AccessorMember v) { foreach (var field in transforms) { if (field.TryTransform(accessor, @object, v, out var transformed)) { return(transformed); } } accessor.TryGetValue(@object, v.Name, out var untransformed); return(untransformed); }
public Instruction(OpCode opcode, IReadAccessor <LocalBuilder> arg) : this(opcode, true) { argument = arg; emit = il => { il.Emit(opcode, arg.Item); }; }
public Instruction(OpCode opcode, IReadAccessor <Label> arg) : this(opcode, true) { argument = arg; emit = il => il.Emit(opcode, arg.Item); }