Beispiel #1
0
        public override void InstallBindings()
        {
            var curriculumData = CsvLoader.LoadCurriculum(data);

            Container.Bind <ImageDatabase>().FromInstance(imageDatabase).AsSingle();
            Container.BindInstance(curriculumData).AsSingle();
        }
Beispiel #2
0
        public void PostCsv_ShouldReturn200IfSuccesful()
        {
            // Arrange
            ICsvLoader            loader  = new CsvLoader();
            Mock <IModuleService> service = new Mock <IModuleService>(MockBehavior.Loose);

            service.Setup(s => s.SendCreeerModuleCommand(It.IsAny <Module>())).Returns(new CreeerModuleCommandResponse()
            {
                Message = "xd", StatusCode = 200
            });
            ModuleController sut          = new ModuleController(service.Object, loader);
            Mock <IFormFile> formFileMock = new Mock <IFormFile>();

            using (FileStream fs = File.OpenRead(file2))
            {
                formFileMock.Setup(file => file.OpenReadStream()).Returns(fs);

                CsvInlaadFormViewModel model = new CsvInlaadFormViewModel()
                {
                    Cohort = "2017/2018", File = formFileMock.Object
                };

                // Act
                var result = sut.PostCsvFile(model);

                // Assert
                Assert.IsInstanceOfType(result, typeof(OkObjectResult));
            }
        }
Beispiel #3
0
    /// <summary>
    /// 读取CSV文件数据(利用反射)
    /// </summary>
    /// <typeparam name="CsvData">CSV数据对象的类型</typeparam>
    /// <param name="csvFilePath">CSV文件路径</param>
    /// <param name="csvDatas">用于缓存数据的字典</param>
    /// <returns>CSV文件所有行内容的数据对象</returns>
    private static Dictionary <int, T_CsvData> LoadCsvData <T_CsvData>(string csvFilePath)
    {
        Dictionary <int, T_CsvData> dic = new Dictionary <int, T_CsvData>();

        /* 从CSV文件读取数据 */
        Dictionary <string, Dictionary <string, string> > result = CsvLoader.LoadCsvFile(csvFilePath);

        /* 遍历每一行数据 */
        foreach (string ID in result.Keys)
        {
            /* CSV的一行数据 */
            Dictionary <string, string> datas = result[ID];

            /* 读取Csv数据对象的属性 */
            PropertyInfo[] props = typeof(T_CsvData).GetProperties();

            /* 使用反射,将CSV文件的数据赋值给CSV数据对象的相应字段,要求CSV文件的字段名和CSV数据对象的字段名完全相同 */
            T_CsvData obj = Activator.CreateInstance <T_CsvData>();
            foreach (PropertyInfo p in props)
            {
                ReflectUtil.PiSetValue <T_CsvData>(datas[p.Name], p, obj);
            }

            /* 按ID-数据的形式存储 */
            dic[Convert.ToInt32(ID)] = obj;
        }

        return(dic);
    }
Beispiel #4
0
 private void InitializeArenaInfos()
 {
     int[,] array = new int[this.arenasCount * this.arenaStages, 2];
     CsvLoader.SplitText <int>(this.csvData, ',', ref array);
     int[,] item     = new int[this.arenaStages, 2];
     item[0, 0]      = array[0, 0];
     item[0, 1]      = array[0, 1];
     this.arenaInfos = new List <int[, ]>();
     for (int i = 1; i < array.GetLength(0); i++)
     {
         if ((i % 4) == 0)
         {
             this.arenaInfos.Add(item);
             item       = new int[this.arenaStages, 2];
             item[0, 0] = array[i, 0];
             item[0, 1] = array[i, 1];
         }
         else
         {
             int num2 = i % 4;
             item[num2, 0] = array[i, 0];
             item[num2, 1] = array[i, 1];
         }
     }
     this.arenaInfos.Add(item);
 }
Beispiel #5
0
    public static int Main(string[] args)
    {
        try{
            DirectoryInfo basedir = null;
            if (args.Length < 1)
            {
                basedir = new DirectoryInfo("./");
            }
            else
            {
                basedir = new DirectoryInfo(args[0]);
            }
            if (!basedir.Exists)
            {
                Console.WriteLine("Directory not found: {0}", basedir.FullName);
                return(1);
            }
            var csvLoader = new CsvLoader(basedir);
            csvLoader.Execute();

            return(0);
        } catch (Exception e) {
            Console.Error.WriteLine(e);
            return(1);
        }
    }
Beispiel #6
0
        static void Main(string[] args)
        {
            DataMoverLog.InfoAsync("Starting the application");
            MigrationConfiguration configuration = null;

            if (args.Length > 0)
            {
                DataMoverLog.DebugAsync("Received parameters:");
                for (var i = 0; i < args.Length; i++)
                {
                    DataMoverLog.DebugAsync($"{i} - {args[i]}");
                }

                configuration = ConfigurationLoader.LoadConfiguration(args);
            }

            if (configuration == null)
            {
                DataMoverLog.ErrorAsync("Missing configuration.");
                PrintUsage();
            }
            else
            {
                var stream = System.IO.File.Open(configuration.Files[0].Path, FileMode.Open, FileAccess.Read,
                                                 FileShare.Read);
                var loader = new CsvLoader(configuration.Files[0].Name);
                foreach (var l in loader.ReadLines(stream))
                {
                }
            }
            Task.Delay(TimeSpan.FromMilliseconds(500)).Wait();
            DataMoverLog.Terminate();
        }
Beispiel #7
0
    private void Awake()
    {
        m_ItemCsv = CsvLoader.LoadCsvBy2DimensionArray("Csv/Item_Table");

        int i = 0;

        for (int j = 0; i < m_LampItemCells.Length; ++i, ++j)
        {
            m_LampItemCells[j].Initialize(m_LampSprites[j], ItemCategory.LAMP, j, m_ItemCsv[i + 1, 2], int.Parse(m_ItemCsv[i + 1, 8]), DataManager.GetHaveItem(ItemCategory.LAMP, j));
            m_LampItemCells[j].m_OnClickedEvent.AddListener(OnStoreItemCellClicked);
        }

        for (int j = 0; i < m_LampItemCells.Length + m_NutrientsItemCells.Length; ++i, ++j)
        {
            m_NutrientsItemCells[j].Initialize(m_NutrientsSprites[j], ItemCategory.NUTRIENTS, j, m_ItemCsv[i + 1, 2], int.Parse(m_ItemCsv[i + 1, 8]), DataManager.GetHaveItem(ItemCategory.NUTRIENTS, j));
            m_NutrientsItemCells[j].m_OnClickedEvent.AddListener(OnStoreItemCellClicked);
        }

        for (int j = 0; i < m_LampItemCells.Length + m_NutrientsItemCells.Length + m_SprinklerItemCells.Length; ++i, ++j)
        {
            m_SprinklerItemCells[j].Initialize(m_SprinklerSprites[j], ItemCategory.SPRINKLER, j, m_ItemCsv[i + 1, 2], int.Parse(m_ItemCsv[i + 1, 8]), DataManager.GetHaveItem(ItemCategory.SPRINKLER, j));
            m_SprinklerItemCells[j].m_OnClickedEvent.AddListener(OnStoreItemCellClicked);
        }

        for (int j = 0; i < m_LampItemCells.Length + m_NutrientsItemCells.Length + m_SprinklerItemCells.Length + m_ETCItemCells.Length; ++i, ++j)
        {
            m_ETCItemCells[j].Initialize(m_ETCSprites[j], ItemCategory.ETC, j, m_ItemCsv[i + 1, 2], int.Parse(m_ItemCsv[i + 1, 8]), true);
            m_ETCItemCells[j].m_OnClickedEvent.AddListener(OnStoreItemCellClicked);
        }
    }
 public void Setup()
 {
     _directoryFinder = new DirectoryFinder();
     _configuration   = Substitute.For <IConfiguration>();
     _target          = new CsvLoader(_directoryFinder, _configuration);
     _path            = "D:\\WTWDIP\\ClaimsReserving\\ClaimsReserving\\InputFiles\\";
 }
Beispiel #9
0
    //非同期でロードする
    private IEnumerator LoadAsync()
    {
        //非同期ロード開始
        ResourceRequest resourceRequest_chara       = Resources.LoadAsync <GameObject> ("Prefabs/Chara");
        ResourceRequest resourceRequest_mana        = Resources.LoadAsync <GameObject> ("Prefabs/Mana");
        ResourceRequest resourceRequest_param_chara = Resources.LoadAsync <TextAsset> ("Parameter/characters");

        //ロードが終わるまで待機(resourceRequest.progressで進捗率を確認出来る)
        while (!resourceRequest_chara.isDone || !resourceRequest_mana.isDone || !resourceRequest_param_chara.isDone)
        {
            Debug.Log("ロード待ち");
            yield return(0);
        }
        Debug.Log("ロード完了!");
        //ロード完了、resourceRequest.assetからロードしたアセットを取得
        characterIcon = resourceRequest_chara.asset as GameObject;
        manaIcon      = resourceRequest_mana.asset as GameObject;
        TextAsset csv = resourceRequest_param_chara.asset as TextAsset;

        // var strReader = new StringReader(csv.text);
        // var csvReader = new CsvHelper.CsvReader(strReader, System.Globalization.CultureInfo.CreateSpecificCulture("ja-JP"));
        // csvReader.Configuration.RegisterClassMap<CharacterMapper>();
        // charaParameters = csvReader.GetRecords<Character>().ToArray();
        (charaParameters, _) = CsvLoader.Reader <Character, CharacterMapper>(csv);
        yield return(new WaitForSeconds(0.5f));

        Debug.Log("セットアップ開始!");
        SetUp();
    }
Beispiel #10
0
    // Use this for initialization
    void Start()
    {
        CsvLoader   loader   = new CsvLoader();
        CsvTable    csvTable = loader.LoadCSV("Config/test");
        TestDataMap tMap     = new TestDataMap();
        IDataMap    tempMap  = tMap as IDataMap;

        loader.LoadCSV("Config/test", ref tempMap);
        //tMap.Load(ref csvTable);

        Dictionary <int, TestData> Dic = tMap.GetMap() as Dictionary <int, TestData>;

        //tMap.GetMap(ref Dic);
        //tMap.clearMap();
        foreach (var t in Dic)
        {
            Debug.Log("!!!!!!!" + t.Key + "=" + t.Value.Name);
        }

        //CsvTable csvTable = loader.LoadCSV("Config/" + str);
        foreach (CsvRecord record in csvTable.Records)
        {
            foreach (string header in csvTable.Headers)
            {
                Debug.Log(header + ":" + record.GetField(header));
                text.text = text.text + (header + ":" + record.GetField(header));
            }
        }
    }
Beispiel #11
0
        public async Task Initialize()
        {
            Sheet sheet;

            if (Settings.Instance.RecentFile != null)
            {
                try
                {
                    sheet = await CsvLoader.LoadLocal(Settings.Instance.RecentFile);
                }
                catch
                {
                    sheet = await CsvLoader.Load("student-mat.csv");
                }
            }
            else
            {
                sheet = await CsvLoader.Load("student-mat.csv");
            }

            await Logger.Instance.Initialize();

            Logger.Instance.Log("Logging has been started.");

            Initialize(sheet);
        }
Beispiel #12
0
        public void TestTypeConversion2()
        {
            string data = @"
xxx,yyy,zzz
10,20,2019/1/1
11,21,2019/2/1
";
            var    file = CreateTestFile(data);

            var config = new Config()
            {
                CsvHelperConfiguration = new CsvConfiguration(CultureInfo.CurrentCulture),
                ColumnTypes            = new Dictionary <string, Type>()
                {
                    { "zzz", typeof(DateTime) }
                }
            };

            using (var reader = new StreamReader(file))
                using (var loader = new CsvLoader(reader, config))
                {
                    var dic = loader.LoadToDictionary();
                    Assert.Equal(new string[] { "20", "21" }, dic["yyy"]);
                    Assert.Equal(new DateTime[] { DateTime.Parse("2019/1/1"), DateTime.Parse("2019/2/1") }, dic["zzz"]);
                }
        }
 public void Setup()
 {
     _directoryFinder = Substitute.For <IDirectoryFinder>();
     _configuration   = Substitute.For <IConfiguration>();
     _configuration.GetValue <string>("InputFilesDirectory")
     .Returns("D:\\WTWDIP\\ClaimsReserving\\ClaimsReserving\\InputFiles");
     _target = new CsvLoader(_directoryFinder, _configuration);
 }
Beispiel #14
0
        public void Given_InvalidTypeMapping_Should_ThrowConvertError()
        {
            // wrong positions expected there would be converting error
            string csvLine = "Michael Jordan,23";

            // set ignoreConvertErro = false
            var player = CsvLoader.Map <Player>(csvLine, ignoreConvertError: false);
        }
        public void LoadTest()
        {
            ILogger <CsvLoader> logger      = new NullLogger <CsvLoader>();
            CsvLoader           rssStoreCsv = new CsvLoader(logger);

            var ret = rssStoreCsv.Load <RssSource, RssSourceMap>();

            ret.Should().NotBeNull();
        }
Beispiel #16
0
    public void LoadSequences()
    {
        if (this.sequenceObjectFiles == null)
        {
            this.sequenceObjectFiles = CsvLoader.LoadingFromFile(MagicOrchestraUtils.pathToGame2Sequence);
        }

        // Getting the sequence panel
        GameObject         sequencePanel      = gameObject.transform.GetChild(4).gameObject;
        SequenceObjectFile sequenceObjectFile = sequenceObjectFiles[difficultySlider.GetComponent <DifficultySlider>().GetCurrentDifficulty() - difficultySlider.GetComponent <DifficultySlider>().lowDifficulty];


        // Looping on sequences of the target difficulty
        for (int arrayIndex = 0; arrayIndex < sequenceObjectFile.sequences.Count; arrayIndex++)
        {
            // Getting a sequence
            List <int> currentArray = sequenceObjectFile.sequences[arrayIndex];

            if (sequencePanel.transform.childCount != sequenceObjectFile.sequences.Count)
            {
                // Creating a new toggle
                GameObject toggle = Instantiate(togglePrefab, sequencePanel.transform, false);
                toggle.transform.SetParent(sequencePanel.transform);
                toggle.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f);
                toggle.GetComponent <SequenceToggle>().SetIndex(arrayIndex);

                // Setting toggle group
                toggleGroup.GetComponent <ToggleGroup>().RegisterToggle(toggle.GetComponent <Toggle>());
                toggle.GetComponent <Toggle>().group = toggleGroup.GetComponent <ToggleGroup>();

                // In order to leave only one toggle on
                if (arrayIndex != 0)
                {
                    toggle.GetComponent <Toggle>().isOn = false;
                }

                // Creating the visual sequence
                string stringToWrite = "";
                foreach (int number in currentArray)
                {
                    stringToWrite = stringToWrite + number.ToString() + " ";
                }
                toggle.transform.GetChild(1).gameObject.GetComponent <Text>().text = stringToWrite;
            }
            else
            {
                // Creating the visual sequence
                string stringToWrite = "";
                foreach (int number in currentArray)
                {
                    stringToWrite = stringToWrite + number.ToString() + " ";
                }
                sequencePanel.transform.GetChild(arrayIndex).gameObject.transform.GetChild(1).gameObject.GetComponent <Text>().text = stringToWrite;
            }
        }
    }
Beispiel #17
0
        public MainForm()
        {
            InitializeComponent();

            _loader         = new CsvLoader();
            _graphicService = new GraphicService();
            _state          = new State();
            _chartService   = new ChartService(main_chart, _state);
            _tradeProcess   = new TradeProcess(listBox_Orders, label_BuyResult, _state);
        }
Beispiel #18
0
        public void File3Creates4Rows()
        {
            ICsvLoader loader = new CsvLoader();

            using (FileStream fs = File.OpenRead(file3))
            {
                IEnumerable <Module> results = loader.ReadFromStream(fs);
                Assert.AreEqual(2, results.Count());
            }
        }
    public static void Init()
    {
        CsvLoader csvLoader = new CsvLoader();

        csvLoader.LoadCsv("localization");
        localizedEn = csvLoader.GetDictionaryValues("en");
        localizedPt = csvLoader.GetDictionaryValues("pt");
        language    = DataHandler.instance.selectedLanguage;
        isInit      = true;
    }
Beispiel #20
0
        public void Given_IncorrectColumnIndex_Should_BeableToAvoidIndexOutOfRangeException()
        {
            string csvLine = "23,Michael Jordan";

            var player = CsvLoader.Map <PlayerHasOutBoundaryColumnPosition>(csvLine, ignoreConvertError: false, ignoreIndexOutOfRange: true);

            Assert.IsNotNull(player);
            Assert.AreEqual(player.No, 23);
            Assert.AreEqual(player.Name, "Michael Jordan");
        }
Beispiel #21
0
        public void Given_ValidCsvRow_Should_GetValidEntity()
        {
            string csvLine = "23,Michael Jordan";

            var player = CsvLoader.Map <Player>(csvLine);

            Assert.IsNotNull(player);
            Assert.AreEqual(player.No, 23);
            Assert.AreEqual(player.Name, "Michael Jordan");
        }
Beispiel #22
0
    void Awake()
    {
        //データ取得用のインスタンス
        instance = this;

        //自動読み込み
        if (autoLoad)
        {
            LoadCSV();
        }
    }
Beispiel #23
0
        public void Given_InvalidTypeMapping_Should_BeAbleToIgnoreConvertError()
        {
            // wrong positions expected there would be converting error
            string csvLine = "Michael Jordan,23";

            // set ignoreConvertErro = true to avoid exceptions
            var player = CsvLoader.Map <Player>(csvLine, ignoreConvertError: true);

            Assert.IsNotNull(player);
            Assert.AreEqual(player.No, default(int));
            Assert.AreEqual(player.Name, "23");
        }
Beispiel #24
0
        static void Import()
        {
            var productCsvFile = Path.Combine(Environment.CurrentDirectory, "product.csv");

            using (var storeCtx = new StoreContext())
            {
                var products = CsvLoader.Load <Product>(productCsvFile);
                storeCtx.Database.ExecuteSqlCommand("DELETE [Products]");
                storeCtx.Products.AddRange(products);
                storeCtx.SaveChanges();
            }
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            var csvFilePath = Path.Combine(Environment.CurrentDirectory, "test.csv");
            var products    = CsvLoader.Load <Product>(csvFilePath);

            foreach (var product in products)
            {
                Console.WriteLine(product.ToString());
            }

            Console.ReadKey();
        }
Beispiel #26
0
        [Test] public void Test_loading_lines_without_a_preprocessor()
        {
            var c     = new  CsvLoader <C1>();
            var lines = new [] { "0,1", "2,3" };
            var rows  = c.LoadLines(lines).ToArray();

            Assert.AreEqual(2, rows.Length);
            Assert.AreEqual(0, rows[0].prop1);
            Assert.AreEqual(1, rows[0].prop2);
            Assert.AreEqual(2, rows[1].prop1);
            Assert.AreEqual(3, rows[1].prop2);
        }
Beispiel #27
0
    // CSV データの読み込み
    void LoadCSV()
    {
        starData = CsvLoader <StarData> .LoadData(starDataCSV);

        starMajorData = CsvLoader <StarMajorData> .LoadData(starMajorDataCSV);

        constellationNameData = CsvLoader <ConstellationNameData> .LoadData(constellationNameDataCSV);

        constellationPositionData = CsvLoader <ConstellationPositionData> .LoadData(constellationPositionDataCSV);

        constellationLineData = CsvLoader <ConstellationLineData> .LoadData(constellationLineDataCSV);
    }
Beispiel #28
0
        public void Given_WrongFilePath_ExceptionMessage_Should_ReflectFilePath()
        {
            string invalidFilePath = "\\not-exist-file-path\not-exist.csv";

            try
            {
                CsvLoader.Load <Player>(invalidFilePath);
            }
            catch (FileNotFoundException ex)
            {
                Assert.AreEqual(ex.Message, $"File not found: {invalidFilePath}");
            }
        }
Beispiel #29
0
        private static Task <List <Word> > loadLexiconAsync()
        {
            List <Word> result;

            try
            {
                result = CsvLoader.LoadCSV();
            }
            catch (Exception)
            {
                throw;
            }
            return(Task.FromResult(result));
        }
Beispiel #30
0
        [Test] public void Test_loading_file_without_a_preprocessor()
        {
            var c          = new  CsvLoader <C1>();
            var csvcontent = "prop1,prop2\n0,1\n2,3";
            var file       = "Test_loading_file_without_a_preprocessor.csv";

            File.WriteAllText(file, csvcontent);
            var rows = c.Load(file).ToArray();

            Assert.AreEqual(2, rows.Length);
            Assert.AreEqual(0, rows[0].prop1);
            Assert.AreEqual(1, rows[0].prop2);
            Assert.AreEqual(2, rows[1].prop1);
            Assert.AreEqual(3, rows[1].prop2);
        }
Beispiel #31
0
    public static int Main(string[] args)
    {
        try{
            DirectoryInfo basedir = null;
            if(args.Length < 1){
                basedir = new DirectoryInfo("./");
            } else {
                basedir = new DirectoryInfo(args[0]);
            }
            if(!basedir.Exists){
                Console.WriteLine("Directory not found: {0}", basedir.FullName);
                return 1;
            }
            var csvLoader = new CsvLoader(basedir);
            csvLoader.Execute();

            return 0;
        } catch(Exception e){
            Console.Error.WriteLine(e);
            return 1;
        }
    }