public TSaveResponse Process(IUnitOfWork unitOfWork, TSaveRequest request,
                                     SaveRequestType requestType = SaveRequestType.Auto)
        {
            StateBag.Clear();

            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            UnitOfWork = unitOfWork;

            Request  = request;
            Response = new TSaveResponse();

            Row = request.Entity;
            if (Row == null)
            {
                throw new ArgumentNullException("Entity");
            }

            if (requestType == SaveRequestType.Auto)
            {
                if (((Field)Row.IdField).IsNull(Row))
                {
                    requestType = SaveRequestType.Create;
                }
                else
                {
                    requestType = SaveRequestType.Update;
                }
            }

            if (requestType == SaveRequestType.Update)
            {
                ValidateAndClearIdField();
                Old = new TRow();
                LoadOldEntity();
            }

            ValidateRequest();
            SetInternalFields();
            BeforeSave();

            ClearNonTableAssignments();
            ExecuteSave();

            AfterSave();

            PerformAuditing();

            OnReturn();
            return(Response);
        }
Esempio n. 2
0
        /** リクエスト。セーブ。バイナリファイル。
         */
        public Item RequestSaveBinaryFile(SaveRequestType a_request_type, Path a_relative_path, byte[] a_binary)
        {
            switch (a_request_type)
            {
            case SaveRequestType.SaveLocalBinaryFile:
            {
                WorkItem t_work_item = new WorkItem();
                t_work_item.RequestSaveLocalBinaryFile(a_relative_path, a_binary);
                this.add_list.Add(t_work_item);
                return(t_work_item.GetItem());
            } break;
            }

            Tool.Assert(false);
            return(null);
        }
Esempio n. 3
0
        /** リクエスト。セーブ。テクスチャファイル。
         */
        public Item RequestSaveTextureFile(SaveRequestType a_request_type, Path a_relative_path, UnityEngine.Texture2D a_texture)
        {
            switch (a_request_type)
            {
            case SaveRequestType.SaveLocalTextureFile:
            {
                WorkItem t_work_item = new WorkItem();
                t_work_item.RequestSaveLocalTextureFile(a_relative_path, a_texture);
                this.add_list.Add(t_work_item);
                return(t_work_item.GetItem());
            } break;
            }

            Tool.Assert(false);
            return(null);
        }
Esempio n. 4
0
        /** リクエスト。セーブ。テクスチャファイル。
         */
        public Item RequestSaveTextureFile(SaveRequestType a_request_type, Path a_relative_path, UnityEngine.Texture2D a_texture)
        {
            switch (a_request_type)
            {
            case SaveRequestType.SaveLocalTextureFile:
            {
                System.Collections.Generic.LinkedListNode <WorkItem> t_work_node = this.work_pool.Alloc();
                t_work_node.Value.Reset();

                t_work_node.Value.RequestSaveLocalTextureFile(a_relative_path, a_texture);
                this.work_add.AddLast(t_work_node);

                return(t_work_node.Value.GetItem());
            } break;
            }

            Tool.Assert(false);
            return(null);
        }
 SaveResponse ISaveRequestProcessor.Process(IUnitOfWork uow, ISaveRequest request, SaveRequestType type)
 {
     return(Process(uow, (TSaveRequest)request, type));
 }