예제 #1
0
        public object ReadElement(IDataEntityType dt, object entity)
        {
            MoveToFirstElement(this._reader);
            string name = this._reader.Name;

            if (entity == null)
            {
                dt = this.BindToType(dt);
                if (dt.Flag != DataEntityTypeFlag.Primitive)
                {
                    entity = this._binder.CreateInstance(dt);
                }
            }
            else
            {
                IDataEntityType dataEntityType = this.GetDataEntityType(entity);
                if (dataEntityType != null)
                {
                    dt = this.BindToType(dt);
                    if ((!object.Equals(dt, dataEntityType) && !dt.IsAssignableFrom(dataEntityType)) && (dt.Flag != DataEntityTypeFlag.Primitive))
                    {
                        entity = this._binder.CreateInstance(dt);
                    }
                }
            }
            this.Push(entity);
            if (!this._reader.IsEmptyElement)
            {
                if (dt.Flag != DataEntityTypeFlag.Primitive)
                {
                    while (this.MoveToNextElement(name))
                    {
                        IDataEntityProperty property;
                        if ((dt.Properties.TryGetValue(this._reader.Name, out property) && !this.ReadSimpleProperty(property as ISimpleProperty, entity)) && (!this.ReadComplexProperty(property as IComplexProperty, entity) && !this.ReadCollectionProperty(property as ICollectionProperty, entity)))
                        {
                            SerializationException.SerializationExceptionData data = new SerializationException.SerializationExceptionData
                            {
                                CanIgnore = true
                            };
                            this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("XML节点中出现的属性{0},必须是简单属性、复杂或集合属性的一种。", "014009000001739", SubSystemType.SL, new object[0]), property.Name), data, null);
                        }
                        this.SafeDo();
                    }
                    return(entity);
                }
                string str2          = this._reader.ReadString();
                Type   primitiveType = DcxmlBinder.GetPrimitiveType(dt.Name.ToLowerInvariant());
                if (primitiveType != typeof(string))
                {
                    entity = Convert.ChangeType(str2, primitiveType, this._binder.Culture);
                }
                else
                {
                    entity = str2;
                }
                this.SafeDo();
            }
            return(entity);
        }
 public DcxmlSerializerWriteImplement(DcxmlBinder dcxmlBinder, System.Xml.XmlWriter writer, bool p1, bool p2)
 {
     // TODO: Complete member initialization
     this.dcxmlBinder = dcxmlBinder;
     this.writer      = writer;
     this.p1          = p1;
     this.p2          = p2;
 }
예제 #3
0
 // Methods
 public DcxmlSerializer(DcxmlBinder binder)
 {
     if (binder == null)
     {
         throw new ORMArgInvalidException("??????", ResManager.LoadKDString("设置DcxmlSerializer的binder失败,binder不能为空!", "014009000001765", SubSystemType.SL, new object[0]));
     }
     this._binder = binder;
     this._serializeComplexProperty = true;
 }
예제 #4
0
 // Methods
 internal DcxmlSerializerReadImplement(DcxmlBinder binder, XmlReader reader)
 {
     if (binder == null)
     {
         throw new ArgumentNullException("binder");
     }
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     this._binder = binder;
     this._reader = reader;
     this._supportInitializeObjects = new Stack <ISupportInitialize>();
     this._context = new DcxmlTypeDescriptorContext(null);
     this._setValueActionsCache = new Dictionary <Type, Action <ISimpleProperty, XmlReader, object> >();
 }
예제 #5
0
 internal DcxmlSerializerReadImplement(DcxmlBinder binder, XmlReader reader, bool colloctionIgnorePKValue = false)
     : this(binder, reader)
 {
     this._colloctionIgnorePKValue = colloctionIgnorePKValue;
 }
예제 #6
0
 public DcxmlSerializer(IEnumerable <IDataEntityType> dts)
 {
     this._binder = new ListDcxmlBinder(dts);
     this._serializeComplexProperty = true;
 }