Beispiel #1
0
 static AccountsEntity()
 {
     IdProperty.OverrideMeta(typeof(AccountsEntity), new PropertyMetadata <object>(), m =>
     {
         m.DefaultValue = AccountsPlugin.KeyProvider.DefaultValue;
     });
 }
Beispiel #2
0
 static SerialNumberEntity()
 {
     IdProperty.OverrideMeta(typeof(SerialNumberEntity), new PropertyMetadata <object>(), m =>
     {
         m.DefaultValue = SerialNumberPlugin.KeyProvider.DefaultValue;
     });
 }
Beispiel #3
0
 public void SetIdForResource(object resource, string id)
 {
     if (resource == null)
     {
         throw new ArgumentNullException(nameof(resource));
     }
     IdProperty.SetValue(resource, id); // TODO: handle classes with non-string ID types
 }
Beispiel #4
0
        public void SetId(object instance, Guid id)
        {
            if (instance == null)
            {
                throw new NullReferenceException("SetId cannot be called on a null instance");
            }

            IdProperty.SetValue(instance, id);
        }
Beispiel #5
0
        static Entity()
        {
            KeyProviderField = KeyProviders.Get(typeof(TKey));

            IdProperty.OverrideMeta(typeof(Entity <TKey>), new PropertyMetadata <object>(), m =>
            {
                m.DefaultValue = KeyProviderField.DefaultValue;
            });
        }
Beispiel #6
0
 /// <summary>
 /// 書籍情報を更新する(ダミー)
 /// </summary>
 public void Update()
 {
     if (Id == 0)
     {
         BookCount++;
         IdProperty.Init(BookCount);
     }
     Clean();
 }
Beispiel #7
0
 /// <summary>
 /// コンストラクタ(3)
 /// </summary>
 /// <param name="book">Book</param>
 public Book(Book book)
     : this()
 {
     IdProperty.Init(book.Id);
     TitleProperty.Init(string.Format("*{0}", book.Title));
     AuthorProperty.Init(book.Author);
     PublisherProperty.Init(book.Publisher);
     CategoryProperty.Init(book.Category);
     PriceProperty.Init(book.Price);
     PurchaseDateProperty.Init(book.PurchaseDate);
     ReviewPointProperty.Init(book.ReviewPoint);
 }
Beispiel #8
0
 /// <summary>
 /// コンストラクタ(2)
 /// </summary>
 /// <param name="id">int : ID</param>
 /// <param name="title">string : タイトル</param>
 /// <param name="author">string : 著者</param>
 /// <param name="publisher">string : 出版社</param>
 /// <param name="category">BookCategories : カテゴリー</param>
 /// <param name="price">decimal : 価格</param>
 /// <param name="purchaseDate">DateTime? : 購入日</param>
 /// <param name="reviewPoint">int : 評価点</param>
 public Book(int id, string title, string author, string publisher, BookCategories category, decimal price, DateTime?purchaseDate, int reviewPoint)
     : this()
 {
     IdProperty.Init(id);
     TitleProperty.Init(title);
     AuthorProperty.Init(author);
     PublisherProperty.Init(publisher);
     CategoryProperty.Init(category);
     PriceProperty.Init(price);
     PurchaseDateProperty.Init(purchaseDate);
     ReviewPointProperty.Init(reviewPoint);
 }
Beispiel #9
0
        public void ParseIdProperty_ForeignColumn()
        {
            ClassInfo  clazz      = TestUtils.ParseHbm("Agency.hbm.xml", "HeadQuarter", ClassType.RootClass);
            IdProperty idProperty = clazz.GetIdProperty();

            idProperty.Should()
            .HaveName("Id")
            .HaveTagName("Id")
            .HaveAttribute("type", "Int64")
            .HaveAttribute("generator", "foreign");

            idProperty.GeneratorParams.Should()
            .HaveAttribute("property", "Agency");
        }
Beispiel #10
0
        public string GetIdForResource(object resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }
            var resourceId = IdProperty.GetValue(resource);

            if (resourceId == null)
            {
                throw new ArgumentException($"The ID for the provided `{ResourceTypeName}` resource is null.");
            }
            return(resourceId.ToString());
        }
Beispiel #11
0
        public override Property Parse(ClassInfo clazz, XElement element)
        {
            var prop             = base.Parse(clazz, element);
            var generatorElement = element.GetElement("generator");
            var generatorClass   = generatorElement.GetAttributeValue("class");

            var idProp = new IdProperty(clazz, prop.Name, generatorClass);

            idProp.AddAttributes(prop);

            generatorElement.Elements().Where(x => x.Name.LocalName == "param").ToList()
            .ForEach(p => idProp.GeneratorParams.Add(p.GetAttributeValue("name"), p.Value));

            return(idProp);
        }
Beispiel #12
0
        public void AddProperty(DbAttribute attribute, int row, int column, FrameworkElement parent = null, bool ignorePrimary = false)
        {
            if (!ignorePrimary)
            {
                if (attribute.PrimaryKey)
                {
                    IdProperty <TKey> obj = new IdProperty <TKey>();
                    obj.Initialize(attribute, row, column, this, parent as Grid);
                    _formattedProperties.Add((FormatConverter <TKey, TValue>)((object)obj));
                    return;
                }
            }

            if (attribute.DataType == typeof(int) ||
                attribute.DataType == typeof(string))
            {
                FrameworkElement element = AddTextBox(row, column, parent);

                _resetFields.Add(element);
                _update.Add(new Tuple <DbAttribute, FrameworkElement>(attribute, element));
            }
            else if (attribute.DataType == typeof(bool))
            {
                FrameworkElement element = AddCheckBox(row, column, parent);

                _resetFields.Add(element);
                _update.Add(new Tuple <DbAttribute, FrameworkElement>(attribute, element));
            }
            else if (attribute.DataType.BaseType == typeof(Enum))
            {
                ComboBox element = AddComboBox(row, column, parent);

                element.ItemsSource = Enum.GetValues(attribute.DataType).Cast <Enum>().Select(p => _getDescription(Description.GetDescription(p)));

                _resetFields.Add(element);
                _update.Add(new Tuple <DbAttribute, FrameworkElement>(attribute, element));
            }
            else if (_isType <FormatConverter <TKey, TValue> >(attribute.DataType))
            {
                FormatConverter <TKey, TValue> obj = (FormatConverter <TKey, TValue>)Activator.CreateInstance(attribute.DataType, new object[] { });
                obj.Initialize(attribute, row, column, this, parent as Grid);
                _formattedProperties.Add(obj);
            }
        }
Beispiel #13
0
        public override IAliasedCommandTypeDataOrder Lookup(TModel model)
        {
            Clause whereClause =
                Clause
                .New()
                .AddClause(
                    IdProperty.GetValue(model),
                    Clause.EqualStatementCallback(IdProperty.Name)
                    );

            var fields = typeof(TModel).GetProperties().Select(p => p.Name);

            var selectQuery =
                SelectQuery
                .New(TableName, fields, false)
                .Build(whereClause);

            return(new AliasedCommandTypeDataOrder(selectQuery, System.Data.CommandType.Text));
        }
Beispiel #14
0
        public void ParseIdProperty_AssignedId()
        {
            ClassInfo  clazz      = TestUtils.ParseHbm("BaseObject.hbm.xml", "BaseObject", ClassType.RootClass);
            IdProperty idProperty = clazz.GetIdProperty();

            idProperty.Should().NotBeNull();
            idProperty.Should()
            .HaveName("Id")
            .HaveTagName("Id")
            .HaveAttribute("type", "Int64")
            .HaveAttribute("generator", "assigned")
            .NotHaveAttribute("name");

            idProperty.GeneratorParams.Should().NotBeNull();

            idProperty.GeneratorParams.Should()
            .HaveName("assigned")
            .HaveTagName("generator");

            idProperty.GeneratorParams.Should().BeEmpty();
        }
Beispiel #15
0
 private set => SetProperty(IdProperty, value);
Beispiel #16
0
 set => SetProperty(IdProperty, value);
Beispiel #17
0
 get => GetProperty(IdProperty, _id);
Beispiel #18
0
 /// <summary>
 /// 書籍情報を削除する(ダミー)
 /// </summary>
 public void Delete()
 {
     IdProperty.Init(0);
 }
 public void SetIdForResource(object resource, string id)
 {
     IdProperty.SetValue(resource, id); // TODO: handle classes with non-string ID types
 }
Beispiel #20
0
 set => SetValue(IdProperty, value);
 private set => LoadProperty(IdProperty, value);
 public string GetIdForResource(object resource)
 {
     return(IdProperty.GetValue(resource).ToString());
 }