Example #1
0
        public void ProcessRead(IPostProcessReader reader)
        {
            reader.NextTag();

            ICommandTypeRegistry   commandTypeRegistry   = reader.CommandTypeRegistry;
            ICommandTypeExtendable commandTypeExtendable = reader.CommandTypeExtendable;

            commandTypeExtendable.RegisterOverridingCommandType(typeof(MergeArraySetterCommand), typeof(ArraySetterCommand));
            Object result = reader.ReadObject();

            commandTypeExtendable.UnregisterOverridingCommandType(typeof(MergeArraySetterCommand), typeof(ArraySetterCommand));

            if (!(result is CUDResult))
            {
                throw new Exception("Can only handle results of type '" + typeof(CUDResult).Name + "'. Result of type '"
                                    + result.GetType().Name + "' given.");
            }

            ICommandBuilder          commandBuilder           = CommandBuilder;
            Member                   directObjRefDirectMember = this.directObjRefDirectMember;
            CUDResult                cudResult = (CUDResult)result;
            IList <IChangeContainer> changes   = cudResult.AllChanges;

            for (int i = 0, size = changes.Count; i < size; i++)
            {
                IChangeContainer changeContainer = changes[i];
                if (!(changeContainer is CreateContainer))
                {
                    continue;
                }

                IObjRef ori = changeContainer.Reference;
                if (ori == null)
                {
                    continue;
                }
                else if (ori is DirectObjRef)
                {
                    IObjectFuture  objectFuture  = new ObjRefFuture(ori);
                    IObjectCommand setterCommand = commandBuilder.Build(commandTypeRegistry, objectFuture, ori, directObjRefDirectMember);
                    reader.AddObjectCommand(setterCommand);
                    IObjectCommand mergeCommand = commandBuilder.Build(commandTypeRegistry, objectFuture, changeContainer);
                    reader.AddObjectCommand(mergeCommand);
                }
                else
                {
                    throw new Exception("Not implemented yet");
                }
            }
        }
        public Object ReadObject(Type returnType, String elementName, int id, IReader reader)
        {
            if (!XmlDictionary.OriWrapperElement.Equals(elementName))
            {
                throw new Exception("Element '" + elementName + "' not supported");
            }

            String idIndexValue = reader.GetAttributeValue(idNameIndex);
            sbyte  idIndex      = idIndexValue != null?SByte.Parse(idIndexValue) : ObjRef.PRIMARY_KEY_INDEX;

            reader.NextTag();
            Type   realType = (Type)reader.ReadObject();
            Object objId    = reader.ReadObject();
            Object version  = reader.ReadObject();

            IObjRef ori = ObjRefFactory.CreateObjRef(realType, idIndex, objId, version);

            Object obj = new ObjRefFuture(ori);

            return(obj);
        }