Beispiel #1
0
        public Object ProcessServiceResult(Object result, IList <IObjRef> objRefs, IList <Object> entities, Type expectedType, Object[] serviceRequestArgs,
                                           Attribute annotation)
        {
            IPagingResponse pagingResponse = (IPagingResponse)result;

            QueryResultType queryResultType = QueryResultType.REFERENCES;

            if (annotation is FindAttribute)
            {
                queryResultType = ((FindAttribute)annotation).ResultType;
            }
            switch (queryResultType)
            {
            case QueryResultType.BOTH:
                pagingResponse.RefResult = objRefs;
                pagingResponse.Result    = entities;
                break;

            case QueryResultType.ENTITIES:
                pagingResponse.RefResult = null;
                pagingResponse.Result    = entities;
                break;

            case QueryResultType.REFERENCES:
                pagingResponse.RefResult = objRefs;
                pagingResponse.Result    = null;
                break;

            default:
                throw RuntimeExceptionUtil.CreateEnumNotSupportedException(queryResultType);
            }
            return(pagingResponse);
        }
Beispiel #2
0
        public virtual void IfZCmp(CompareOperator compareOperator, Label label)
        {
            switch (compareOperator)
            {
            case CompareOperator.EQ:
                gen.Emit(OpCodes.Brfalse, label);
                break;

            case CompareOperator.NE:
                gen.Emit(OpCodes.Brtrue, label);
                break;

            default:
                throw RuntimeExceptionUtil.CreateEnumNotSupportedException(compareOperator);
            }
        }
Beispiel #3
0
        public virtual void IfCmp(Type type, CompareOperator compareOperator, Label label)
        {
            switch (compareOperator)
            {
            case CompareOperator.EQ:
                gen.Emit(OpCodes.Beq, label);
                break;

            case CompareOperator.NE:
                gen.Emit(OpCodes.Bne_Un, label);
                break;

            default:
                throw RuntimeExceptionUtil.CreateEnumNotSupportedException(compareOperator);
            }
        }
Beispiel #4
0
        public void HandleCollectionChange(INotifyPropertyChangedSource obj, Object sender, NotifyCollectionChangedEventArgs evnt)
        {
            IEntityMetaData metaData = ((IEntityMetaDataHolder)obj).Get__EntityMetaData();

            Object bases = null;
            bool   parentChildProperty = false;

            RelationMember[] relationMembers = metaData.RelationMembers;
            for (int relationIndex = relationMembers.Length; relationIndex-- > 0;)
            {
                Object valueDirect = ((IValueHolderContainer)obj).Get__ValueDirect(relationIndex);
                if (!Object.ReferenceEquals(valueDirect, sender))
                {
                    continue;
                }
                if (relationMembers[relationIndex].GetAnnotation(typeof(ParentChild)) != null)
                {
                    bases = obj;
                    parentChildProperty = true;
                }
                else
                {
                    bases = sender;
                }
                break;
            }
            if (bases == null)
            {
                foreach (PrimitiveMember primitiveMember in metaData.PrimitiveMembers)
                {
                    Object valueDirect = primitiveMember.GetValue(obj);
                    if (!Object.ReferenceEquals(valueDirect, sender))
                    {
                        continue;
                    }
                    bases = obj;
                    parentChildProperty = true;
                    break;
                }
            }
            if (bases == null)
            {
                throw new Exception("Must never happen");
            }
            ICacheModification cacheModification = this.CacheModification;
            bool oldCacheModification            = cacheModification.Active;
            bool cacheModificationUsed           = false;

            try
            {
                switch (evnt.Action)
                {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                    if (evnt.OldItems != null)
                    {
                        foreach (Object oldItem in evnt.OldItems)
                        {
                            HandleRemovedItem(obj, oldItem, parentChildProperty);
                        }
                    }
                    if (evnt.NewItems != null)
                    {
                        foreach (Object newItem in evnt.NewItems)
                        {
                            HandleAddedItem(obj, newItem, parentChildProperty);
                        }
                    }
                    break;

#if !SILVERLIGHT
                case NotifyCollectionChangedAction.Move:
                    // Nothing to do in that case
                    break;
#endif
                case NotifyCollectionChangedAction.Reset:
                    throw new NotSupportedException("Reset is not allowed in a managed collection");

                default:
                    throw RuntimeExceptionUtil.CreateEnumNotSupportedException(evnt.Action);
                }
                IList <ICollectionChangeExtension> extensions = collectionChangeExtensions.GetExtensions(obj.GetType());
                for (int a = 0, size = extensions.Count; a < size; a++)
                {
                    extensions[a].CollectionChanged(obj, evnt);
                }
            }
            finally
            {
                if (!oldCacheModification)
                {
                    SetToBeUpdated(obj, true);
                }
                if (cacheModificationUsed)
                {
                    cacheModification.Active = oldCacheModification;
                }
            }
        }