예제 #1
0
        public virtual ValueEditor GetValueEditor(DataType?type = null)
        {
            ValueEditor result = DefaultEditor;

            type = type ?? DataType;
            if (result == null)
            {
                switch (type.Value)
                {
                case DataType.Date:
                case DataType.Time:
                case DataType.DateTime:
                    result = new DateTimeValueEditor();
                    break;

                case DataType.Bool:
                    result = new CustomListValueEditor("BooleanValues", "MENU");
                    break;

                default:
                    result = new TextValueEditor();
                    break;
                }
            }

            if (result is DateTimeValueEditor)
            {
                ((DateTimeValueEditor)result).SubType = type.Value;
            }

            return(result);
        }
예제 #2
0
 /// <summary>
 /// Copies all attribute's properties from another entity attribute
 /// </summary>
 /// <param name="attr">An EntityAttr object to copy from.</param>
 public virtual void CopyFrom(MetaEntityAttr attr)
 {
     Caption        = attr.Caption;
     DataType       = attr.DataType;
     Description    = attr.Description;
     Expr           = attr.Expr;
     ID             = attr.ID;
     Kind           = attr.Kind;
     _lookupAttrId  = attr._lookupAttrId;
     _defaultEditor = attr.DefaultEditor;
     Size           = attr.Size;
     UserData       = attr.UserData;
     IsNullable     = attr.IsNullable;
     IsPrimaryKey   = attr.IsPrimaryKey;
     IsForeignKey   = attr.IsForeignKey;
     IsEditable     = attr.IsEditable;
     IsVisible      = attr.IsVisible;
 }
예제 #3
0
 /// <summary>
 /// Copies all attribute's properties from another entity attribute
 /// </summary>
 /// <param name="attr">An EntityAttr object to copy from.</param>
 public virtual void CopyFrom(MetaEntityAttr attr)
 {
     Caption        = attr.Caption;
     DataType       = attr.DataType;
     Description    = attr.Description;
     Expr           = attr.Expr;
     Id             = attr.Id;
     Kind           = attr.Kind;
     _lookupAttrId  = attr._lookupAttrId;
     _defaultEditor = attr.DefaultEditor;
     Size           = attr.Size;
     UserData       = attr.UserData;
     IsNullable     = attr.IsNullable;
     IsPrimaryKey   = attr.IsPrimaryKey;
     IsForeignKey   = attr.IsForeignKey;
     IsEditable     = attr.IsEditable;
     ShowInLookup   = attr.ShowInLookup;
     ShowOnView     = attr.ShowOnView;
     ShowOnEdit     = attr.ShowOnEdit;
     ShowOnCreate   = attr.ShowOnCreate;
 }
예제 #4
0
        /// <summary>
        /// Creates a value editor based on the value of "tag" property and reads the content of the newly created editor from JSON (asynchronous way).
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="ct">The cancellation token.</param>
        /// <returns>Task&lt;ValueEditor&gt;.</returns>
        /// <exception cref="BadJsonFormatException">
        /// </exception>
        public static async Task <ValueEditor> ReadFromJsonAsync(JsonReader reader, CancellationToken ct = default)
        {
            if (reader.TokenType != JsonToken.StartObject)
            {
                throw new BadJsonFormatException(reader.Path);
            }

            var jObject = await JObject.LoadAsync(reader, ct).ConfigureAwait(false);

            if (!jObject.TryGetValue("tag", out var tagToken))
            {
                throw new BadJsonFormatException(jObject.Path);
            }

            var editor       = ValueEditor.Create(tagToken.ToString());
            var editorReader = jObject.CreateReader();
            await editorReader.ReadAsync(ct).ConfigureAwait(false);

            await editor.ReadContentFromJsonAsync(editorReader, ct).ConfigureAwait(false);

            return(editor);
        }
예제 #5
0
 /// <summary>
 /// Initializes the <see cref="MetaData"/> class.
 /// Registers the main value editors types.
 /// </summary>
 static MetaData()
 {
     ValueEditor.RegisterCreator(new BasicValueEditorsCreator());
 }
예제 #6
0
 /// <summary>
 /// Inserts an element into the <see cref="T:System.Collections.ObjectModel.Collection`1"></see> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which item should be inserted.</param>
 /// <param name="item">The object to insert. The value can be null for reference types.</param>
 protected override void InsertItem(int index, ValueEditor item)
 {
     base.InsertItem(index, item);
     item.Model = Model;
 }
예제 #7
0
 /// <summary>
 /// Sets default editor without adding it to model.
 /// </summary>
 public void SetDefaultEditorWithoutChecking(ValueEditor editor)
 {
     _defaultEditor = editor;
 }