Esempio n. 1
0
 private static IEnumerable <KeyValuePair <string, object> > PropValuesToAttributeNameValues(IEnumerable <PropValue> propValues)
 {
     foreach (PropValue propValue in propValues)
     {
         PropValue propValue2 = propValue;
         XmlAttributePropertyDefinition xmlAttrPropDef = propValue2.Property as XmlAttributePropertyDefinition;
         if (xmlAttrPropDef != null)
         {
             string    xmlAttributeName = xmlAttrPropDef.XmlAttributeName;
             PropValue propValue3       = propValue;
             yield return(new KeyValuePair <string, object>(xmlAttributeName, propValue3.Value));
         }
     }
     yield break;
 }
Esempio n. 2
0
        private List <PropValue> ReadAttributes(Schema schema)
        {
            List <PropValue> list = new List <PropValue>();

            foreach (PropertyDefinition propertyDefinition in schema.AllProperties)
            {
                XmlAttributePropertyDefinition xmlAttributePropertyDefinition = propertyDefinition as XmlAttributePropertyDefinition;
                if (xmlAttributePropertyDefinition != null)
                {
                    object obj = this.ReadAttributeForProperty(xmlAttributePropertyDefinition);
                    if (obj != null)
                    {
                        list.Add(new PropValue(xmlAttributePropertyDefinition, obj));
                    }
                }
            }
            return(list);
        }
Esempio n. 3
0
        private object ReadAttributeForProperty(XmlAttributePropertyDefinition xmlAttrPropDef)
        {
            if (!this.xmlReader.MoveToAttribute(xmlAttrPropDef.XmlAttributeName) && !this.xmlReader.MoveToAttribute(xmlAttrPropDef.XmlAttributeName, "CategoryList.xsd"))
            {
                return(null);
            }
            Exception ex2;

            try
            {
                if (xmlAttrPropDef.Type == typeof(Guid))
                {
                    return(new Guid(this.xmlReader.Value));
                }
                if (xmlAttrPropDef.Type == typeof(ExDateTime))
                {
                    return(ConvertUtils.GetDateTimeFromXml(this.xmlReader.Value));
                }
                return(this.xmlReader.ReadContentAs(xmlAttrPropDef.Type, null));
            }
            catch (XmlException ex)
            {
                ex2 = ex;
            }
            catch (FormatException ex3)
            {
                ex2 = ex3;
            }
            catch (OverflowException ex4)
            {
                ex2 = ex4;
            }
            catch (InvalidCastException ex5)
            {
                ex2 = ex5;
            }
            finally
            {
                this.xmlReader.MoveToElement();
            }
            ExTraceGlobals.StorageTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Couldn't parse a value for the MasterCategoriesList property {0}: {1}", xmlAttrPropDef.Name, ex2.Message);
            this.ReportFault();
            return(null);
        }
Esempio n. 4
0
        private void ValidateAndFillInDefaults()
        {
            foreach (PropertyDefinition propertyDefinition in CategorySchema.Instance.AllProperties)
            {
                XmlAttributePropertyDefinition xmlAttributePropertyDefinition = propertyDefinition as XmlAttributePropertyDefinition;
                if (xmlAttributePropertyDefinition != null)
                {
                    object obj = this.propertyBag.TryGetProperty(xmlAttributePropertyDefinition);
                    PropertyValidationError[] array = null;
                    if (PropertyError.IsPropertyNotFound(obj) || (array = xmlAttributePropertyDefinition.Validate(null, obj)).Length > 0)
                    {
                        if (xmlAttributePropertyDefinition.HasDefaultValue)
                        {
                            this.propertyBag[xmlAttributePropertyDefinition] = xmlAttributePropertyDefinition.DefaultValue;
                        }
                        else if (array != null && array.Length > 0)
                        {
                            throw new PropertyValidationException(array[0].Description, xmlAttributePropertyDefinition, array);
                        }
                    }
                }
            }
            List <StoreObjectValidationError> list = new List <StoreObjectValidationError>();
            ValidationContext context = new ValidationContext(null);

            foreach (StoreObjectConstraint storeObjectConstraint in CategorySchema.Instance.Constraints)
            {
                StoreObjectValidationError storeObjectValidationError = storeObjectConstraint.Validate(context, this.propertyBag);
                if (storeObjectValidationError != null)
                {
                    list.Add(storeObjectValidationError);
                }
            }
            if (list.Count > 0)
            {
                throw new ObjectValidationException(list[0].Description, list.ToArray());
            }
        }