Пример #1
0
        /// <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;
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        //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);
        }
Пример #4
0
 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));
 }
Пример #5
0
 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));
 }