/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) { return; } asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) { this._tasks.Add(new Task(() => asset.RunParser())); } else { try { asset.RunParser(); } catch (Exception e) { Logger.Error("Error parsing {0}.\n{1}", asset.FileName, e.Message); } } } }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) { return; } asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) { this._tasks.Add(new Task(() => asset.RunParser())); } else { try { Logger.Debug("(ProcessAsset) Loading stuff from the DB : group {0}", asset.Group); asset.RunParser(); } catch (Exception e) { Logger.Error("Error parsing {0}.\nMessage: {1}\n InnerException:{2}\nStack Trace:{3}", asset.FileName, e.Message, e.InnerException == null ? "(null)" : e.InnerException.Message, e.StackTrace); } } } }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) { return; } asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) { this._tasks.Add(new Task(() => asset.RunParser())); } else { asset.RunParser(); } } }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) { return; } asset.Parser = this.Parsers[asset.Group]; try { asset.RunParser(); parsedTasks++; } catch (Exception e) { Logger.Error("Error parsing {0}.\nMessage: {1}\n InnerException:{2}\nStack Trace:{3}", asset.FileName, e.Message, e.InnerException.Message, e.StackTrace); } }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) return; asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser())); else { try { asset.RunParser(); } catch (Exception e) { Logger.Error("Error parsing {0}.\nMessage: {1}\n InnerException:{2}\nStack Trace:{3}", asset.FileName, e.Message, e.InnerException.Message, e.StackTrace); } } } }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = this.FileSystem.FindFile(asset.FileName); // get the asset file. // if file is in any of the follow groups, try to load the original version - the reason is that assets in those groups got patched to 0 bytes. if (PatchExceptions.Contains(asset.Group)) { foreach (CrystalMpq.MpqArchive archive in this.FileSystem.Archives.Reverse()) //search mpqs starting from base { file = archive.FindFile(asset.FileName); if (file != null) break; } } if (file == null || file.Size < 10) return asset; // if it's empty, give up again. this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. return asset; }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) return; asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser())); else asset.RunParser(); } }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = this.FileSystem.FindFile(asset.FileName); // get the asset file. if (file == null || file.Size < 10) return asset; // if it's empty, give up again. this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. return asset; }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = this.GetFile(asset.FileName, PatchExceptions.Contains(asset.Group)); // get the file. note: if file is in any of the groups in PatchExceptions it'll from load the original version - the reason is that assets in those groups got patched to 0 bytes. /raist. if (file == null || file.Size < 10) return asset; // if it's empty, give up again. if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. else asset.RunParser(parser, file); // run the parsers sequentally. return asset; }