예제 #1
0
 public Schema UpdateField(long fieldId, FieldProperties newProperties)
 {
     return(UpdateField(fieldId, field =>
     {
         return field.Update(newProperties);
     }));
 }
예제 #2
0
        public override NestedField Update(FieldProperties newProperties)
        {
            var typedProperties = ValidateProperties(newProperties);

            return(Clone <NestedField <T> >(clone =>
            {
                clone.SetProperties(typedProperties);
            }));
        }
예제 #3
0
        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.");
            }
        }
예제 #4
0
        public override Field Update(FieldProperties newProperties)
        {
            var typedProperties = ValidateProperties(newProperties);

            return(Clone <Field <T> >(clone =>
            {
                clone.properties = typedProperties;
                clone.properties.Freeze();
            }));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
        public override RootField Update(FieldProperties newProperties)
        {
            var typedProperties = ValidateProperties(newProperties);

            if (properties.Equals(typedProperties))
            {
                return(this);
            }

            return(Clone <RootField <T> >(clone =>
            {
                clone.SetProperties(typedProperties);
            }));
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
            }));
        }
예제 #10
0
        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)));
        }
예제 #11
0
        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;
                    }
                });
            }
        }
예제 #12
0
파일: Field{T}.cs 프로젝트: ifle/squidex
        public override void Update(FieldProperties newProperties)
        {
            var typedProperties = ValidateProperties(newProperties);

            properties = typedProperties;
        }
예제 #13
0
 public abstract NestedField Update(FieldProperties newProperties);
예제 #14
0
        public NestedField CreateNestedField(long id, string name, FieldProperties properties, IFieldSettings settings = null)
        {
            CheckProperties(properties);

            return(properties.CreateNestedField(id, name, settings));
        }
예제 #15
0
        public RootField CreateRootField(long id, string name, Partitioning partitioning, FieldProperties properties, IFieldSettings settings = null)
        {
            CheckProperties(properties);

            return(properties.CreateRootField(id, name, partitioning, settings));
        }
예제 #16
0
 public bool DeepEquals(FieldProperties properties)
 {
     return(this.WithDeepEqual(properties).IgnoreProperty <Freezable>(x => x.IsFrozen).Compare());
 }
예제 #17
0
        public RootField CreateRootField(long id, string name, Partitioning partitioning, FieldProperties properties)
        {
            CheckProperties(properties);

            return(properties.CreateRootField(id, name, partitioning));
        }
예제 #18
0
        protected override Field UpdateInternal(FieldProperties newProperties)
        {
            var typedProperties = ValidateProperties(newProperties);

            return(Clone <Field <T> >(clone => clone.properties = typedProperties));
        }
예제 #19
0
 public Field CreateField(long id, string name, Partitioning partitioning, FieldProperties properties)
 {
     return(fieldFactory(id, name, partitioning, properties));
 }
예제 #20
0
        public Field Update(FieldProperties newProperties)
        {
            ThrowIfLocked();

            return(UpdateInternal(newProperties));
        }
예제 #21
0
 public Field Update(FieldProperties newProperties)
 {
     return(UpdateInternal(newProperties));
 }
예제 #22
0
        public NestedField CreateNestedField(long id, string name, FieldProperties properties)
        {
            CheckProperties(properties);

            return(properties.CreateNestedField(id, name));
        }
예제 #23
0
 protected abstract Field UpdateInternal(FieldProperties newProperties);
예제 #24
0
 public abstract RootField Update(FieldProperties newProperties);
예제 #25
0
파일: Field.cs 프로젝트: ifle/squidex
 public abstract void Update(FieldProperties newProperties);