public void Export(IAssetExportEnvironment env) { // Determine input and output path CsvData input = env.Input as CsvData; string outputPath = env.AddOutputPath(input.Name + SourceFileExtPrimary); BaseAssetImporter.Export(input, outputPath); }
/// <summary> /// Sets the favourite spell. /// </summary> public void SetFavouriteSpell(SpellData Spell) { if (Spell != null) { CsvData CsvData = CsvFiles.Get(Gamefile.Resources).GetData("FavouriteSpell"); this.CommoditySlots.SetCommodityCount(CommodityType.ProfileResource, CsvData, CsvData.GlobalId); } }
public void SetUp() { theMapping = new TestCsvMapping(); theHeaders = new CsvData(new[] { "Count", "Flag", "Name" }); theRawValues = new CsvData(new[] { "1", "true", "Test" }); theValues = theMapping.ValueSource(theRawValues, theHeaders); }
public void SetUp() { theMapping = new MappingWithAliases(); theHeaders = new CsvData(new[] { "Count", "Flag", "SomethingElse" }); theRawValues = new CsvData(new[] { "1", "true", "Test" }); theValues = theMapping.ValueSource(theRawValues, theHeaders); }
public void CsvDataFromObjectShouldConvertableBackToObject() { var obj = new CsvDataObject(); var csvData = CsvData.FromObject(obj); var backData = csvData.GetObject <CsvDataObject>(); Assert.True(PropertiesEqual(obj, backData)); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var dataPoint = (DataPoint <T>)value; if (typeof(T) == typeof(CsvData)) { CsvData csv = (CsvData)(object)dataPoint.Value; WriteDataPointArray(writer, serializer, dataPoint.EpochTime, csv.TotalNotional); } }
public void CsvDataFromObjectShouldContainAllProperties() { var obj = new CsvDataObject(); var expected = obj.GetType().GetProperties().Length; var csvData = CsvData.FromObject(obj); Assert.Equal(expected, csvData.Columns.Count); Assert.Equal(expected, csvData.Fields.Count); }
/// <summary> /// Gets if the collection has the specified data. /// </summary> public bool Exists(int CommodityType, CsvData CsvData) { if (CommodityType >= 8) { Logging.Error(this.GetType(), "Exists() - Commodity Type is not valid. (" + CommodityType + ")"); return(false); } return(this.Slots[CommodityType].Exists(T => T.Data.Equals(CsvData))); }
public void GivenEmptyResponseData_WhenConvertingToSheet_NoCellsAreCreated() { var csvData = new CsvData(); var converter = new CsvToSheetConverter(); var result = converter.Convert(csvData); result.Rows.Should().BeEmpty(); }
static void Main(string[] args) { var argsParsed = ArgumentsParsed.FromArgs(args); var sqlQuery = SqlQuery.FromProgramParams(argsParsed.ProgramParams); var sqlData = new SqlQueryRunner(sqlQuery.Query, argsParsed.QueryParams).Run(); CsvData .FromSqlData(sqlData) .ToFile(argsParsed.GetValue(string.Concat(ArgumentsParsed.PROGRAM_PARAM_PREFIX, "outFilePath"))); }
void RemoveReference() { bool _success = CsvData.RemoveReference(reference.Value); if (!success.IsNone) { success.Value = _success; } Fsm.Event(_success?successEvent:failureEvent); }
/// <summary> /// Initializes a new instance of the <see cref="Summoner"/> class. /// </summary> public Summoner(CsvData CsvData) : base(CsvData) { this.ManaCount = Globals.StartMana; this.ManaReserve = Globals.MaxMana; this.Hand = new int[4]; this.SpellQueue = new List <int>(4); this.SpellQueue2 = new List <int>(4); this.LastUsedSpellIdx = -1; }
public override void UpdateCurrentFrame(int frame) { var data = CsvData.FirstOrDefault(d => d.FrameNumber == frame); if (data == null) { return; } Translation = data.Translation; Rotation = data.Rotation; }
public void ShouldContainStringData() { // Arrange const string expected = "hello world"; var sut = new CsvData(expected, "ext"); // Act var actual = sut.ToString(); // Assert Assert.Equal(expected, actual); }
/// <summary> /// Adds a data data reference. /// </summary> public static void EncodeData(this ChecksumEncoder Stream, CsvData CsvData) { if (CsvData != null) { Stream.WriteVInt(CsvData.Type); Stream.WriteVInt(CsvData.Instance); } else { Stream.WriteVInt(0); } }
/* * 获取文本总长度 */ public int GetLength(string filename) { CsvData data = new CsvData(); if (m_AllDatas.TryGetValue(filename, out data)) { return(data.GetLength()); } else { return(0); } }
void DoGetCsvRecordCount() { CsvData _data = CsvData.GetReference(reference.Value); if (_data == null) { Fsm.Event(errorEvent); recordCount.Value = 0; return; } recordCount.Value = _data.RecordCount; }
void DoGetCsvColumnCount() { CsvData _data = CsvData.GetReference(reference.Value); if (_data == null) { Fsm.Event(errorEvent); columnCount.Value = 0; return; } columnCount.Value = _data.ColumnCount; }
private CsvData DrawWidget(Rect position, CsvData item) { float midY = position.y + position.height / 2 - 5; Rect fieldLableRect = new Rect(position.x, midY, 50, position.height); Rect headerLableRect = new Rect(fieldLableRect.xMax + interval, midY, 200, position.height); Rect dataTypeEnumRect = new Rect(headerLableRect.xMax + interval, midY, 200, position.height); Rect isParseRect = new Rect(dataTypeEnumRect.xMax + interval, midY, 200, position.width); EditorGUI.LabelField(fieldLableRect, "字段名:"); EditorGUI.LabelField(headerLableRect, item.header); item.dataType = (DataType)EditorGUI.EnumPopup(dataTypeEnumRect, "数据类型:", item.dataType); item.isParse = EditorGUI.Toggle(isParseRect, "是否解析该字段", item.isParse); return(item); }
public string GetData(string filename, string key, string head) { CsvData data = new CsvData(); string value = ""; if (m_AllDatas.TryGetValue(filename, out data)) { value = data.GetData(key, head); } else { value = "error"; } return(value); }
public void SaveFile(string fileName, CsvData csvData) { using (var streamWriter = new StreamWriter(fileName)) { var header = csvData.FieldNames; var headerCsv = string.Join(',', csvData.FieldNames); streamWriter.WriteLine(string.Join(',', csvData.FieldNames)); foreach (var entry in csvData.Entries) { streamWriter.WriteLine(entry.GetCsvRow(header)); } } }
/// <summary> /// Uses the specified commodity count. /// </summary> public void UseCommodity(int CommodityType, CsvData CsvData, int Count) { if (CommodityType >= 8) { Logging.Error(this.GetType(), "UseCommodity() - Commodity Type is not valid. (" + CommodityType + ")"); return; } DataSlot Slot = this.Slots[CommodityType].Find(T => T.Data == CsvData); if (Slot != null) { Slot.Count -= Count; } }
public async Task <HttpResponseMessage> GetDetailsByDateTime(DateTime date) { /// check for null date try { var csvData = new CsvData(); // id there is a db this can asychronus call var details = csvData.DataConvertor(); // we can convert the details object to Json here return(Request.CreateResponse(System.Net.HttpStatusCode.OK, FilterData(details, date))); } catch (Exception ex) { return(new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError)); } }
public void Replace() { // Arrange IEnumerable <ITupleReplace> replaces = new List <ITupleReplace>() { CreateReplace("A", "Z"), CreateReplace("B", "V", "B"), }; var csvDataOk = new CsvData(); var aListA = new List <string>() { "A1", "A2", "A3", "A4" }; var aListB = new List <string>() { "AB1", "AB2", "AB3", "AB4" }; csvDataOk.Add("A", aListA); csvDataOk.Add("B", aListB); var lines = csvDataOk.GetLines(); // Act var result = CsvActionCreator.Create( replaces); // Assert foreach (var item in result) { lines.ToList().ForEach(item); } lines.ToList().ForEach( x => { Assert.IsTrue(x["A"].Contains("Z")); Assert.IsTrue(!x["A"].Contains("A")); Assert.IsTrue(x["B"].Contains("Z")); Assert.IsTrue(!x["B"].Contains("A")); Assert.IsTrue(x["B"].Contains("V")); Assert.IsTrue(!x["B"].Contains("B")); } ); }
public void ShouldWriteContentToFile() { // Arrange const string baseName = "fileName"; const string fileName = "fileName.ext"; const string expected = "hello world"; var sut = new CsvData(expected, "ext"); // Act sut.Save(baseName); // Assert var actual = File.ReadAllText(fileName); Assert.Equal(expected, actual); }
private void CreateDatabaseIfNotExists() { var database = Store.Database; var dbRecord = Store.Admin.Server.Send(new GetDatabaseRecordOperation(database)); if (dbRecord == null) { this._logger.LogInformation("RavenDB database does not exist, creating and seeding with initial data"); // Create database dbRecord = new DatabaseRecord(database); var createResult = Store.Admin.Server.Send(new CreateDatabaseOperation(dbRecord)); if (createResult.Name != null) { // Seed database var talks = CsvData.LoadTalks(); var speakers = CsvData.LoadSpeakers(); // old => new speaker ID map var speakerIdMap = new Dictionary <string, string>(); using (var session = Store.OpenSession()) { foreach (var speaker in speakers) { var oldId = speaker.Id; speaker.Id = null; session.Store(speaker); speakerIdMap.Add(oldId, speaker.Id); } foreach (var talk in talks) { talk.Id = null; talk.Speaker = speakerIdMap[talk.Speaker]; session.Store(talk); } session.SaveChanges(); } this._logger.LogInformation("Seeded database with {0} talks", talks.Count); this._logger.LogInformation("Seeded database with {0} speakers", speakers.Count); } } }
/// <summary> /// Gets the commodity count. /// </summary> public int GetCommodityCount(int CommodityType, CsvData CsvData) { if (CommodityType >= 8) { Logging.Error(this.GetType(), "GetCommodityCount() - Commodity Type is not valid. (" + CommodityType + ")"); return(0); } DataSlot Slot = this.Slots[CommodityType].Find(T => T.Data == CsvData); if (Slot != null) { return(Slot.Count); } return(0); }
public CsvData CreateCsvData(AggregatedData data) { CsvData report = new CsvData(new[] { "Local Time", "Volume" }); DateTime utcSessionStart = data.TradingDate.AddDays(-1).Add(data.SessionStart); for (int i = 0; i < data.Volumes.Length; i++) { DateTime localTime = utcSessionStart.Add(TimeSpan.FromHours(i)).ToLocalTime(); string time = localTime.TimeOfDay.ToString(@"hh\:mm"); string volume = data.Volumes[i].ToString(CultureInfo.InvariantCulture); report.AddRow(new[] { time, volume }); } return(report); }
public static IEnumerable <ICsvLine> AddStringLine(this IEnumerable <ICsvLine> lines, string repeatValue = null) { var csvData = new CsvData(); var aListA = repeatValue == null ? new List <string>() { "S1", "S2", "S3", "S4" } : new List <string>() { repeatValue, repeatValue, repeatValue, repeatValue }; csvData.Add("string", aListA); lines = lines.Append(csvData.GetLines().First()); return(lines); }
public static IEnumerable <ICsvLine> AddIntLine(this IEnumerable <ICsvLine> lines, int?repeatValue = null) { var csvData = new CsvData(); var aListA = repeatValue == null ? new List <string>() { "1", "2", "3", "4" } : new List <string>() { repeatValue.ToString(), repeatValue.ToString(), repeatValue.ToString(), repeatValue.ToString() }; csvData.Add("int", aListA); lines = lines.Append(csvData.GetLines().First()); return(lines); }
public HttpResponseMessage GetUrl(CsvData data) { var src = String.Format(urlFormat, Request.RequestUri.Host + (Request.RequestUri.Port != 80 ? ":" + Request.RequestUri.Port : ""), data.DisplayType, HttpUtility.UrlEncode(data.CsvDocument), data.HasColumnNames ? "1" : "0", data.DisplayType != "RSS" ? data.GroupBy : null, data.Width, data.FilterBy, data.FilterValue, data.ExactFilterMatch ? "1" : "0"); if (data.DisplayType == "Timeline") src += "&startDateColumn=" + data.Timeline.startDateColumn + "&endDateColumn=" + data.Timeline.endDateColumn + "&textColumn=" + data.Timeline.TextColumn + "&numOfDaysToShow=" + data.Timeline.NumberOfDaysToShowFromNow + "&onlyWithContent=" + (data.Timeline.OnlyShowLinesWithContent ? "1" : "0"); if (data.DisplayType == "List") src += "&include=" + String.Join("|", data.Columns.Where(x => x.Include).Select(x => x.Name).ToArray()); if (data.DisplayType == "RSS") src += "&Title=" + data.RSS.Title + "&Description=" + data.RSS.Description + "&DateColumn=" + data.RSS.DateColumn + "&TitleColumn=" + data.RSS.TitleColumn + "&DescriptionColumn=" + data.RSS.DescriptionColumn + "&LinkColumn=" + data.RSS.LinkColumn + "&numOfDaysToShow=" + data.RSS.NumberOfDaysToShowFromNow; var ret = new HttpResponseMessage(); ret.Content = new StringContent(src); return ret; }
public CsvData AnalyzeCsvData(CsvData data) { try { if (String.IsNullOrEmpty(data.CsvDocument)) throw new Exception("Du skal indtaste et link til dokumentet"); try { SmtpClient client = new SmtpClient(); MailMessage mm = new MailMessage(); mm.From = new MailAddress("*****@*****.**"); mm.To.Add(new MailAddress("*****@*****.**")); mm.Subject = "AnalyzeCsvData called"; mm.Body = data.CsvDocument; client.Send(mm); } catch { //throw; } data.CsvDocumentValid = true; data.Width = 900; data.Columns = new List<Column>(); data.HasColumnNames = true; data.GroupBy = ""; data.FilterBy = ""; data.FilterValue = ""; data.NotSupportedDisplayTypes = new List<string>(); data.Timeline = new Timeline(); data.Timeline.OnlyShowLinesWithContent = true; data.Timeline.NumberOfDaysToShowFromNow = 28; data.Timeline.endDateColumn = ""; data.RSS = new RSS(); data.RSS.Title = "Indtast overskrift her"; data.RSS.Description = "Indtast beskrivelse her"; data.RSS.NumberOfDaysToShowFromNow = 28; data.DisplayType = "Timeline"; var list = Csv.CsvListRepository.GetList(data.CsvDocument, true, "", "", "", false, null); foreach (var col in list.ColumnNames) { data.Columns.Add(new Column { Name = col.Name, Type = col.Type }); if (col.Type == "DateTime" && String.IsNullOrEmpty(data.Timeline.startDateColumn)) { data.Timeline.startDateColumn = col.Name; data.RSS.DateColumn = col.Name; } else if (col.Type == "DateTime" && String.IsNullOrEmpty(data.Timeline.endDateColumn)) data.Timeline.endDateColumn = col.Name; if (col.Type == "String" || col.Type == "Uri") { if (String.IsNullOrEmpty(data.GroupBy)) data.GroupBy = col.Name; if (String.IsNullOrEmpty(data.Timeline.TextColumn)) data.Timeline.TextColumn = col.Name; if (col.Type == "String") if (String.IsNullOrEmpty(data.RSS.TitleColumn)) data.RSS.TitleColumn = col.Name; else if (String.IsNullOrEmpty(data.RSS.DescriptionColumn)) data.RSS.DescriptionColumn = col.Name; } if (col.Type == "Uri" && String.IsNullOrEmpty(data.RSS.LinkColumn)) data.RSS.LinkColumn = col.Name; } data.CsvDocument = list.CsvLink; if (String.IsNullOrEmpty(data.Timeline.startDateColumn)) { data.NotSupportedDisplayTypes.Add("Timeline"); data.DisplayType = "List"; } } catch (Exception ex) { data.CsvDocumentValid = false; data.isError = true; data.ErrorMessage = ex.Message; } return data; }