Пример #1
0
        private int FindItemIndex(ICollectionProperty property, object entity, object item)
        {
            object          obj3;
            ISimpleProperty primaryKey = this._binder.GetDataEntityType(item).PrimaryKey;

            if (primaryKey == null)
            {
                return(-1);
            }
            object obj2 = primaryKey.GetValue(item);
            string oid  = (obj2 == null) ? "" : obj2.ToString();

            return(this.FindItemByOid(property, entity, oid, out obj3));
        }
Пример #2
0
        public static T GetPrimaryKeyValue <T>(this IDataEntityBase dataEntity, bool throwOnError = true)
        {
            if (dataEntity == null)
            {
                if (throwOnError)
                {
                    throw new ArgumentNullException("dataEntity");
                }
                return(default(T));
            }
            ISimpleProperty primaryKey = dataEntity.GetDataEntityType().PrimaryKey;

            if (primaryKey != null)
            {
                return((T)primaryKey.GetValue(dataEntity));
            }
            if (throwOnError)
            {
                throw new NotSupportedException(string.Format(ResManager.LoadKDString("实体类型{0}沒有定义主键,无法获取。", "014009000001732", SubSystemType.SL, new object[0]), dataEntity.GetDataEntityType().Name));
            }
            return(default(T));
        }
Пример #3
0
        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();
        }