コード例 #1
0
 public FieldBase(FieldType Type, FieldBase Base)
 {
     this.Type = Type;
     this.Name = Type.Name;
     this.TenantID = Configure.GetTenantResolutionProvider().GetTenantID();
     LoadUpValues(Base);
 }
コード例 #2
0
 public FieldEntityReference(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.EntityReference)
     {
         throw new ArgumentOutOfRangeException("Cannot create an entity reference field from a non-entity-reference type.");
     }
 }
コード例 #3
0
 public FieldLazyBinary(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.Binary)
     {
         throw new ArgumentOutOfRangeException("Cannot create a binary field from a non-binary type.");
     }
 }
コード例 #4
0
 public FieldString(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.Text)
     {
         throw new ArgumentOutOfRangeException("Cannot create a string field from a non-string type.");
     }
 }
コード例 #5
0
 public FieldDecimal(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.Decimal)
     {
         throw new ArgumentOutOfRangeException("Cannot create a decimal field from a non-decimal type.");
     }
 }
コード例 #6
0
 public FieldLookup(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.Lookup)
     {
         throw new ArgumentOutOfRangeException("Cannot create a lookup field from a non-lookup type.");
     }
 }
コード例 #7
0
 public FieldBase(FieldType Type, FieldBase Base, EntityBase Entity, IDbContext ctx = null)
 {
     this.Type = Type;
     this.Name = Type.Name;
     this.Entity = Entity;
     this.TenantID = Configure.GetTenantResolutionProvider().GetTenantID();
     LoadUpValues(Base);
     TryLoadFieldMeta(ctx);
 }
コード例 #8
0
        /// <summary>
        /// Compares the value of this binary field to another and return true if they are identical, byte for byte.
        /// </summary>
        /// <param name="OtherField">The other field.</param>
        /// <returns>true if the field values are identical, false otherwise</returns>
        public override bool IsIdenticalTo(FieldBase OtherField)
        {
            if (OtherField == null)
            {
                Log.Warn("Trying to compare Field to a null Field. FieldID: {0}",
                        FieldID.HasValue ? FieldID.Value.ToString() : "null");

                throw new ArgumentNullException(nameof(OtherField));
            }
            if (OtherField.Type.DataType != this.Type.DataType)
            {
                Log.Warn("Trying to compare Field to a Field of a different type. FieldID: {0}, Other FieldID: {1}, Field Type: {2}, Other Field Type: {3}",
                    FieldID.HasValue ? FieldID.Value.ToString() : "null",
                    OtherField.FieldID.HasValue ? OtherField.FieldID.Value.ToString() : "null",
                    Type.Name, OtherField.Type.Name);

                throw new InvalidOperationException("Cannot compare two fields of different types.");
            }

            if (((IField)this).Value == null && ((IField)OtherField).Value == null) // Both are null, identical
            {
                return true;
            }

            if ((((IField)this).Value == null && ((IField)OtherField).Value != null) ||  // If a is null and b is not, not identical
                 (((IField)this).Value != null && ((IField)OtherField).Value == null))   // If b is null and a is not, not identical
            {
                return false;
            }

            // Both are not null, use byte-by-byte comparison.
            return this.Value.SequenceEqual(((FieldBinary)OtherField).Value);
        }
コード例 #9
0
ファイル: Form.cs プロジェクト: emisaacson/EffectFramework
        /// <summary>
        /// Gets the name of the field bound to this member on the form
        /// if it exists, otherwise null.
        /// </summary>
        /// <param name="Field">The field to search for</param>
        /// <returns>The name of the bound field, or null</returns>
        public string GetFormFieldNameIfBound(FieldBase Field)
        {
            if (Field == null)
            {
                return null;
            }

            var AllFields = GetBoundFields();

            foreach (var _Field in AllFields)
            {
                var BoundField = (FieldBase)GetBoundField(_Field.Name);
                if (BoundField.Entity.Item.Type == Field.Entity.Item.Type &&
                    BoundField.Entity.Type == Field.Entity.Type &&
                    BoundField.Type == Field.Type)
                {
                    return _Field.Name;
                }
            }

            return null;
        }
コード例 #10
0
 public ValidationResult(FieldBase Field, string Message)
 {
     this._Field = Field;
     this.Message = Message;
 }
コード例 #11
0
        protected void LoadUpValues(FieldBase Base)
        {
            Log.Trace("Loading values for Field. FieldID: {0}",
                Base == null || !Base.FieldID.HasValue ? "null" : Base.FieldID.Value.ToString());

            this.TenantID = Configure.GetTenantResolutionProvider().GetTenantID();
            if (Base == null)
            {
                this.FieldID      = null;

                this.ValueString  = null;
                this.ValueDate    = null;
                this.ValueDecimal = null;
                this.ValueBool    = null;
                this.ValueLookup  = null;
                this.ValueBinary  = null;
                this.ValueEntityReference = null;
                this.ValueItemReference = null;
            }
            else
            {
                if (Base.TenantID != this.TenantID)
                {
                    Log.Fatal("TenantID Does not match. FieldID: {0}, Global TenantID: {1}, Other Field TenantID : {2}",
                        this.FieldID, this.TenantID, Base.TenantID);
                    throw new FatalException("Data error.");
                }

                this.FieldID      = Base.FieldID;

                this.ValueString  = Base.ValueString;
                this.ValueDate    = Base.ValueDate;
                this.ValueDecimal = Base.ValueDecimal;
                this.ValueBool    = Base.ValueBool;
                this.ValueLookup  = Base.ValueLookup;
                this.ValueBinary  = Base.ValueBinary;
                this.ValueEntityReference = Base.ValueEntityReference;
                this.ValueItemReference = Base.ValueItemReference;

                this.Guid         = Base.Guid;
            }
            this.Dirty = false;

            if (this is ISerializableField)
            {
                ((ISerializableField)this).DeserializeField();
            }

            RefreshOriginalValues();
        }
コード例 #12
0
        /// <summary>
        /// Compares the value of this field to another and return true if they are identical. This
        /// method may be overridden in subclasses.
        /// </summary>
        /// <param name="OtherField">The other field.</param>
        /// <returns>true if the field values are identical, false otherwise</returns>
        public virtual bool IsIdenticalTo(FieldBase OtherField)
        {
            if (OtherField == null)
            {
                Log.Warn("Trying to compare Field to a null Field. FieldID: {0}",
                    FieldID.HasValue ? FieldID.Value.ToString() : "null");

                throw new ArgumentNullException(nameof(OtherField));
            }
            if (OtherField.Type.DataType != this.Type.DataType)
            {
                Log.Warn("Trying to compare Field to a Field of a different type. FieldID: {0}, Other FieldID: {1}, Field Type: {2}, Other Field Type: {3}",
                    FieldID.HasValue ? FieldID.Value.ToString() : "null",
                    OtherField.FieldID.HasValue ? OtherField.FieldID.Value.ToString() : "null",
                    Type.Name, OtherField.Type.Name);

                throw new InvalidOperationException("Cannot compare two fields of different types.");
            }
            if (OtherField.TenantID != this.TenantID)
            {
                Log.Error("TenantID Does not match. FieldID: {0}, Other Field ID: {1}, TenantID: {2}, Other TenantID: {3}",
                    FieldID, OtherField.FieldID, TenantID, OtherField.TenantID);
                throw new FatalException("Data error.");
            }

            if (((IField)this).Value == null && ((IField)OtherField).Value == null) // Both are null, identical
            {
                return true;
            }

            if ((((IField)this).Value == null && ((IField)OtherField).Value != null) ||  // If a is null and b is not, not identical
                (((IField)this).Value != null && ((IField)OtherField).Value == null))    // If b is null and a is not, not identical
            {
                return false;
            }

            // Both are not null, use the default comparison
            return ((IField)this).Value.Equals(((IField)OtherField).Value);
        }
コード例 #13
0
 public void FillFromDatabase(EntityBase Entity, FieldBase Field, IDbContext ctx = null)
 {
     if (Entity.TenantID != this.TenantID ||
         Field.TenantID != this.TenantID)
     {
         Log.Fatal("TenantID Does not match. EntityID: {0}, Entity TenantID {1}, Field ID: {2}, Field TenantID : {3}, this FieldID: {4}, this TenantID {5}",
             Entity.EntityID, Entity.TenantID, Field.FieldID, Field.TenantID, this.FieldID, this.TenantID);
         throw new FatalException("Data error.");
     }
     FieldBase Base = PersistenceService.RetreiveSingleFieldOrDefault(Entity, Field.Type, ctx);
     LoadUpValues(Base);
 }