protected virtual void ParseReferenceAsCsvStream(System.IO.Stream stream) { using (StreamReader c = new StreamReader(stream)) { c.ReadLine(); while (c.Peek() > 0) { CommaDelimitedString fields = CommaDelimitedString.Parse(c.ReadLine()); uint AdditionId = 0; try { string field = fields[1].Trim('\0', ' '); bool IsValidInteger = uint.TryParse(fields[0], System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out AdditionId); AdditionHandler Handler = CoreService.Find <AdditionHandler>(field); if (!IsValidInteger) { if (refenceWarningsAsErrors.Enabled) { WriteError("AdditionFactory", "Not a valid integer {0}", field); } else { WriteWarning("AdditionFactory", "Not a valid integer {0}", field); } } else if (Handler == null || Handler.Method == null) { if (refenceWarningsAsErrors.Enabled) { WriteError("AdditionFactory", "Method not found {0}", field); } else { WriteWarning("AdditionFactory", "Method not found {0}", field); } } else { MethodInfo info = Handler.Method; GC.SuppressFinalize(info); this.addition_table.Add(AdditionId, info); } } catch (Exception e) { HostContext.AddUnhandeldException(e); } } } }
protected virtual void ParseReferenceAsCsvStream(System.IO.Stream stream) { using (StreamReader c = new StreamReader(stream)) { c.ReadLine(); while (c.Peek() > 0) { CommaDelimitedString fields = CommaDelimitedString.Parse(c.ReadLine()); uint SkillId = 0; bool IsValidInteger = uint.TryParse(fields[0], System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out SkillId); try { SkillHandler Handler = CoreService.Find <SkillHandler>(fields[1]); if (Handler != null && IsValidInteger) { methods.Add(SkillId, Handler); } else { if (refenceWarningsAsErrors.Enabled) { WriteError("SkillManager", "Spell not loaded: {0} {1}", fields[0], fields[1]); } else { WriteWarning("SkillManager", "Spell not loaded: {0} {1}", fields[0], fields[1]); } } } catch (Exception e) { if (refenceWarningsAsErrors.Enabled) { WriteError("SkillManager", "Unhandeld exception {1} {0}", e.Message, e.Source); } else { WriteWarning("SkillManager", "Unhandeld exception {1} {0}", e.Message, e.Source); } } } } }
protected void RegisterExternalGmCommand(string path) { try { GmCommandHandler handler = CoreService.Find <GmCommandHandler>(path); if (handler != null) { Register(handler); } else { HostContext.AddUnhandeldException(new SystemException(string.Format("Cannot find console command: {0}", path))); } } catch (Exception e) { //do nothing here HostContext.AddUnhandeldException(e); } }