public static void ReadArgs <T1, T2, T3, T4, T5, T6, T7>(this IJSValueReader reader, out T1 arg1, out T2 arg2, out T3 arg3, out T4 arg4, out T5 arg5, out T6 arg6, out T7 arg7) { bool success = reader.ValueType == JSValueType.Array; arg1 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T1>() : default(T1); arg2 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T2>() : default(T2); arg3 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T3>() : default(T3); arg4 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T4>() : default(T4); arg5 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T5>() : default(T5); arg6 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T6>() : default(T6); arg7 = reader.GetNextArrayItem(ref success) ? reader.ReadValue <T7>() : default(T7); _ = success && reader.SkipArrayToEnd(); }
public virtual void UpdateProperties(FrameworkElement view, IJSValueReader propertyMapReader) { if (view is TFrameworkElement viewAsT) { propertyMapReader.ReadValue(out IDictionary <string, JSValue> propertyMap); foreach (var property in propertyMap) { if (ViewManagerProperties.TryGetValue(property.Key, out ViewManagerProperty <TFrameworkElement> setter)) { setter.Setter(viewAsT, property.Value); } } } else { throw new ArgumentOutOfRangeException(nameof(view)); } }
public static void ReadValue <T>(this IJSValueReader reader, out IReadOnlyCollection <KeyValuePair <string, T> > value) { reader.ReadValue(out ReadOnlyDictionary <string, T> dictionary); value = dictionary; }
public static void ReadValue <T>(this IJSValueReader reader, out ReadOnlyDictionary <string, T> value) { reader.ReadValue(out Dictionary <string, T> dictionary); value = new ReadOnlyDictionary <string, T>(dictionary); }
public static void ReadValue <T>(this IJSValueReader reader, out IEnumerable <KeyValuePair <string, T> > value) { reader.ReadValue(out Dictionary <string, T> dictionary); value = dictionary; }
public static void ReadValue <T>(this IJSValueReader reader, out IDictionary <string, T> value) { reader.ReadValue(out Dictionary <string, T> dictionary); value = dictionary; }
// Reading RobotModel enum value. It could be generated instead. public static void ReadValue(this IJSValueReader reader, out RobotModel value) { value = (RobotModel)reader.ReadValue <int>(); }
// Reading RobotInfo value. It could be generated instead. public static void ReadValue(this IJSValueReader reader, out RobotInfo value) { value = new RobotInfo(); if (reader.ValueType == JSValueType.Object) { while (reader.GetNextObjectProperty(out string propertyName)) { switch (propertyName) { case nameof(value.Model): value.Model = reader.ReadValue <RobotModel>(); break; case nameof(value.Name): value.Name = reader.ReadValue <string>(); break; case nameof(value.Age): value.Age = reader.ReadValue <int>(); break; case nameof(value.Shape): value.Shape = reader.ReadValue <RobotShape>(); break; case nameof(value.Shape2): value.Shape2 = reader.ReadValue <RobotShape?>(); break; case nameof(value.Shape3): value.Shape3 = reader.ReadValue <RobotShape?>(); break; case nameof(value.Steps): value.Steps = reader.ReadValue <IList <int> >(); break; case nameof(value.Dimensions): value.Dimensions = reader.ReadValue <IDictionary <string, int> >(); break; case nameof(value.Badges): value.Badges = reader.ReadValue <Tuple <int, string, bool> >(); break; case nameof(value.Tools): value.Tools = reader.ReadValue <RobotTool[]>(); break; case nameof(value.Path): value.Path = reader.ReadValue <RobotPoint[]>(); break; case nameof(value.Extra): value.Extra = reader.ReadValue <OneOf2 <T2Extra, R2D2Extra> >(); break; default: reader.ReadValue <JSValue>(); break; } } } }