private Action <ISimpleProperty, XmlReader, object> CreateSetValueAction(Type propertyType) { Action <ISimpleProperty, XmlReader, object> action; Action <ISimpleProperty, XmlReader, object> action2 = null; Action <ISimpleProperty, XmlReader, object> action3 = null; if (typeof(string).IsAssignableFrom(propertyType)) { action = delegate(ISimpleProperty property, XmlReader reader, object entity) { string str = reader.ReadString(); property.SetValue(entity, str); }; } else if (typeof(ILocaleValue).IsAssignableFrom(propertyType)) { if (action2 == null) { action2 = delegate(ISimpleProperty property, XmlReader reader, object entity) { string str = reader.ReadString(); int lCID = this._binder.Culture.LCID; if (this.ResetLoacaleValueBy2052 && (lCID == 0x804)) { property.ResetValue(entity); } ILocaleValue value2 = (ILocaleValue)property.GetValue(entity); if (value2 == null) { value2 = (ILocaleValue)this.ConvertFromString(property, entity, str); property.SetValue(entity, value2); } if (str != string.Empty) { value2[lCID] = str; } }; } action = action2; } else if (typeof(byte[]).IsAssignableFrom(propertyType)) { action = delegate(ISimpleProperty property, XmlReader reader, object entity) { byte[] buffer = new byte[0x200]; using (MemoryStream stream = new MemoryStream()) { int num; while ((num = reader.ReadElementContentAsBase64(buffer, 0, 0x200)) > 0) { stream.Write(buffer, 0, num); } property.SetValue(entity, stream.ToArray()); } }; } else { if (action3 == null) { action3 = delegate(ISimpleProperty property, XmlReader reader, object entity) { string str = reader.ReadString(); object obj2 = this.ConvertFromString(property, entity, str); property.SetValue(entity, obj2); }; } action = action3; } action = this._binder.BindReadAction(propertyType, action); if (action == null) { throw new ArgumentNullException("BindReadDataAction"); } return(action); }
private void DoSimplePropertyAction(string action, ISimpleProperty property, object entity) { string str = action; if (str != null) { if (!(str == "setvalue")) { if (str == "reset") { if (typeof(ILocaleValue).IsAssignableFrom(property.PropertyType)) { ILocaleValue value2 = (ILocaleValue)property.GetValue(entity); if (value2 == null) { property.ResetValue(entity); } else if (property is SimpleProperty) { int lCID = this._binder.Culture.LCID; if (lCID != 0x804) { value2[lCID] = value2[0x804]; } else { property.ResetValue(entity); } } } else { property.ResetValue(entity); } goto Label_01FC; } if (str == "setnull") { try { property.SetValue(entity, null); } catch (Exception exception2) { SerializationException.SerializationExceptionData data2 = new SerializationException.SerializationExceptionData { CanIgnore = true }; this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("在赋值{0}:{1}的值 Null 时失败,{2}", "014009000001741", SubSystemType.SL, new object[0]), property.Name, property.PropertyType.Name, exception2.Message), data2, exception2); } goto Label_01FC; } } else { try { this.GetSetValueAction(property.PropertyType)(property, this._reader, entity); } catch (Exception exception) { SerializationException.SerializationExceptionData data = new SerializationException.SerializationExceptionData { CanIgnore = true }; this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("在赋值{0}:{1}的值'{2}'时失败,{3}", "014009000001740", SubSystemType.SL, new object[0]), new object[] { property.Name, property.PropertyType.Name, this._reader.ReadString(), exception.Message }), data, exception); } goto Label_01FC; } } SerializationException.SerializationExceptionData data3 = new SerializationException.SerializationExceptionData { CanIgnore = true }; this.ThrowXmlException("??????", string.Format(ResManager.LoadKDString("不能识别的属性操作符{0}", "014009000001742", SubSystemType.SL, new object[0]), action), data3, null); Label_01FC: this.SafeDo(); }