public void AddSurrogateReference(IStateObjectSurrogate surrogate, IStateObject reference)
 {
     lock (surrogate)
     {
         ((StateObjectSurrogate)surrogate).AddReference(new LazyStateObjectReference(_stateManager, reference));
     }
 }
Beispiel #2
0
        public bool RemoveOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item)
        {
            bool removed = false;

            if (typeof(IStateObject).IsAssignableFrom(item.GetType()))
            {
                removed = ProcessDeletionForMostCases(services, ctx, item);
            }
            else if (item.GetType().IsValueType || item.GetType() == typeof(String))
            {
                removed = ProcessDeletionForValueType(services, ctx, item);
            }
            else if (services.SurrogateManager.IsSurrogateRegistered(item.GetType()))
            {
                IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);
                if (baptizedItem != null)
                {
                    removed = ProcessDeletionForMostCases(services, ctx, baptizedItem);
                }
                else
                {
                    throw new Exception();
                }
            }
            else
            {
                throw new NotSupportedException();
            }
            return(removed);
        }
        public bool RemoveOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item)
        {
            //The item is a pure object, which is not yet be encapsulated into a StateObjectSurrogate
            //We are going to baptize the item
            IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);

            return(ProcessDeletionForMostCases(services, ctx, baptizedItem));
        }
        public void SetterOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, int index, object value)
        {
            IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(value, true);

            if (baptizedItem != null)
            {
                this.ProcessIndexSetterForMostCases(services, ctx, index, baptizedItem);
            }
        }
        public void InsertOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item, int index, object parent)
        {
            //The item is a pure object, which is not yet be encapsulated into a StateObjectSurrogate
            //We are going to baptize the item
            IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);

            //Should I register a Posible orphan for this baptizedItem?
            services.SurrogateManager.AddSurrogateReference(baptizedItem, (IStateObject)parent);

            ProcessInsertionForMostCases(services, ctx, baptizedItem, index, parent);
        }
Beispiel #6
0
 public void InsertOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item, int index, object parent)
 {
     if (services.SurrogateManager.IsSurrogateRegistered(item.GetType()))
     {
         IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);
         services.SurrogateManager.AddSurrogateReference(baptizedItem, (IStateObject)parent);
         ProcessInsertionForMostCases(services, ctx, baptizedItem, index, parent);
     }
     else
     {
         ProcessInsertionForMostCases(services, ctx, item, index, parent);
     }
 }
Beispiel #7
0
 public int IndexOfOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item)
 {
     if (typeof(IStateObject).IsAssignableFrom(item.GetType()))
     {
         return(ProcessIndexOfForMostCases(services, ctx, item));
     }
     else if (item.GetType().IsValueType || item.GetType() == typeof(String))
     {
         return(ProcessIndexOfForValueType(services, ctx, item));
     }
     else if (services.SurrogateManager.IsSurrogateRegistered(item.GetType()))
     {
         IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);
         return(ProcessIndexOfForMostCases(services, ctx, baptizedItem));
     }
     else
     {
         throw new NotSupportedException();
     }
 }
        public int IndexOfOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, object item)
        {
            IStateObjectSurrogate baptizedItem = services.SurrogateManager.GetStateObjectSurrogate(item, true);

            return(ProcessIndexOfForMostCases(services, ctx, baptizedItem));
        }
        public object GetItemInfoToSerialize(object item)
        {
            IStateObjectSurrogate baptizedItem = (IStateObjectSurrogate)item;

            return(baptizedItem.UniqueID);
        }
        public object GetterOperation(IVirtualListServiceDependencies services, IVirtualListContext ctx, int index)
        {
            IStateObjectSurrogate item = (IStateObjectSurrogate)ProcessIndexGetterForMostCases(services, ctx, index);

            return(item.Value);
        }
 public void RemoveSurrogateReference(IStateObjectSurrogate surrogate, IStateObject reference)
 {
     RemoveSurrogateReference((StateObjectSurrogate)surrogate, reference);
 }