protected StructuralProperty(StructuralProperty prop)
 {
     this.IsInherited  = true;
     this.Name         = prop.Name;
     this.NameOnServer = prop.NameOnServer;
     this.Custom       = prop.Custom;
     this.IsInherited  = prop.IsInherited;
     this.IsScalar     = prop.IsScalar;
     this.IsUnmapped   = prop.IsUnmapped;
     this._validators  = new ValidatorCollection(prop.Validators);
 }
Ejemplo n.º 2
0
        // called internally by property set logic
        internal IEnumerable <ValidationError> ValidateProperty(StructuralProperty prop, Object value)
        {
            IEnumerable <ValidationError> errors = null;
            var co = value as IComplexObject;

            if (co != null)
            {
                errors = co.ComplexAspect.Validate();
            }
            var vc         = new ValidationContext(this.StructuralObject, prop, value);
            var itemErrors = prop.Validators.Select(vr => ValidateCore(vr, vc)).Where(ve => ve != null);

            return(errors == null?itemErrors.ToList() : errors.Concat(itemErrors).ToList());
        }
        internal void CheckProperty(StructuralProperty prop, Object v1, Object v2, String name)
        {
            if (v1 == null && v2 == null)
            {
                return;
            }
            if (Object.Equals(v1, v2))
            {
                return;
            }
            var detail = String.Format("Client value: '{0}',  Server value: '{1}'",
                                       (v1 ?? "").ToString(), (v2 ?? "").ToString());

            MetadataStore.OnMetadataMismatch(prop.ParentType.Name, prop.Name, MetadataMismatchType.InconsistentCLRPropertyDefinition, detail);
        }
Ejemplo n.º 4
0
        public EntityError Resolve(EntityManager em)
        {
            IsServerError = true;
            try {
                EntityType entityType = null;
                if (EntityTypeName != null)
                {
                    var stName = TypeNameInfo.FromClrTypeName(EntityTypeName).ToClient(em.MetadataStore).StructuralTypeName;
                    entityType = em.MetadataStore.GetEntityType(stName);
                    var ek = new EntityKey(entityType, KeyValues);
                    Entity = em.GetEntityByKey(ek);
                }


                if (entityType != null)
                {
                    if (PropertyName != null)
                    {
                        Property = entityType.Properties.FirstOrDefault(p => p.NameOnServer == PropertyName);
                        if (Property != null)
                        {
                            PropertyName = Property.Name;
                        }
                    }

                    var vc = new ValidationContext(this.Entity);
                    vc.Property = Property;
                    var veKey = (ErrorName ?? ErrorMessage) + (PropertyName ?? "");
                    var ve    = new ValidationError(null, vc, ErrorMessage, veKey);
                    ve.IsServerError = true;
                    this.Entity.EntityAspect.ValidationErrors.Add(ve);
                }
            } catch (Exception e) {
                ErrorMessage = (ErrorMessage ?? "") + ":  Unable to Resolve this error: " + e.Message;
            }
            return(this);
        }
Ejemplo n.º 5
0
 public T GetValue <T>(StructuralProperty prop)
 {
     return((T)GetRawValue(prop.Name));
 }
Ejemplo n.º 6
0
 public Object GetValue(StructuralProperty prop)
 {
     return(GetValue(prop.Name));
 }
Ejemplo n.º 7
0
        public IEnumerable <ValidationError> ValidateProperty(StructuralProperty prop)
        {
            var value = this.GetValue(prop);

            return(ValidateProperty(prop, value));
        }
Ejemplo n.º 8
0
 public ValidationContext(IStructuralObject so, StructuralProperty property, Object propertyValue)
     : this(so) {
     Property      = property;
     PropertyValue = propertyValue;
 }