public void Set(SongData Song, string Name, List <string> Parameter) { var o = HeaderList.FirstOrDefault(x => x.Name == Name); if (o == null) { Error.Add(ErrorData.Type.UnknownHeaderName); return; } if (!Requred(Parameter, o.Length)) { return; } o.Execute(Song, Parameter); }
public ErrorData Collect(Exception e) { if (ErrorditeScope.Data == null) return null; var ret = new ErrorData(); foreach (var dataItem in ErrorditeScope.Data) { ret.Add(dataItem.Key, dataItem.Value); } return ret; }
protected void AddIfNotEmpty(string key, string value, ErrorData data) { if (!string.IsNullOrEmpty(value)) { //make sure we dont get duplicate keys if (data.ContainsKey(key)) { int index = 1; while (data.ContainsKey(key)) { key = string.Format("{0}-{1}", key, index); index++; } } data.Add(key, value); } }
public void Make(SongData Song, TrackData Track, MmlFileReader m) { var fl = m.FetchLine(); var Command = ObjectList.FirstOrDefault(x => fl.StartsWith(x.Name)); if (Command == null) { Error.Add(ErrorData.Type.UnknownCommandName); return; } m.StepCount(Command.Name.Length); Command.Execute(Song, Track, Command, m); }
private static ErrorData GetCustomData(Exception exception, IEnumerable<KeyValuePair<string, string>> customData) { var items = new ErrorData(); if (customData != null) { foreach (var item in customData) { items.Add("Custom." + item.Key, item.Value); } } var scopedItems = new ScopedDataCollector().Collect(exception); if (scopedItems != null) { foreach (var item in scopedItems) { items.Add("Scoped." + item.Key, item.Value); } } var httpItems = new HttpContextDataCollector().Collect(exception, Configuration); if (httpItems != null) { foreach (var item in httpItems) { items.Add("Request." + item.Key, item.Value); } } if (Configuration.DataCollectors == null) return items; foreach (var dataCollectorFactory in Configuration.DataCollectors) { var item = CollectData(exception, dataCollectorFactory); if (item != null) items.Add(item); } return items; }
private static ErrorData CollectData(Exception exception, IDataCollectorFactory dataCollectorFactory) { try { var dataCollector = dataCollectorFactory.Create(); if (dataCollector == null) { return null; } var exceptionData = dataCollector.Collect(exception); if (exceptionData != null) { var ret = new ErrorData(); foreach (var kvp in exceptionData) { ret.Add(string.Format("{0}.{1}", dataCollectorFactory.Prefix, kvp.Key), kvp.Value); } return ret; } } catch (Exception e) { return new ErrorData{{"Error", e.Message}}; } return null; }
private void ParseMmlFile(string filename) { Song = new SongData(); Song.Error = Error; var m = new MmlFileReader(); Error.SetFileReader(m); if (!m.Load(filename)) { Error.Add(ErrorData.Type.FileNotFound); return; } while (!m.IsEof() && !Error.HasError) { // 行頭 var ct = m.FetchType(); // コメントブロック終了時の行は読み飛ばす if (ct == MmlCharactorType.CommentEnd) { m.SkipType(); m.StepNextLine(); } if (m.IsComment(ct)) { m.SkipType(); continue; } if (ct == MmlCharactorType.NextLine || ct == MmlCharactorType.Eof) { m.SkipType(); continue; } if (ct != MmlCharactorType.GeneralChanacter) { Error.Add(ErrorData.Type.LineHeaderIsWrong); continue; } ReadItem(m); } }