コード例 #1
0
        static bool processResourceListObject <Storage, SrcType, DstType>(
            List <DstType> dstObjectList,
            ResourceStorageWatcher <Storage, SrcType> watcher,
            System.Func <SrcType, int, ResId, DstType> converter)
        {
            var result = watcher.hasNewObjects;

            if (dstObjectList == null)
            {
                throw new System.ArgumentNullException("dstObjectList");
            }
            if (watcher == null)
            {
                throw new System.ArgumentNullException("watcher");
            }
            if (converter == null)
            {
                throw new System.ArgumentNullException("converter");
            }

            foreach (var cur in watcher.getNewObjectsData())
            {
                var dst = converter(cur.data, cur.index, cur.id);
                dstObjectList.Add(dst);
            }
            watcher.updateNumObjects();

            return(result);
        }
コード例 #2
0
        static bool saveResourcesToPath <DstType, SrcType, StorageType>(
            List <string> outObjectPaths,
            string baseDir,
            ResourceStorageWatcher <StorageType, SrcType> objects,
            IndexedObjectConverter <SrcType, DstType> converter,
            System.Func <DstType, string> nameFunc, string baseName, bool showGui,
            System.Action <DstType> dstProcessor = null)
            where DstType : IFastJsonValue
        {
            if (converter == null)
            {
                throw new System.ArgumentNullException("converter");
            }

            bool result = false;

            try{
                if (objects != null)
                {
                    foreach (var curData in objects.getNewObjectsData())
                    {
                        //lq begin
                        var temp = saveResourceToPath(
                            baseDir, curData.data, curData.index, curData.id,
                            objects.numObjects,
                            converter, nameFunc, baseName, showGui,
                            dstProcessor
                            );

                        if (string.IsNullOrEmpty(temp) == false)
                        {
                            outObjectPaths.Add(temp);
                            result = true;
                        }
                        //end
                    }
                    objects.updateNumObjects();                    //yup. I forgot that part.
                }
                return(result);
            }
            finally{
                if (showGui)
                {
                    ExportUtility.hideProgressBar();
                }
            }
        }