Example #1
0
 internal EditableVariable(IEditableFactory factory, bool nullable, Cursor dataCursor)
 {
     this.nullable   = nullable;
     this.factory    = factory;
     this.dataSchema = dataCursor.Schema ?? BuiltInSchemas.Boolean;
     this.dataCursor = dataCursor;
 }
Example #2
0
        public IEditable ToEditable(IEditableFactory factory)
        {
            var choice = factory.Create(schema, nullable);

            choice.Set(this.Value);
            return(choice);
        }
Example #3
0
        public IEditableList ToEditable(IEditableFactory factory)
        {
            var list = (IEditableList)factory.Create(schema);

            foreach (var x in this)
            {
                list.Add().Set(x);
            }
            return(list);
        }
Example #4
0
        public static IEditable CreateFromMemory(this IEditableFactory factory, MemoryStream mem, Schema schema)
        {
            ArraySegment <byte> buffer;

            if (!mem.TryGetBuffer(out buffer))
            {
                throw new Exception("Buffer of MemoryStream object is not accessible");
            }
            return(factory.CreateFromMemory(buffer, schema));
        }
Example #5
0
        public IEditable ToEditable(IEditableFactory factory)
        {
            var option = (IEditableObject)factory.Create(BuiltInSchema.ChoiceOption);

            option.GetField("Value").Set(this.Value);
            option.GetField("Order").Set(this.Order);
            option.GetField("Hidden").Set(this.Hidden);
            option.GetField("Name").Set(this.Name);
            option.GetField("Caption").Set(this.Caption);
            option.GetField("Description").Set(this.Description);
            return(option);
        }
Example #6
0
        public IEditableObject ToEditable(IEditableFactory factory)
        {
            var editableField = (IEditableObject)factory.Create(BuiltInSchema.Field, false);

            editableField.GetField("SchemaId").Set(this.Schema.Id);
            editableField.GetField("Nullable").Set(this.Nullable);
            editableField.GetField("Name").Set(this.Name);
            editableField.GetField("Caption").Set(this.Caption);
            editableField.GetField("Description").Set(this.Description);
            editableField.GetField("MaxLength").Set(this.MaxLength);
            return(editableField);
        }
Example #7
0
        public EditableObject(IEditableFactory factory, Schema schema, bool nullable)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            this.factory  = factory;
            this.schema   = schema;
            this.nullable = nullable;

            if (!this.nullable)
            {
                CreateFields();
            }
        }
Example #8
0
        public EditablePrimitive(IEditableFactory factory, Schema schema, bool nullable)
        {
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            if (!IsSupportedType(schema.DataType))
            {
                throw new ArgumentException("Invalid schema for value class specified", "schema");
            }

            this.factory  = factory;
            this.schema   = schema;
            this.nullable = nullable;

            if (!nullable)
            {
                data = this.TypeHelper.DefaultValue;
            }
        }
Example #9
0
        public IEditableObject ToEditable(IEditableFactory factory)
        {
            var editableSchema = (IEditableObject)factory.Create(BuiltInSchema.Schema, false);

            editableSchema.GetField("Id").Set(this.Id);
            editableSchema.GetField("DataType").Set((int)this.DataType);
            editableSchema.GetField("Name").Set(this.Name);
            editableSchema.GetField("Description").Set(this.Description);
            editableSchema.GetField("DeclarationItem").Set(this.declarationItem);

            if (this.fields != null)
            {
                var fieldList = (IEditableList)editableSchema.GetField("Fields");
                foreach (var f in fields)
                {
                    fieldList.Add().Set(f.ToEditable(factory));
                }
            }

            return(editableSchema);
        }
Example #10
0
        public IEditableObject ToEditable(IEditableFactory factory)
        {
            var choiceSet = factory.CreateItem(Schema.BuiltIn[BuiltInSchema.ChoiceSet]);

            choiceSet.GetField((int)ItemLayout.Id).Set(this.Id);
            choiceSet.GetField((int)ItemLayout.Name).Set(this.Name);
            choiceSet.GetField((int)ItemLayout.Revision).Set(this.Revision);

            IEditableObject dataField = choiceSet.GetField((int)ItemLayout.Data).Get <IEditableObject>();

            dataField.GetField("Description").Set(this.Description);
            dataField.GetField("Caption").Set(this.Caption);

            var defaultsList = (IEditableList)dataField.GetField("Defaults");

            this.Defaults.ForEach(x => defaultsList.Add().Set(x));

            var optionList = (IEditableList)dataField.GetField("Options");

            this.Options.ForEach(x => optionList.Add().Set(x.ToEditable(factory)));

            return(choiceSet);
        }
Example #11
0
        public EditableList(IEditableFactory factory, Schema schema, bool nullable)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            this.factory = factory;
            this.schema  = schema;

            if (schema.DataType == DataType.MultiChoice)
            {
                this.itemSchema   = Schema.BuiltIn[BuiltInSchema.Int32];
                this.itemNullable = false;
            }
            else
            {
                if (schema.DataType != DataType.List && schema.DataType != DataType.MultiChoice || schema.FieldCount != 1)
                {
                    throw new ArgumentException("Invalid schema specified for item list", "schema");
                }

                this.itemSchema   = schema[0].Schema;
                this.itemNullable = schema[0].Nullable;
            }

            this.nullable = nullable;
            if (!this.nullable)
            {
                this.Clear();
            }
        }
Example #12
0
 public RecordSerializer(ISchemaProvider schemaProvider, ISchemaTypeMap schemaTypeMap, IEditableFactory editableFactory)
 {
     this.schemaProvider  = schemaProvider;
     this.schemaTypeMap   = schemaTypeMap;
     this.editableFactory = editableFactory;
 }
Example #13
0
 public static IEditable CreateFromJson(this IEditableFactory factory, string json, Schema schema)
 {
     return(factory.CreateFromJson(new JsonTextReader(new StringReader(json)), schema));
 }
 public ReflectionSchemaBuilder(ISchemaProvider schemaProvider, IEditableFactory editableFactory, ISchemaTypeMap schemaTypeMap)
 {
     this.schemaProvider  = schemaProvider;
     this.editableFactory = editableFactory;
     this.typeMap         = schemaTypeMap;
 }
Example #15
0
 public static IEditable CreateFromJson(this IEditableFactory factory, string json, BuiltInSchema schema)
 {
     return(factory.CreateFromJson(json, Schema.BuiltIn[schema]));
 }
Example #16
0
 public EditableVariable(IEditableFactory factory, bool nullable)
     : this(factory, nullable, default(Cursor))
 {
 }
Example #17
0
 public static IEditable CreateFromJson(this IEditableFactory factory, JsonReader reader, BuiltInSchema schema)
 {
     return(factory.CreateFromJson(reader, Schema.BuiltIn[schema]));
 }
Example #18
0
 public static IEditable CreateFromMemory(this IEditableFactory factory, byte[] mem, Schema schema)
 {
     return(factory.CreateFromMemory(new ArraySegment <byte>(mem), schema));
 }
Example #19
0
 public static IEditableObject CreateItem(this IEditableFactory factory, BuiltInSchema dataSchema, bool nullable = false)
 {
     return(factory.CreateItem(Schema.BuiltIn[dataSchema], nullable));
 }
Example #20
0
 public EditablePrimitive(IEditableFactory factory, Schema schema, bool nullable, object value)
     : this(factory, schema, nullable)
 {
     this.Set(value);
 }
Example #21
0
 public static IEditableObject CreateItem(this IEditableFactory factory, string dataSchemaName, bool nullable = false)
 {
     return(factory.CreateItem(factory.SchemaProvider.GetSchemaByName(dataSchemaName), nullable));
 }
Example #22
0
 public static IEditableObject CreateItemFromJson(this IEditableFactory factory, JsonReader reader)
 {
     return((IEditableObject)factory.CreateFromJson(reader, BuiltInSchema.Item));
 }
Example #23
0
 public IEditable ToEditable(IEditableFactory factory)
 {
     return(factory.Create(this));
 }
Example #24
0
 public static IEditableObject CreateItemFromJson(this IEditableFactory factory, string json)
 {
     return((IEditableObject)factory.CreateFromJson(json, BuiltInSchema.Item));
 }
Example #25
0
 public EditablePrimitive(IEditableFactory factory, object value)
     : this(factory, FindSchemaFor(value), value == null || !value.GetType().GetTypeInfo().IsValueType, value)
 {
 }
Example #26
0
 IEditable IEditableConvertible.ToEditable(IEditableFactory factory)
 {
     return(ToEditable(factory));
 }