public Schema UpdateField(long fieldId, FieldProperties newProperties) { return(UpdateField(fieldId, field => { return field.Update(newProperties); })); }
public override NestedField Update(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); return(Clone <NestedField <T> >(clone => { clone.SetProperties(typedProperties); })); }
private void CheckProperties(FieldProperties properties) { Guard.NotNull(properties, nameof(properties)); if (!supportedFields.Contains(properties.GetType())) { throw new InvalidOperationException($"The field property '{properties.GetType()}' is not supported."); } }
public override Field Update(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); return(Clone <Field <T> >(clone => { clone.properties = typedProperties; clone.properties.Freeze(); })); }
private T ValidateProperties(FieldProperties newProperties) { Guard.NotNull(newProperties); if (!(newProperties is T typedProperties)) { throw new ArgumentException($"Properties must be of type '{typeof(T)}", nameof(newProperties)); } return(typedProperties); }
public Field CreateField(long id, string name, Partitioning partitioning, FieldProperties properties) { Guard.NotNull(properties, nameof(properties)); var factory = fieldsByPropertyType.GetOrDefault(properties.GetType()); if (factory == null) { throw new InvalidOperationException($"The field property '{properties.GetType()}' is not supported."); } return(factory(id, name, partitioning, properties)); }
public override RootField Update(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); if (properties.Equals(typedProperties)) { return(this); } return(Clone <RootField <T> >(clone => { clone.SetProperties(typedProperties); })); }
private T ValidateProperties(FieldProperties newProperties) { Guard.NotNull(newProperties, nameof(newProperties)); newProperties.Freeze(); if (!(newProperties is T typedProperties)) { throw new ArgumentException($"Properties must be of type '{typeof(T)}", nameof(newProperties)); } newProperties.Validate(() => $"Cannot update field with id '{Id}', because the settings are invalid."); return(typedProperties); }
public override NestedField Update(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); typedProperties.Freeze(); if (properties.DeepEquals(typedProperties)) { return(this); } return(Clone <NestedField <T> >(clone => { clone.SetProperties(typedProperties); })); }
public static Schema UpdateField(this Schema schema, long fieldId, FieldProperties properties, long?parentId = null) { if (parentId != null) { return(schema.UpdateField(parentId.Value, f => { if (f is ArrayField arrayField) { return arrayField.UpdateField(fieldId, n => n.Update(properties)); } return f; })); } return(schema.UpdateField(fieldId, f => f.Update(properties))); }
public void Should_set_or_freeze_sut(FieldProperties properties) { foreach (var property in properties.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; property.SetValue(properties, value); var result = property.GetValue(properties); Assert.Equal(value, result); } properties.Freeze(); foreach (var property in properties.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) { var value = property.PropertyType.GetTypeInfo().IsValueType ? Activator.CreateInstance(property.PropertyType) : null; Assert.Throws <InvalidOperationException>(() => { try { property.SetValue(properties, value); } catch (Exception ex) { throw ex.InnerException; } }); } }
public override void Update(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); properties = typedProperties; }
public abstract NestedField Update(FieldProperties newProperties);
public NestedField CreateNestedField(long id, string name, FieldProperties properties, IFieldSettings settings = null) { CheckProperties(properties); return(properties.CreateNestedField(id, name, settings)); }
public RootField CreateRootField(long id, string name, Partitioning partitioning, FieldProperties properties, IFieldSettings settings = null) { CheckProperties(properties); return(properties.CreateRootField(id, name, partitioning, settings)); }
public bool DeepEquals(FieldProperties properties) { return(this.WithDeepEqual(properties).IgnoreProperty <Freezable>(x => x.IsFrozen).Compare()); }
public RootField CreateRootField(long id, string name, Partitioning partitioning, FieldProperties properties) { CheckProperties(properties); return(properties.CreateRootField(id, name, partitioning)); }
protected override Field UpdateInternal(FieldProperties newProperties) { var typedProperties = ValidateProperties(newProperties); return(Clone <Field <T> >(clone => clone.properties = typedProperties)); }
public Field CreateField(long id, string name, Partitioning partitioning, FieldProperties properties) { return(fieldFactory(id, name, partitioning, properties)); }
public Field Update(FieldProperties newProperties) { ThrowIfLocked(); return(UpdateInternal(newProperties)); }
public Field Update(FieldProperties newProperties) { return(UpdateInternal(newProperties)); }
public NestedField CreateNestedField(long id, string name, FieldProperties properties) { CheckProperties(properties); return(properties.CreateNestedField(id, name)); }
protected abstract Field UpdateInternal(FieldProperties newProperties);
public abstract RootField Update(FieldProperties newProperties);
public abstract void Update(FieldProperties newProperties);