Exemplo n.º 1
0
 /// <summary>
 /// 發生於特性狀態變更
 /// </summary>
 protected virtual void OnStatusChanged(PropertyStatus oldValue, PropertyStatus newValue)
 {
     if (StatusChanged != null)
     {
         StatusChanged(this, oldValue, newValue);
     }
 }
        public void EnsureLoaded()
        {
            if (MuteNotify)
            {
                return;
            }

            IContext       ctx        = interceptable.GetInterceptor().Context;
            IObjectManager om         = ctx.ObjectManager;
            PropertyStatus propStatus = om.GetPropertyStatus(interceptable, propertyName);

            if (propStatus == PropertyStatus.NotLoaded)
            {
                ObjectStatus objStatus = om.GetObjectStatus(interceptable);
                if (!(objStatus == ObjectStatus.UpForCreation))
                {
                    bool stackMute = MuteNotify;
                    MuteNotify = true;

                    ctx.PersistenceEngine.LoadProperty(interceptable, propertyName);

                    MuteNotify = stackMute;
                }
            }
        }
Exemplo n.º 3
0
        public async Task <OperationResult> ProcessAsync(long id, PropertyStatus status, string comment = null)
        {
            if (status != PropertyStatus.Realized && status != PropertyStatus.Reserved)
            {
                return(OperationResult.BadRequest);
            }

            var property = await _propertyRepository.GetAsync(id);

            if (property == null)
            {
                return(OperationResult.NotFound);
            }

            await _propertyValidator.ValidateAsync(property, PropertyAction.Process);

            property.Status = status;

            _propertyRepository.Update(property);

            if (!string.IsNullOrEmpty(comment))
            {
                // TODO: May be call service?
                _commentRepository.Create(new Comment()
                {
                    UserId     = _identityService.GetUserId(),
                    PropertyId = id,
                    Text       = comment
                });
            }

            await _unitOfWork.SaveAsync();

            return(OperationResult.Success);
        }
Exemplo n.º 4
0
        private void SetStatusControl()
        {
            if (Template != null && DesignModeHelper.IsInDesignMode == false)
            {
                PropertyStatus status = GetTemplateChild("PART_PropertyStatus") as PropertyStatus;
                if (status != null)
                {
                    BindingExpression expression = GetBindingExpression(SelectedValueProperty);
                    if (expression != null &&
                        expression.ParentBinding != null &&
                        expression.ParentBinding.Path != null)
                    {
                        var binding = new Binding(expression.ParentBinding.Path.Path)
                        {
                            Source = expression.ParentBinding.Source
                        };

                        if (binding.Source == null)
                        {
                            binding.Source = DataContext;
                        }

                        status.SetBinding(PropertyStatus.PropertyProperty, binding);
                        status.TargetControl = this;
                    }
                }
            }
        }
Exemplo n.º 5
0
 public void SetPropertyStatusOnAll(PropertyStatus value)
 {
     CameraMakePropertyStatus          = value;
     CameraModelPropertyStatus         = value;
     DisplayNamePropertyStatus         = value;
     ExtensionPropertyStatus           = value;
     FileAttributesPropertyStatus      = value;
     FileDateCreatedPropertyStatus     = value;
     FileDateModifiedPropertyStatus    = value;
     FileDirectoryPropertyStatus       = value;
     FileMimeTypePropertyStatus        = value;
     FileSizePropertyStatus            = value;
     FileSmartDatePropertyStatus       = value;
     LocationCityPropertyStatus        = value;
     LocationCountryPropertyStatus     = value;
     LocationDateTimePropertyStatus    = value;
     LocationNamePropertyStatus        = value;
     LocationRegionStatePropertyStatus = value;
     LocationTimeZonePropertyStatus    = value;
     MediaAlbumPropertyStatus          = value;
     MediaAuthorPropertyStatus         = value;
     MediaCommentPropertyStatus        = value;
     MediaDateTakenPropertyStatus      = value;
     MediaDescriptionPropertyStatus    = value;
     MediaDimensionsPropertyStatus     = value;
     MediaRatingPropertyStatus         = value;
     MediaTitlePropertyStatus          = value;
 }
 private void SaveProperty(PropertyStatus status) {
   FillPropertyData();
   property.Status = status;
   property.Save();
   FillPropertyEventData();
   propertyEvent.Status = (PropertyEventStatus) (char) status;
   propertyEvent.Save();
 }
Exemplo n.º 7
0
        //public void Rent(Guid propertyId, Guid userId)
        //{
        //    _propertiesRepository.RentProperty(propertyId, userId);

        //    _eventBus.Publish();
        //}

        public bool ChangePropertyRentStatus(Guid propertyId, Guid userId, PropertyStatus status)
        {
            var result = _propertiesRepository.ChangePropertyRentStatus(propertyId, userId, status);

            _eventBus.Publish(CreateEvent(userId, propertyId, status));

            return(result == 1);
        }
        public void SetStatus(int propertyId, PropertyStatus status)
        {
            // TODO: this needs to be license aware
            VProperty dataModel = new VProperty {
                PropertyId = propertyId, Status = status
            };

            Update(dataModel, x => x.Status);
        }
 public CachedListUpdate(IList cachedList, IList originalList, object obj, string propertyName, PropertyStatus propertyStatus, RefreshBehaviorType refreshBehavior)
 {
     this.cachedList = cachedList;
     this.originalList = originalList;
     this.obj = obj;
     this.propertyName = propertyName;
     this.propertyStatus = propertyStatus;
     this.refreshBehavior = refreshBehavior;
 }
Exemplo n.º 10
0
 public void SetStatus(int propertyId, PropertyStatus status)
 {
     using (DatabaseContext context = CreateDatabaseContext())
     {
         PropertyRepository propertyRepository = new PropertyRepository(context);
         propertyRepository.SetStatus(propertyId, status);
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public PropertyDTO(Property prop)
        {
            Id         = prop.PropertyId;
            LandlordId = prop.LandlordId;

            Housenumber   = prop.Housenumber;
            Street        = prop.Street;
            Town          = prop.Town;
            PostCode      = prop.PostCode;
            AvailableFrom = prop.AvailableFrom;
            Status        = (PropertyStatus)Enum.Parse(typeof(PropertyStatus), prop.Status);
        }
Exemplo n.º 12
0
        public PropertyDTO(PropertyDTO copy)
        {
            Id         = copy.Id;
            LandlordId = copy.LandlordId;

            Housenumber   = copy.Housenumber;
            Street        = copy.Street;
            Town          = copy.Town;
            PostCode      = copy.PostCode;
            AvailableFrom = copy.AvailableFrom;
            Status        = copy.Status;
        }
Exemplo n.º 13
0
 public int ChangePropertyRentStatus(Guid propertyId, Guid userId, PropertyStatus propertyStatus)
 {
     // todo: based on the bussiness conditions, this could throw if the user does not own the property
     // should we catch this???
     // maybe should catch the SQL exception with code 10000001 only ???
     return(ExecuteQuery("sp_ChangePropertyRentStatus",
                         new[] {
         new SqlParameter("@propertyId", propertyId),
         new SqlParameter("@userId", userId),
         new SqlParameter("@status", (int)propertyStatus)
     }));
 }
Exemplo n.º 14
0
 public PropertyStatus BuyRailroad(RailroadObj railroadObj, PropertyStatus propertySt)
 {
     if (Player.Money >= railroadObj.price)
     {
         propertySt.isBuyed = true;
         propertySt.owner   = Player.ID;
         Player.railroads.Add(railroadObj);
         Player.propertiesStat.Add(propertySt);
         Player.Money -= railroadObj.price;
         Debug.Log("player " + Player.ID + " buyed " + railroadObj.title + " for " + railroadObj.price + "| Now he got: " + Player.Money);
         return(propertySt);
     }
     return(propertySt);
 }
Exemplo n.º 15
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <Contact>().OwnsOne(c => c.Address);
            modelBuilder.Entity <Property>().OwnsOne(p => p.Address);
            modelBuilder.Entity <SystemUser>().OwnsOne(u => u.Address);
            modelBuilder.Entity <Team>().OwnsOne(t => t.Address);
            modelBuilder.Entity <Organisation>().OwnsOne(o => o.Address);

            modelBuilder.Entity <Property>().Property(p => p.Status).HasConversion(
                p => p.Value,
                p => PropertyStatus.FromValue(p));
        }
Exemplo n.º 16
0
 public PropertyStatus BuyProperty(CardObject cardObj, PropertyStatus propertySt)
 {
     if (Player.Money >= cardObj.price)
     {
         propertySt.isBuyed = true;
         propertySt.owner   = Player.ID;
         Player.properties.Add(cardObj);
         Player.propertiesStat.Add(propertySt);
         Player.Money -= cardObj.price;
         Debug.Log("player " + Player.ID + " buyed " + cardObj.titleDeed + " for " + cardObj.price + "| Now he got: " + Player.Money);
         return(propertySt);
     }
     return(propertySt);
 }
Exemplo n.º 17
0
 public bool ChangeStatus(PropertyStatus status)
 {
     try
     {
         RealEntities db   = new RealEntities();
         property     prop = db.properties.Where(p => p.property_id == PropertyId).FirstOrDefault();
         prop.status = ( int )status;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Exemplo n.º 18
0
        public void ValidateObject(object obj, IList exceptions)
        {
            IObjectManager om       = this.Context.ObjectManager;
            IClassMap      classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());

            ValidationMode objValidationMode = GetValidationMode(classMap);

            if (objValidationMode != ValidationMode.Off)
            {
                CustomValidateObject(obj, classMap, exceptions);
                ObjectStatus objStatus = om.GetObjectStatus(obj);
                foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
                {
                    ValidationMode validationMode = GetValidationMode(classMap, propertyMap);

                    if (validationMode != ValidationMode.Off)
                    {
                        PropertyStatus propStatus = om.GetPropertyStatus(obj, propertyMap.Name);

                        if (validationMode == ValidationMode.ValidateAll && objStatus != ObjectStatus.UpForCreation)
                        {
                            this.Context.ObjectManager.EnsurePropertyIsLoaded(obj, propertyMap);
                        }

                        if (objStatus == ObjectStatus.UpForCreation || propStatus != PropertyStatus.NotLoaded)
                        {
                            bool ok = false;
                            if (validationMode == ValidationMode.Default || validationMode == ValidationMode.ValidateLoaded || validationMode == ValidationMode.ValidateAll)
                            {
                                ok = true;
                            }
                            else if (validationMode == ValidationMode.ValidateDirty)
                            {
                                if (propStatus == PropertyStatus.Dirty)
                                {
                                    ok = true;
                                }
                            }

                            if (ok)
                            {
                                DoValidateProperty(obj, propertyMap, exceptions);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
        private static PropertyEvent CreateEvent(Guid userId, Guid propertyId, PropertyStatus status)
        {
            var statusCode = (int)status;

            if (statusCode == 2)
            {
                return(new PropertyRented(userId, propertyId));
            }

            if (statusCode == 1)
            {
                return(new PropertyOfferedForRent(userId, propertyId));
            }

            throw new ApplicationException(string.Format(@"Status '{0}' is not mapped to any event.", status));
        }
Exemplo n.º 20
0
        private bool HasCount(ref int count)
        {
            IContext context = interceptable.GetInterceptor().Context;

            PropertyStatus propStatus = context.ObjectManager.GetPropertyStatus(interceptable, propertyName);

            if (propStatus != PropertyStatus.NotLoaded)
            {
                return(false);
            }

            IInverseHelper inverseHelper = interceptable as IInverseHelper;

            if (inverseHelper == null)
            {
                return(false);
            }

            ITransaction tx = null;

            ConsistencyMode readConsistency = context.ReadConsistency;

            if (readConsistency == ConsistencyMode.Pessimistic)
            {
                IClassMap  classMap  = context.DomainMap.MustGetClassMap(interceptable.GetType());
                ISourceMap sourceMap = classMap.GetSourceMap();
                if (sourceMap != null)
                {
                    if (sourceMap.PersistenceType.Equals(PersistenceType.ObjectRelational) || sourceMap.PersistenceType.Equals(PersistenceType.Default))
                    {
                        tx = context.GetTransaction(context.GetDataSource(sourceMap).GetConnection());
                        if (tx == null)
                        {
                            return(false);
                        }
                    }
                }
            }

            if (inverseHelper.HasCount(propertyName, tx))
            {
                count = inverseHelper.GetCount(propertyName, tx);
                return(true);
            }

            return(false);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 集合內特性狀態變更動作
        /// </summary>
        private void ItemStatusChanged(object sender, PropertyStatus oldValue, PropertyStatus newValue)
        {
            PropertyBase item = sender as PropertyBase;

            if (item.Affix == RunningBox.SpecialStatus.None)
            {
                return;
            }
            if (item.Status == PropertyStatus.Enabled)
            {
                _Affix |= item.Affix;
            }
            else
            {
                _AffixChanged = true;
            }
        }
Exemplo n.º 22
0
        public void ValidateObject(object obj, IList exceptions)
        {
            IObjectManager om       = this.Context.ObjectManager;
            IClassMap      classMap = this.Context.DomainMap.MustGetClassMap(obj.GetType());

            CustomValidateObject(obj, classMap, exceptions);
            ObjectStatus objStatus = om.GetObjectStatus(obj);

            foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
            {
                PropertyStatus propStatus = om.GetPropertyStatus(obj, propertyMap.Name);
                if (objStatus == ObjectStatus.UpForCreation || propStatus != PropertyStatus.NotLoaded)
                {
                    DoValidateProperty(obj, propertyMap, exceptions);
                }
            }
        }
Exemplo n.º 23
0
        private static IEnumerable <PropertyInfo> GetProperties(T start, T end, PropertyStatus status)
        {
            var @default = new T();

            foreach (var info in typeof(T).GetProperties())
            {
                var priValue     = info.GetGetMethod().Invoke(end, null);
                var baseValue    = info.GetGetMethod().Invoke(start, null);
                var defaultValue = info.GetGetMethod().Invoke(@default, null);

                var propertyChanged = !Equals(priValue, baseValue) &&
                                      !Equals(priValue, defaultValue);
                if (status == PropertyStatus.Changed && propertyChanged)
                {
                    yield return(info);
                }
                else if (status == PropertyStatus.Unchanged && !propertyChanged)
                {
                    yield return(info);
                }
            }
        }
Exemplo n.º 24
0
		private void MergePrimitiveProperty(IObjectManager om, object obj, IClassMap classMap, IPropertyMap propertyMap, object existing, bool forOrgValue, PropertyStatus propStatus, PropertyStatus extPropStatus, MergeBehaviorType mergeBehavior)
		{
			if (forOrgValue)
			{
				object value = om.GetPropertyValue(obj, propertyMap.Name);
				object extValue = om.GetPropertyValue(existing, propertyMap.Name);
				MergePrimitivePropertyValues(value, extValue, propStatus, extPropStatus, om, existing, classMap, propertyMap, obj, forOrgValue, mergeBehavior);
			}
			else
			{
				object orgValue = om.GetOriginalPropertyValue(obj, propertyMap.Name);
				object extOrgValue = om.GetOriginalPropertyValue(existing, propertyMap.Name);
				MergePrimitivePropertyValues(orgValue, extOrgValue, propStatus, extPropStatus, om, existing, classMap, propertyMap, obj, forOrgValue, mergeBehavior);
			}
		}
Exemplo n.º 25
0
		private void SetSingleRefPropetyValue(bool forOrgValue, IObjectManager om, object existing, IPropertyMap propertyMap, object value, PropertyStatus propStatus)
		{
			IUnitOfWork uow = this.Context.UnitOfWork;
			if (forOrgValue)
				om.SetOriginalPropertyValue(existing, propertyMap.Name, value);
			else
			{
				om.SetPropertyValue(existing, propertyMap.Name, value);
				if (value == null)
					om.SetNullValueStatus(existing, propertyMap.Name, true);
				else
					om.SetNullValueStatus(existing, propertyMap.Name, false);

				if (propStatus == PropertyStatus.Dirty)
				{
					uow.RegisterDirty(existing);					
					om.SetUpdatedStatus(existing, propertyMap.Name, true);						
				}
			}
		}
Exemplo n.º 26
0
		private void MergeSingleRefProperty(IObjectManager om, object obj, IClassMap classMap, IPropertyMap propertyMap, object existing, bool forOrgValue, PropertyStatus propStatus, PropertyStatus extPropStatus, MergeBehaviorType mergeBehavior)
		{
			string extOrgObjId;
			string refObjId;
			object extRefObj;
			object refObj;
			object extOrgObj;
			if (forOrgValue)
			{
				refObj = om.GetOriginalPropertyValue(obj, propertyMap.Name);
				extOrgObj = om.GetOriginalPropertyValue(existing, propertyMap.Name);				
			}
			else
			{
				refObj = om.GetPropertyValue(obj, propertyMap.Name);
				extOrgObj = om.GetPropertyValue(existing, propertyMap.Name);			
			}	
			if (refObj != null && DBNull.Value.Equals(refObj) != true)
			{
				refObjId = om.GetObjectIdentity(refObj);
				extOrgObjId = "";
				if (extOrgObj != null)
					extOrgObjId = om.GetObjectIdentity(extOrgObj);

				if (!refObjId.Equals(extOrgObjId))
				{
					bool keepExisting = KeepExistingValue(refObj, extOrgObj, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
					if (keepExisting != true)
					{
						extRefObj = this.Context.GetObjectById(refObjId, refObj.GetType());

						SetSingleRefPropetyValue(forOrgValue, om, existing, propertyMap, extRefObj, propStatus);
					}
				}
			}
			else
			{
				if (extOrgObj != null)
				{
					bool keepExisting = KeepExistingValue(refObj, extOrgObj, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
					if (keepExisting)
					{
						SetSingleRefPropetyValue(forOrgValue, om, existing, propertyMap, null, propStatus);
					}
				}
			}
		}
 public void SetStatus(int propertyId, PropertyStatus status)
 {
     _propertyDataProvider.SetStatus(propertyId, status);
 }
Exemplo n.º 28
0
        private void NullifyInverseReference(IPropertyMap propertyMap, object obj, IPropertyMap invPropertyMap, IObjectManager om)
        {
            bool stackMute = false;
            IInterceptableList mList;
            IList  refList;
            IList  list;
            object thisObj;
            object refObj;

            //Ensure that the property is loaded
            if (this.Context.GetPropertyStatus(obj, propertyMap.Name) == PropertyStatus.NotLoaded)
            {
                this.Context.LoadProperty(obj, propertyMap.Name);
            }

            if (propertyMap.IsCollection)
            {
                list = (IList)om.GetPropertyValue(obj, propertyMap.Name);
                if (list == null)
                {
                    list = this.Context.ListManager.CreateList(obj, propertyMap);
                }
                if (list != null)
                {
                    if (invPropertyMap.IsCollection)
                    {
                        foreach (object itemRefObj in list)
                        {
                            //Ensure inverse is loaded
                            PropertyStatus invPropertyStatus = this.Context.GetPropertyStatus(itemRefObj, invPropertyMap.Name);
                            if (invPropertyStatus == PropertyStatus.NotLoaded)
                            {
                                this.Context.LoadProperty(itemRefObj, invPropertyMap.Name);
                            }

                            refList = ((IList)(om.GetPropertyValue(itemRefObj, invPropertyMap.Name)));
                            if (refList.Contains(obj))
                            {
                                mList = refList as IInterceptableList;
                                if (mList != null)
                                {
                                    stackMute        = mList.MuteNotify;
                                    mList.MuteNotify = true;
                                }
                                refList.Remove(obj);
                                if (mList != null)
                                {
                                    mList.MuteNotify = stackMute;
                                }
                                om.SetUpdatedStatus(itemRefObj, invPropertyMap.Name, true);
                            }
                        }
                    }
                    else
                    {
                        foreach (object itemRefObj in list)
                        {
                            //Ensure inverse is loaded
                            PropertyStatus invPropertyStatus = this.Context.GetPropertyStatus(itemRefObj, invPropertyMap.Name);
                            if (invPropertyStatus == PropertyStatus.NotLoaded)
                            {
                                this.Context.LoadProperty(itemRefObj, invPropertyMap.Name);
                            }

                            thisObj = om.GetPropertyValue(itemRefObj, invPropertyMap.Name);
                            if (thisObj != null)
                            {
                                if (thisObj == obj)
                                {
                                    om.SetPropertyValue(itemRefObj, invPropertyMap.Name, null);
                                    om.SetUpdatedStatus(itemRefObj, invPropertyMap.Name, true);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                refObj = om.GetPropertyValue(obj, propertyMap.Name);
                if (refObj != null)
                {
                    PropertyStatus invPropertyStatus = this.Context.GetPropertyStatus(refObj, invPropertyMap.Name);
                    //Ensure inverse is loaded
                    if (invPropertyStatus == PropertyStatus.NotLoaded)
                    {
                        this.Context.LoadProperty(refObj, invPropertyMap.Name);
                    }
                    if (invPropertyMap.IsCollection)
                    {
                        refList = ((IList)(om.GetPropertyValue(refObj, invPropertyMap.Name)));
                        if (refList.Contains(obj))
                        {
                            mList = refList as IInterceptableList;
                            if (mList != null)
                            {
                                stackMute        = mList.MuteNotify;
                                mList.MuteNotify = true;
                            }
                            refList.Remove(obj);
                            if (mList != null)
                            {
                                mList.MuteNotify = stackMute;
                            }
                            om.SetUpdatedStatus(refObj, invPropertyMap.Name, true);
                        }
                    }
                    else
                    {
                        //only update back ref if it is actually pointing at me
                        thisObj = om.GetPropertyValue(refObj, invPropertyMap.Name);
                        if (thisObj != null)
                        {
                            if (thisObj == obj)
                            {
                                om.SetPropertyValue(refObj, invPropertyMap.Name, null);
                                om.SetUpdatedStatus(refObj, invPropertyMap.Name, true);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 29
0
		private void MergeListRefProperty(IObjectManager om, object obj, IClassMap classMap, IPropertyMap propertyMap, object existing, PropertyStatus propStatus, PropertyStatus extPropStatus, bool forOrgValue, MergeBehaviorType mergeBehavior)
		{
			IList list = ((IList) om.GetPropertyValue(obj, propertyMap.Name));
			IList orgList = ((IList) om.GetPropertyValue(existing, propertyMap.Name));
			MergeReferenceLists(list, orgList, om, obj, mergeBehavior, classMap, propertyMap, existing, propStatus, extPropStatus, forOrgValue);

		}
        private void RefreshProperty(IObjectManager om, object targetObject, IPropertyMap propertyMap, IPersistenceManager pm, RefreshBehaviorType refreshBehavior, object value, out bool doWrite, out bool doWriteOrg)
        {
            doWrite    = false;
            doWriteOrg = false;
            PropertyStatus propStatus = om.GetPropertyStatus(targetObject, propertyMap.Name);
            IClassMap      classMap   = this.Context.DomainMap.MustGetClassMap(targetObject.GetType());

            RefreshBehaviorType useRefreshBehavior = pm.GetRefreshBehavior(refreshBehavior, classMap, propertyMap);

            if (useRefreshBehavior == RefreshBehaviorType.OverwriteNotLoaded || useRefreshBehavior == RefreshBehaviorType.DefaultBehavior)
            {
                //Overwrite both value and original far all unloaded properties
                if (propStatus == PropertyStatus.NotLoaded)
                {
                    doWrite    = true;
                    doWriteOrg = true;
                }
            }
            else if (useRefreshBehavior == RefreshBehaviorType.OverwriteLoaded)
            {
                //Overwrite original for all properties
                //Overwrite value for all clean or unloaded properties (but not for dirty or deleted properties)
                doWriteOrg = true;
                if (propStatus == PropertyStatus.Clean || propStatus == PropertyStatus.NotLoaded)
                {
                    doWrite = true;
                }
            }
            else if (useRefreshBehavior == RefreshBehaviorType.ThrowConcurrencyException)
            {
                //Overwrite original for all properties unless the old originial value and the fresh value from the
                //database mismatch, in that case raise an exception
                //Overwrite value for all clean or unloaded properties (but not for dirty or deleted properties)
                if (propStatus == PropertyStatus.Clean || propStatus == PropertyStatus.NotLoaded || propStatus == PropertyStatus.Dirty)
                {
                    if (!(propStatus == PropertyStatus.NotLoaded))
                    {
                        object testValue  = om.GetOriginalPropertyValue(targetObject, propertyMap.Name);
                        object testValue2 = value;
                        if (DBNull.Value.Equals(testValue))
                        {
                            testValue = null;
                        }
                        if (DBNull.Value.Equals(testValue2))
                        {
                            testValue2 = null;
                        }
                        if (testValue2 != testValue)
                        {
                            string cachedValue = "null";
                            string freshValue  = "null";
                            try
                            {
                                if (testValue != null)
                                {
                                    cachedValue = testValue.ToString();
                                }
                            }
                            catch {; }
                            try
                            {
                                if (value != null)
                                {
                                    freshValue = value.ToString();
                                }
                            }
                            catch {; }
                            throw new RefreshException("A refresh concurrency exception occurred when refreshing a cached object of type " + targetObject.GetType().ToString() + " with fresh data from the data source. The data source row has been modified since the last time this version of the object was loaded, specifically the value for property " + propertyMap.Name + ". (this exception occurs because ThrowConcurrencyExceptions refresh behavior was selected). Cashed value: " + cachedValue + ", Fresh value: " + freshValue, cachedValue, freshValue, targetObject, propertyMap.Name);                             // do not localize
                        }
                    }
                    if (!(propStatus == PropertyStatus.Dirty))
                    {
                        doWrite = true;
                    }
                }
            }
            else if (useRefreshBehavior == RefreshBehaviorType.OverwriteDirty)
            {
                //Overwrite original for all properties
                //Overwrite value for all clean, unloaded or dirty properties (but not for deleted properties)
                doWriteOrg = true;
                if (!(propStatus == PropertyStatus.Deleted))
                {
                    doWrite = true;
                }
            }
            else
            {
                throw new NPersistException("Unknown object refresh behavior specified!");                 // do not localize
            }
        }
Exemplo n.º 31
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            Debug.Log("Player [" + playerScripts[i].Player.ID + "]: " + playerScripts[i].Player.Money + "$");
        }

        if (canBeReset && !playerControls[i].GetIsMoving() && !cardActive && cardEndTurn)
        {
            PropertyStatus property = propertiesStat.Find(x => x.id == playerControls[i].GetRoutePos());
            cardEndTurn = false;
            CheckCard(playerControls[i].GetRoutePos());
            if (property.owner != 0)
            {
                PlayerRent(playerControls[i].GetRoutePos());
            }
        }
        if ((Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.C) || Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Space)) && canBeReset && !playerControls[i].GetIsMoving())
        {
            if (Input.GetKeyDown(KeyCode.Q))
            {
                PropertyStatus property = propertiesStat.Find(x => x.id == playerControls[i].GetRoutePos());

                if (property.isBuyed == false)
                {
                    if (idsOfProp.Contains(playerControls[i].GetRoutePos()))
                    {
                        CardObject cardObject = JsonUtility.FromJson <CardObject>(Load(playerControls[i].GetRoutePos()));
                        property = playerScripts[i].BuyProperty(cardObject, property);
                    }
                    else if (idsOfRr.Contains(playerControls[i].GetRoutePos()))
                    {
                        RailroadObj rrObject = JsonUtility.FromJson <RailroadObj>(Load(playerControls[i].GetRoutePos()));
                        property = playerScripts[i].BuyRailroad(rrObject, property);
                    }
                }

                Debug.Log(property.id + " owner: " + property.owner);
            }
            else if (Input.GetKeyDown(KeyCode.C))
            {
                if (GameObject.Find("Canvas").transform.GetChild(1).gameObject.activeSelf == true || GameObject.Find("Canvas").transform.GetChild(3).gameObject.activeSelf == true)
                {
                    ChangeCard(playerControls[i].GetRoutePos(), 2);
                }
                else if (GameObject.Find("Canvas").transform.GetChild(2).gameObject.activeSelf == true || GameObject.Find("Canvas").transform.GetChild(4).gameObject.activeSelf == true)
                {
                    ChangeCard(playerControls[i].GetRoutePos(), 1);
                }
            }
            else if (Input.GetKeyDown(KeyCode.X))
            {
                CheckCard(playerControls[i].GetRoutePos());
            }
            else
            {
                if (cardActive)
                {
                    CheckCard(playerControls[i].GetRoutePos());
                }
                foreach (var dice in dices)
                {
                    dice.Reset();
                }
                canBeReset = false;
                Debug.Log("Dices has been Started/Reseted!");

                i++;
                if (i > countOfPlayers - 1)
                {
                    i = 0;
                }
                cardEndTurn = true;
            }
        }
        CheckTurn();
    }
        private void MergeSingleRefProperty(IObjectManager om, object obj, IClassMap classMap, IPropertyMap propertyMap, object existing, bool forOrgValue, PropertyStatus propStatus, PropertyStatus extPropStatus, MergeBehaviorType mergeBehavior)
        {
            string extOrgObjId;
            string refObjId;
            object extRefObj;
            object refObj;
            object extOrgObj;
            if (forOrgValue)
            {
                refObj = om.GetOriginalPropertyValue(obj, propertyMap.Name);
                extOrgObj = om.GetOriginalPropertyValue(existing, propertyMap.Name);
            }
            else
            {
                refObj = om.GetPropertyValue(obj, propertyMap.Name);
                extOrgObj = om.GetPropertyValue(existing, propertyMap.Name);
            }
            if (refObj != null && DBNull.Value.Equals(refObj) != true)
            {
                //hmmmm won't this fail if we have two objects of different classes but with the same id?
                //probably the type should be included (and preferably change to KeyStruct comparisons...)
                refObjId = om.GetObjectIdentity(refObj);
                extOrgObjId = "";
                if (extOrgObj != null)
                    extOrgObjId = om.GetObjectIdentity(extOrgObj);

                if (!refObjId.Equals(extOrgObjId))
                {
                    bool keepExisting = KeepExistingValue(refObj, extOrgObj, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
                    if (keepExisting != true)
                    {
                        extRefObj = this.Context.GetObjectById(refObjId, refObj.GetType());

                        SetSingleRefPropetyValue(forOrgValue, om, existing, propertyMap, extRefObj, propStatus);
                    }
                }
            }
            else
            {
                if (extOrgObj != null)
                {
                    bool keepExisting = KeepExistingValue(refObj, extOrgObj, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
                    if (keepExisting)
                    {
                        SetSingleRefPropetyValue(forOrgValue, om, existing, propertyMap, null, propStatus);
                    }
                }
            }
        }
Exemplo n.º 33
0
        public virtual void NotifyPropertyGet(object obj, string propertyName, ref object value, ref bool cancel)
        {
            if (this.isDisposed)
            {
                return;
            }
            if (notification == Notification.Disabled)
            {
                return;
            }
            ObjectStatus            objStatus = this.Context.ObjectManager.GetObjectStatus(obj);
            IPropertyMap            propertyMap;
            PropertyStatus          propStatus        = PropertyStatus.Clean;
            bool                    hasPropertyStatus = false;
            PropertyCancelEventArgs e = new PropertyCancelEventArgs(obj, propertyName, null, value, this.Context.ObjectManager.GetNullValueStatus(obj, propertyName));

            this.Context.EventManager.OnReadingProperty(this, e);
            if (e.Cancel)
            {
                cancel = true;
                return;
            }
            value = e.value;

            bool didLoadObject = false;

            if (objStatus == ObjectStatus.Deleted)
            {
                throw new DeletedObjectException("The object has been deleted!", obj, propertyName);                 // do not localize
            }
            else if (objStatus == ObjectStatus.UpForDeletion)
            {
                throw new DeletedObjectException("The object has been registered as up for deletion!", obj, propertyName);                 // do not localize
            }
            else if (objStatus == ObjectStatus.NotLoaded)
            {
                propertyMap = this.Context.DomainMap.MustGetClassMap(obj.GetType()).MustGetPropertyMap(propertyName);
                if (!(propertyMap.IsIdentity))
                {
                    propStatus        = this.Context.ObjectManager.GetPropertyStatus(obj, propertyName);
                    hasPropertyStatus = true;
                    //it would be sweet to be able to determine beforehand if this property would be part of the span
                    //that is loaded with LoadObject and only call LoadObject if that is the case....
                    if (propStatus == PropertyStatus.NotLoaded)
                    {
                        hasPropertyStatus = false;
                        //this.Context.PersistenceEngine.LoadObject(ref obj);
                        this.Context.IdentityMap.LoadObject(ref obj, true);
                        if (obj == null)
                        {
                            throw new ObjectNotFoundException("Object not found!");                             // do not localize
                        }
                        didLoadObject = true;
                    }
                }
            }
            if (!hasPropertyStatus)
            {
                propStatus = this.Context.ObjectManager.GetPropertyStatus(obj, propertyName);
            }

            if (propStatus == PropertyStatus.Clean)
            {
                if (didLoadObject)
                {
                    value = this.Context.ObjectManager.GetPropertyValue(obj, propertyName);
                }
            }
            if (propStatus == PropertyStatus.Deleted)
            {
                if (obj is IObjectHelper)
                {
                    throw new DeletedObjectException("The object has been deleted!", obj, propertyName);                     // do not localize
                }
            }
            else if (propStatus == PropertyStatus.NotLoaded)
            {
                if (!(objStatus == ObjectStatus.UpForCreation))
                {
                    this.Context.PersistenceEngine.LoadProperty(obj, propertyName);
                    value = this.Context.ObjectManager.GetPropertyValue(obj, propertyName);
                }
            }
            this.Context.InverseManager.NotifyPropertyGet(obj, propertyName);
        }
Exemplo n.º 34
0
        //[DebuggerStepThrough()]
        protected virtual void DoNotifyPropertySet(object obj, string propertyName, ref object value, object oldValue, bool hasOldValue, ref bool cancel)
        {
            IContext                ctx = this.Context;
            IObjectManager          om  = ctx.ObjectManager;
            IPersistenceEngine      pe  = ctx.PersistenceEngine;
            PropertyCancelEventArgs e;

            if (hasOldValue)
            {
                e = new PropertyCancelEventArgs(obj, propertyName, value, oldValue, this.Context.ObjectManager.GetNullValueStatus(obj, propertyName));
            }
            else
            {
                e = new PropertyCancelEventArgs(obj, propertyName, value, this.Context.ObjectManager.GetPropertyValue(obj, propertyName), this.Context.ObjectManager.GetNullValueStatus(obj, propertyName));
            }
            this.Context.EventManager.OnWritingProperty(this, e);
            if (e.Cancel)
            {
                cancel = true;
                return;
            }
            value = e.NewValue;
            IClassMap    classMap = ctx.DomainMap.MustGetClassMap(obj.GetType());
            IPropertyMap propertyMap;
            string       prevId;
            string       newId;

            propertyMap = classMap.MustGetPropertyMap(propertyName);

            if (propertyMap.ReferenceType != ReferenceType.None && value != null)
            {
                if (propertyMap.ReferenceType == ReferenceType.OneToMany || propertyMap.ReferenceType == ReferenceType.OneToOne)
                {
                    //parent object
                    IInterceptable ivalue = value as IInterceptable;
                    if (ivalue == null)
                    {
                        throw new NPersistException(string.Format("Object is not a NPersist managed object, do not use 'new' on Entities. (Property='{0}', Owner={1})", propertyName, obj));
                    }
                    else
                    {
                        if (ivalue.GetInterceptor().Context != this.Context)
                        {
                            throw new NPersistException(string.Format("Object does not belong to the same context object as the property owner. (Property='{0}', Owner={1})", propertyName, obj));
                        }
                        ObjectStatus valueObjectStatus = om.GetObjectStatus(value);
                        if (valueObjectStatus == ObjectStatus.UpForDeletion || valueObjectStatus == ObjectStatus.Deleted)
                        {
                            throw new DeletedObjectException(string.Format("Object has been deleted. (Object={0})", value), value);
                        }
                    }
                }
                else if (propertyMap.ReferenceType == ReferenceType.ManyToOne || propertyMap.ReferenceType == ReferenceType.ManyToMany)
                {
                    IInterceptableList ivalue = value as IInterceptableList;
                    if (ivalue == null)
                    {
                        throw new NPersistException(string.Format("List is not a NPersist managed list, do not use 'new' to initialize lists, NPersist does this for you. (Property='{0}', Owner={1})", propertyName, obj));
                    }
                    else if (ivalue.Interceptable.GetInterceptor().Context != this.Context)
                    {
                        throw new NPersistException(string.Format("List does not belong to the same context object as the property owner. (Property='{0}', Owner={1})", propertyName, obj));
                    }
                }
            }

            if (propertyMap.IsReadOnly)
            {
                //Let read-only inverse properties through
                if (!(propertyMap.ReferenceType != ReferenceType.None && propertyMap.Inverse.Length > 0 && propertyMap.NoInverseManagement == false))
                {
                    //Special - if someone forgot to make their ManyOne read-only,
                    //why bug them about it? (so don't add an "else" with an exception...)
                    if (propertyMap.ReferenceType != ReferenceType.ManyToOne)
                    {
                        throw new ReadOnlyException("Property '" + classMap.Name + "." + propertyName + "' is read-only!");                         // do not localize
                    }
                }
            }
            PropertyStatus propStatus        = PropertyStatus.Clean;
            ObjectStatus   objStatus         = om.GetObjectStatus(obj);
            bool           hasPropertyStatus = false;

            if (objStatus == ObjectStatus.Deleted)
            {
                throw new DeletedObjectException("The object has been deleted!", obj, propertyName);                 // do not localize
            }
            else if (objStatus == ObjectStatus.UpForDeletion)
            {
                throw new DeletedObjectException("The object has been registered as up for deletion!", obj, propertyName);                 // do not localize
            }

            this.Context.ObjectCloner.EnsureIsClonedIfEditing(obj);

            if (objStatus == ObjectStatus.UpForCreation)
            {
            }
            else if (objStatus == ObjectStatus.Clean)
            {
                propStatus = om.GetPropertyStatus(obj, propertyName);
                if (propStatus == PropertyStatus.NotLoaded)
                {
                    pe.LoadProperty(obj, propertyName);
                }
                if (!(hasOldValue))
                {
                    if (!(om.ComparePropertyValues(obj, propertyName, value, om.GetPropertyValue(obj, propertyName))))
                    {
                        this.Context.UnitOfWork.RegisterDirty(obj);
                    }
                }
            }
            else if (objStatus == ObjectStatus.NotLoaded)
            {
                propertyMap = this.Context.DomainMap.MustGetClassMap(obj.GetType()).MustGetPropertyMap(propertyName);
                if (!(propertyMap.IsIdentity))
                {
                    propStatus        = this.Context.ObjectManager.GetPropertyStatus(obj, propertyName);
                    hasPropertyStatus = true;
                    //it would be sweet to be able to determine beforehand if this property would be part of the span
                    //that is loaded with LoadObject and only call LoadObject if that is the case....
                    if (propStatus == PropertyStatus.NotLoaded)
                    {
                        hasPropertyStatus = false;
                        //this.Context.PersistenceEngine.LoadObject(ref obj);
                        this.Context.IdentityMap.LoadObject(ref obj, true);
                        if (obj == null)
                        {
                            throw new ObjectNotFoundException("Object not found!");                             // do not localize
                        }
                    }
                    if (!hasPropertyStatus)
                    {
                        propStatus = om.GetPropertyStatus(obj, propertyName);
                    }

                    if (propStatus == PropertyStatus.NotLoaded)
                    {
                        pe.LoadProperty(obj, propertyName);
                    }
                }

                if (!(hasOldValue))
                {
                    if (!(om.ComparePropertyValues(obj, propertyName, value, om.GetPropertyValue(obj, propertyName))))
                    {
                        this.Context.UnitOfWork.RegisterDirty(obj);
                    }
                }
            }
            else if (objStatus == ObjectStatus.Dirty)
            {
                propStatus = om.GetPropertyStatus(obj, propertyName);
                if (propStatus == PropertyStatus.NotLoaded)
                {
                    pe.LoadProperty(obj, propertyName);
                }
            }
            if (propertyMap.IsIdentity)
            {
                prevId = om.GetObjectIdentity(obj);
                newId  = om.GetObjectIdentity(obj, propertyMap, value);
                if (prevId != newId)
                {
                    ctx.IdentityMap.UpdateIdentity(obj, prevId, newId);
                }
            }
            om.SetNullValueStatus(obj, propertyName, false);
            om.SetUpdatedStatus(obj, propertyName, true);
            if (hasOldValue)
            {
                ctx.InverseManager.NotifyPropertySet(obj, propertyName, value, oldValue);
                ctx.UnitOfWork.RegisterDirty(obj);
            }
            else
            {
                ctx.InverseManager.NotifyPropertySet(obj, propertyName, value);
            }
        }
Exemplo n.º 35
0
 public Response()
 {
     Found = new PropertyStatus();
     NotFound = new PropertyStatus();
 }
Exemplo n.º 36
0
		private void MergePrimitivePropertyValues(object value, object extValue, PropertyStatus propStatus, PropertyStatus extPropStatus, IObjectManager om, object existing, IClassMap classMap, IPropertyMap propertyMap, object obj, bool forOrgValue, MergeBehaviorType mergeBehavior)
		{
			if (!value.Equals(extValue)) // May be to naive - possibly should use some advanced method like ComparePropertyValues..
			{
				bool keepExisting = KeepExistingValue(value, extValue, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
				if (!keepExisting)
				{
					if (forOrgValue)
					{
						om.SetPropertyValue(existing, propertyMap.Name, value);				
						om.SetNullValueStatus(existing, propertyMap.Name, om.GetNullValueStatus(obj, propertyMap.Name));
						if (propStatus == PropertyStatus.Dirty)
						{
							this.Context.UnitOfWork.RegisterDirty(existing);					
							om.SetUpdatedStatus(existing, propertyMap.Name, true);						
						}
					}
					else
					{
						om.SetOriginalPropertyValue(existing, propertyMap.Name, value);									
					}
				}
			}
		}
Exemplo n.º 37
0
		private bool KeepExistingValue(object value, object extValue, MergeBehaviorType mergeBehavior, IClassMap classMap, IPropertyMap propertyMap, object existing, object obj, PropertyStatus propStatus, PropertyStatus extPropStatus, bool forOrgValue)
		{
			bool keepExisting = false;
			MergeBehaviorType useMergeBehavior = GetMergeBehavior(mergeBehavior, classMap, propertyMap);
			if (useMergeBehavior == MergeBehaviorType.ThrowConcurrencyException) 
				throw new MergeException("Merge Conflict!", extValue, value, existing, obj, propertyMap.Name, forOrgValue);

			//First try: Dirty wins..
			if (propStatus == PropertyStatus.Dirty && extPropStatus == PropertyStatus.Dirty)
			{
				if (useMergeBehavior == MergeBehaviorType.DefaultBehavior)
					throw new BothDirtyMergeException("Unresovable Merge Conflict! Both values are dirty!", extValue, value, existing, obj, propertyMap.Name, forOrgValue);
				else if (useMergeBehavior == MergeBehaviorType.IgnoreConflictsUsingMergeValue)
					keepExisting = false;
				else if (useMergeBehavior == MergeBehaviorType.IgnoreConflictsUsingCashedValue)
					keepExisting = true;
				else
					throw new NPersistException("This should be unreachable code...if it is not, that means I made a mistake!" );					
			}
			else if (propStatus == PropertyStatus.Dirty)
				keepExisting = false;
			else if (extPropStatus == PropertyStatus.Dirty)
				keepExisting = true;
			else
			{
				//Second try: Clean wins
				if (propStatus == PropertyStatus.Clean && extPropStatus == PropertyStatus.Clean)
				{
					if (useMergeBehavior == MergeBehaviorType.DefaultBehavior)
						throw new BothCleanMergeException("Unresovable Merge Conflict! Both values are clean!", extValue, value, existing, obj, propertyMap.Name, forOrgValue);
					else if (useMergeBehavior == MergeBehaviorType.IgnoreConflictsUsingMergeValue)
						keepExisting = false;
					else if (useMergeBehavior == MergeBehaviorType.IgnoreConflictsUsingCashedValue)
						keepExisting = true;
					else
						throw new NPersistException("This should be unreachable code...if it is not, that means I made a mistake!" );						
				}
				else if (propStatus == PropertyStatus.Clean)
					keepExisting = false;
				else if (extPropStatus == PropertyStatus.Clean)
					keepExisting = true;
				else
				{
					if (extPropStatus == PropertyStatus.NotLoaded)
						keepExisting = false;
					if (extPropStatus == PropertyStatus.Deleted)
						keepExisting = true;
					else
						throw new NPersistException("This should be unreachable code...if it is not, that means I made a mistake!" );					
				}
			}
			return keepExisting;
		}
Exemplo n.º 38
0
        public void TestINotifyPropertyChangingAndChanged()
        {
            if (this.ToTest == null)
            {
                throw new ArgumentNullException("item");
            }
            Dictionary <string, PropertyStatus> properties = new Dictionary <string, PropertyStatus>();

            foreach (PropertyInfo property in this.ToTest.GetType().GetPublicProperties())
            {
                if (property.CanRead == false)
                {
                    continue;
                }
                if (property.CanWrite == false)
                {
                    continue;
                }
                if (properties.ContainsKey(property.Name) == false)
                {
                    properties.Add(property.Name, PropertyStatus.NotCalled);
                }
            }
            PropertyChangingEventHandler method1 = (o, e)
                                                   =>
            {
                if (properties.ContainsKey(e.PropertyName) == false)
                {
                    throw new InvalidOperationException("The property '" + e.PropertyName + "' was not found on object type '" + typeof(T).FullName + "'");
                }
                properties[e.PropertyName] |= PropertyStatus.Changing;
            };
            PropertyChangedEventHandler method2 = (o, e)
                                                  =>
            {
                if (properties.ContainsKey(e.PropertyName) == false)
                {
                    throw new InvalidOperationException("The property '" + e.PropertyName + "' was not found on object type '" + typeof(T).FullName + "'");
                }
                properties[e.PropertyName] |= PropertyStatus.Changed;
            };

            this.ToTest.PropertyChanging += method1;
            this.ToTest.PropertyChanged  += method2;
            this._ModifyProperties();
            this.ToTest.PropertyChanging -= method1;
            this.ToTest.PropertyChanged  -= method2;
            bool returnValue = properties.Values.All((p) =>
            {
                return((p & PropertyStatus.Changed) > 0 && (p & PropertyStatus.Changing) > 0);
            });

            if (returnValue == false)
            {
                List <string> failedProperties = new List <string>();
                foreach (string key in properties.Keys)
                {
                    PropertyStatus propertyStatus = properties[key];
                    if (
                        ((propertyStatus & PropertyStatus.Changed) == 0)
                        ||
                        ((propertyStatus & PropertyStatus.Changing) == 0)
                        )
                    {
                        failedProperties.Add(key);
                    }
                }
                Assert.Fail("{0} propert{1} ({2}) did not fire PropertyChanged or PropertyChanging.", failedProperties.Count, failedProperties.Count == 1 ? "y" : "ies", String.Join(", ", failedProperties));
            }
        }
Exemplo n.º 39
0
		private void MergeReferenceLists(IList list, IList orgList, IObjectManager om, object obj, MergeBehaviorType mergeBehavior, IClassMap classMap, IPropertyMap propertyMap, object existing, PropertyStatus propStatus, PropertyStatus extPropStatus, bool forOrgValue)
		{
			IList objectsToRemove = new ArrayList(); 
			IList objectsToAdd = new ArrayList();
			IUnitOfWork uow = this.Context.UnitOfWork;
			foreach (object itemOrgObj in orgList)
			{
				string itemOrgObjId = om.GetObjectIdentity(itemOrgObj);
				bool found = false;
				foreach (object itemObj in list)
				{
					string itemObjId = om.GetObjectIdentity(itemObj);
					if (itemObjId == itemOrgObjId)
					{
						found = true;
						break;
					}								
				}
				if (!found)
					objectsToRemove.Add(itemOrgObj);
			}
			foreach (object itemObj in list)
			{
				string itemObjId = om.GetObjectIdentity(itemObj);
				bool found = false;
				foreach (object itemOrgObj in orgList)
				{
					string itemOrgObjId = om.GetObjectIdentity(itemOrgObj);
					if (itemObjId == itemOrgObjId)
					{
						found = true;
						break;
					}								
				}
				if (!found)
				{
					object itemOrgObj = this.Context.GetObjectById(itemObjId, obj.GetType());
					objectsToAdd.Add(itemOrgObj);
				}
			}
	
			if (objectsToRemove.Count > 0 || objectsToAdd.Count > 0)
			{
				bool keepExisting = KeepExistingValue(list, orgList, mergeBehavior, classMap, propertyMap, existing, obj, propStatus, extPropStatus, forOrgValue);
				if (!keepExisting)
				{
					bool stackMute = false;
					IInterceptableList mList = orgList as IInterceptableList;					
					if (mList != null)
					{
						stackMute = mList.MuteNotify;
						mList.MuteNotify = true;
					}
					foreach (object itemOrgObj in objectsToRemove)
						orgList.Remove(itemOrgObj);
					foreach (object itemOrgObj in objectsToAdd)
						orgList.Add(itemOrgObj);	

					if (mList != null) { mList.MuteNotify = stackMute; }
					
					if (propStatus == PropertyStatus.Dirty)
					{
						uow.RegisterDirty(existing);					
						om.SetUpdatedStatus(existing, propertyMap.Name, true);						
					}
				}								
			}
		}
Exemplo n.º 40
0
 public CachedListUpdate(IList cachedList, IList originalList, object obj, string propertyName, PropertyStatus propertyStatus, RefreshBehaviorType refreshBehavior)
 {
     this.cachedList      = cachedList;
     this.originalList    = originalList;
     this.obj             = obj;
     this.propertyName    = propertyName;
     this.propertyStatus  = propertyStatus;
     this.refreshBehavior = refreshBehavior;
 }