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); }
public static ResourceStorageWatcher <List <Resource>, Resource> createWatcher <Resource>(this List <Resource> storage) { var result = new ResourceStorageWatcher <List <Resource>, Resource>( storage, (store) => store.Count, (store, index) => store[index] ); return(result); }
static bool processResourceListObject <Storage, SrcType, DstType>( List <DstType> dstObjectList, ResourceStorageWatcher <Storage, SrcType> watcher, System.Func <SrcType, DstType> converter) { if (converter == null) { throw new System.ArgumentNullException("converter"); } return(processResourceListObject(dstObjectList, watcher, (obj, idx, id) => converter(obj))); }
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(); } } }
static bool saveResourcesToPath <DstType, SrcType, StorageType>( List <string> outObjectPaths, string baseDir, ResourceStorageWatcher <StorageType, SrcType> objects, ObjectConverter <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"); } return(saveResourcesToPath( outObjectPaths, baseDir, objects, (obj, idx, id) => converter(obj), nameFunc, baseName, showGui, dstProcessor )); }