/// <summary> /// Tの情報をロードします。 /// setterには列番号をキーとしたsetメソッドが格納されます。 /// </summary> void LoadType(AttributeIndexType attributeIndexType) { Type type = typeof(T); // Field, Property のみを対象とする var memberTypes = new MemberTypes[] { MemberTypes.Field, MemberTypes.Property }; // インスタンスメンバーを対象とする BindingFlags flag = BindingFlags.Instance | BindingFlags.Public; //| BindingFlags.NonPublic; switch (attributeIndexType) { case AttributeIndexType.MIXED: this.SetValueMixed(type, flag, memberTypes); break; case AttributeIndexType.WITH_INDEX: this.SetValueWithAttributeIndex(type, flag, memberTypes); break; case AttributeIndexType.WITHOUT_INDEX: this.SetValueWithoutAttributeIndex(type, flag, memberTypes); break; default: break; } }
public CSVReader(TextAsset csv, AttributeIndexType attributeIndexType, bool skipFirstLine = true, Encoding encoding = null) { if (csv == null) { throw new System.NullReferenceException("csv == null"); } // Tを解析する LoadType(attributeIndexType); this.filePath = "Got CSV Directly"; this.skipFirstLine = skipFirstLine; CreateReader(csv); }
//public event EventHandler<ConvertFailedEventArgs> ConvertFailed; public CSVReader(string fileFullPath, AttributeIndexType attributeIndexType, bool skipFirstLine = true, Encoding encoding = null) { if (fileFullPath == null) { throw new System.NullReferenceException("fileFullPath == null"); } // Check Extension if (!fileFullPath.EndsWith(fileExtention, StringComparison.CurrentCultureIgnoreCase)) { throw new Exception(fileFullPath + " 's Extension is not " + fileExtention); } this.filePath = fileFullPath.Remove(fileFullPath.Length - fileExtention.Length);; this.skipFirstLine = skipFirstLine; /* * this.encoding = encoding; * // Check Encoding * if (this.encoding == null) * { * this.encoding = System.Text.Encoding.GetEncoding("utf-8"); * } */ // Tを解析する LoadType(attributeIndexType); TextAsset csv = Resources.Load(this.filePath) as TextAsset; if (csv == null) { throw new System.NullReferenceException(string.Format("{0} is not exists!", this.filePath)); } //this.reader = new StreamReader(this.filePath, this.encoding); CreateReader(csv); }
public CSVReader <T> CSVReader <T>(TextAsset csv, AttributeIndexType attributeIndexType = AttributeIndexType.MIXED, bool skipFirstLine = true, Encoding encoding = null) where T : AbstractTable, new() { return(new CSVReader <T> (csv, attributeIndexType, skipFirstLine, encoding)); }
public CSVReader <T> CSVReader <T>(string fileFullPath, AttributeIndexType attributeIndexType = AttributeIndexType.MIXED, bool skipFirstLine = true, Encoding encoding = null) where T : AbstractTable, new() { return(new CSVReader <T> (fileFullPath, attributeIndexType, skipFirstLine, encoding)); }