CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ObjectFieldInfo.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ObjectFieldInfo.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Contains schema information for a single</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Web.UI.Design;
10using System.ComponentModel;
11
12namespace Csla.Web.Design
13{
19 public class ObjectFieldInfo : IDataSourceFieldSchema
20 {
21 private Type _dataType;
22 private bool _primaryKey;
23 private bool _isIdentity;
24 private bool _isNullable;
25 private int _length;
26 private bool _isReadOnly;
27 private string _name;
28 private bool _nullable;
29
35 public ObjectFieldInfo(PropertyDescriptor field)
36 {
37 DataObjectFieldAttribute attribute =
38 (DataObjectFieldAttribute)
39 field.Attributes[typeof(DataObjectFieldAttribute)];
40 if (attribute != null)
41 {
42 _primaryKey = attribute.PrimaryKey;
43 _isIdentity = attribute.IsIdentity;
44 _isNullable = attribute.IsNullable;
45 _length = attribute.Length;
46 }
47 _dataType = Utilities.GetPropertyType(
48 field.PropertyType);
49 _isReadOnly = field.IsReadOnly;
50 _name = field.Name;
51
52 // nullable
53 Type t = field.PropertyType;
54 if (!t.IsValueType || _isNullable)
55 _nullable = true;
56 else
57 {
58 if (t.IsGenericType)
59 _nullable = (t.GetGenericTypeDefinition() == typeof(Nullable<>));
60 else
61 _nullable = false;
62 }
63 }
64
68 public Type DataType
69 {
70 get
71 {
72 return _dataType;
73 }
74 }
75
85 public bool Identity
86 {
87 get { return _isIdentity; }
88 }
89
94 public bool IsReadOnly
95 {
96 get { return _isReadOnly; }
97 }
98
108 public bool IsUnique
109 {
110 get { return _primaryKey; }
111 }
112
121 public int Length
122 {
123 get { return _length; }
124 }
125
129 public string Name
130 {
131 get { return _name; }
132 }
133
145 public bool Nullable
146 {
147 get
148 { return _nullable; }
149 }
150
155 public int Precision
156 {
157 get { return -1; }
158 }
159
169 public bool PrimaryKey
170 {
171 get { return _primaryKey; }
172 }
173
178 public int Scale
179 {
180 get { return -1; }
181 }
182 }
183}
Contains schema information for a single object property.
bool Nullable
Gets a value indicating whether the property is nullable
Type DataType
Gets the data type of the property.
bool PrimaryKey
Gets a value indicating whether the property is a primary key value.
int Length
Gets the length of the property value.
bool Identity
Gets a value indicating whether this property is an identity key for the object.
int Precision
Gets the property's numeric precision.
ObjectFieldInfo(PropertyDescriptor field)
Creates an instance of the object.
bool IsUnique
Gets a value indicating whether this property must contain a unique value.
int Scale
Gets the property's scale.
string Name
Gets the property name.
bool IsReadOnly
Gets a value indicating whether this property is readonly.
@ Serializable
Prevents updating or inserting until the transaction is complete.