Dispose() public method

public Dispose ( ) : void
return void
Exemplo n.º 1
0
    public void DataSave(string SaveDirectory, List <GachaData> TargetList, List <string> SaveDatas)
    {
        using (var Writer = new CsvFileWriter(SaveDirectory))
        {
            List <string> Columns = SaveDatas;

            Writer.WriteRow(Columns);
            Columns.Clear();

            Type DataType = typeof(GachaData);

            FieldInfo[] DataInfos = DataType.GetFields(BindingFlags.Instance |
                                                       BindingFlags.NonPublic |
                                                       BindingFlags.Public |
                                                       BindingFlags.NonPublic);

            for (int i = 0; i < TargetList.Count; i++)
            {
                foreach (var f in DataInfos)
                {
                    object TempObject = f.GetValue(TargetList[i]);

                    Columns.Add(TempObject.ToString());
                }

                Writer.WriteRow(Columns);
                Columns.Clear();
            }

            Writer.Dispose();
        }

        Debug.Log("CSV 저장 완료");
    }
Exemplo n.º 2
0
    private void StageDataSave()
    {
        using (var Writer = new CsvFileWriter(Application.dataPath + "/StageData.csv"))
        {
            List <string> Columns = new List <string>()
            {
                "Index", "Level", "Property", "Point", "Exp", "Jewel"
            };

            Writer.WriteRow(Columns);
            Columns.Clear();

            for (int i = 0; i < StageList.Count; i++)
            {
                Columns.Add(StageList[i].Index.ToString());
                Columns.Add(StageList[i].Level.ToString());
                Columns.Add(StageList[i].Property);
                Columns.Add(StageList[i].Point.ToString());
                Columns.Add(StageList[i].Exp.ToString());
                Columns.Add(StageList[i].Jewel.ToString());

                Writer.WriteRow(Columns);
                Columns.Clear();
            }

            Writer.Dispose();
        }
    }
Exemplo n.º 3
0
    public void CharacterDataSave()
    {
        using (var Writer = new CsvFileWriter(Application.dataPath + "/Resources/" + SelectedPickUpList.ToString() + ".csv"))
        {
            List <string> Columns = new List <string>()
            {
                "Name", "Image", "Rank", "Property", "Power", "Appearence", "Weight", "Level", "MaxLevel", "NowExp", "MaxExp", "Enhance"
            };

            Writer.WriteRow(Columns);
            Columns.Clear();

            for (int i = 0; i < Deck.Count; i++)
            {
                Columns.Add(Deck[i].Name);
                Columns.Add(Deck[i].Image.ToString());
                Columns.Add(Deck[i].Rank.ToString());
                Columns.Add(Deck[i].Property.ToString());
                Columns.Add(Deck[i].Power.ToString());
                Columns.Add(Deck[i].Appearence.ToString());
                Columns.Add(Deck[i].Weight.ToString());
                Columns.Add(Deck[i].Level.ToString());
                Columns.Add(Deck[i].MaxLevel.ToString());
                Columns.Add(Deck[i].NowExp.ToString());
                Columns.Add(Deck[i].MaxExp.ToString());
                Columns.Add(Deck[i].Enhance.ToString());

                Writer.WriteRow(Columns);
                Columns.Clear();
            }

            Writer.Dispose();
        }
    }
Exemplo n.º 4
0
        public void CsvSimpleOpen()
        {
            string path   = Path.GetTempFileName();
            var    writer = new CsvFileWriter(new StreamWriter(path));

            writer.Dispose();
        }
Exemplo n.º 5
0
    public void OnClick()
    {
        string strStageIndex = MapManager.instance.GetStageIndex();                      //현재 몇 스테이지 인가 확인

        if (strStageIndex != "")                                                         //인덱스가 받아올 수 있다.
        {
            string strTmp = "Assets/Resources/" + strStageIndex + "Stage_Event_Pos.csv"; //위치에 의한 이벤트
            using (var Writer = new CsvFileWriter(strTmp))                               //using을 쓰고 난 후 해당 영역을 넘어가면 삭제
            {
                List <string> columns = new List <string>()
                {
                    "Index", "LocX", "LocY", "LocZ"
                };
                Writer.WriteRow(columns);
                columns.Clear();

                for (int i = 0; i < m_ListEvent.Count; i++)
                {
                    columns.Add(i.ToString());
                    //해당 차일드의 순서 0, 1, 2 등등
                    columns.Add(m_ListEvent[i].transform.position.x.ToString());
                    columns.Add(m_ListEvent[i].transform.position.y.ToString());
                    columns.Add(m_ListEvent[i].transform.position.z.ToString());
                    //이벤트 이므로 위치만 필요
                    Writer.WriteRow(columns);
                    columns.Clear();
                }
                Debug.Log("EventPos Save Complete");
                Writer.Dispose();
            }

            strTmp = "Assets/Resources/" + strStageIndex + "Stage_Type.csv"; //해당 스테이지의 타입, 노말, 서바이브, 타임 어택
            using (var Writer = new CsvFileWriter(strTmp))                   //using을 쓰고 난 후 해당 영역을 넘어가면 삭제
            {
                List <string> columns = new List <string>()
                {
                    "Type", "Time"
                };
                Writer.WriteRow(columns);
                columns.Clear();

                string strType = MapManager.instance.GetStageType();//현재 스테이지 타입
                columns.Add(strType);

                strType = MapManager.instance.GetTimeLimit();//타임 리미트가 걸렸나?

                columns.Add(strType);
                Writer.WriteRow(columns);

                Debug.Log("StageType Save Complete");
                Writer.Dispose();
            }
        }
        else
        {
            Debug.Log("Event Save Failed");
        }
        //현재 맵에 존재하는 모든 오브젝트의 정보
    }
Exemplo n.º 6
0
 private void DisposeCSVFile(CsvFileWriter file)
 {
     if (file != null)
     {
         file.Dispose();
     }
     file = null;
 }
        public void WhenNullColumnsListThenThrowArgumentNullException()
        {
            using var writer = new CsvFileWriter("SampleWriteTest.csv");

            Exception ex = Assert.Throws <ArgumentNullException>(() => writer.WriteRow(null));

            Assert.Equal("Value cannot be null. (Parameter 'columns')", ex.Message);

            writer.Dispose();
        }
 public void WhenValidColumnsListWithoutSpecialCharacterThenWriteRowToCsv()
 {
     using var writer = new CsvFileWriter("SampleWriteTest.csv");
     // Write each row of data
     for (var row = 0; row < 100; row++)
     {
         var columns = new List <string> {
             "Date Time", "Alert Level", "Alert Message"
         };
         writer.WriteRow(columns);
     }
     writer.Dispose();
 }
Exemplo n.º 9
0
    public void OnClick()
    {
        string strStageIndex = MapManager.instance.GetStageIndex();                  //현재 몇 스테이지 인가 확인

        if (strStageIndex != "")                                                     //인덱스가 받아올 수 있다.
        {
            string strTmp = "Assets/Resources/" + strStageIndex + "Stage_Enemy.csv"; //해당 스테이지의 적들
            using (var Writer = new CsvFileWriter(strTmp))                           //using을 쓰고 난 후 해당 영역을 넘어가면 삭제
            {
                List <string> columns = new List <string>()
                {
                    "Wave", "Prefab", "LocX", "LocY", "LocZ", "QuaW", "QuaX", "QuaY", "QuaZ", "ScaleX", "ScaleY", "ScaleZ"
                };
                Writer.WriteRow(columns);
                columns.Clear();

                for (int i = 0; i < m_ListEnemy.Count; i++)
                {
                    for (int j = 0; j < m_ListEnemy[i].transform.childCount; j++)           //해당 웨이브에 존재하는 적들을 저장
                    {
                        columns.Add(i.ToString());                                          //가장 위쪽 즉, 웨이브
                        GameObject Enemy = m_ListEnemy[i].transform.GetChild(j).gameObject; //해당 웨이브의 하위 오브젝트
                        columns.Add(Enemy.name);
                        columns.Add(Enemy.transform.position.x.ToString());
                        columns.Add(Enemy.transform.position.y.ToString());
                        columns.Add(Enemy.transform.position.z.ToString());
                        //포지션
                        columns.Add(Enemy.transform.rotation.w.ToString());
                        columns.Add(Enemy.transform.rotation.x.ToString());
                        columns.Add(Enemy.transform.rotation.y.ToString());
                        columns.Add(Enemy.transform.rotation.z.ToString());
                        //쿼터니언 회전값
                        columns.Add(Enemy.transform.localScale.x.ToString());
                        columns.Add(Enemy.transform.localScale.y.ToString());
                        columns.Add(Enemy.transform.localScale.z.ToString());
                        //스케일
                        Writer.WriteRow(columns);
                        columns.Clear();
                    }
                }
                Writer.Dispose();
                Debug.Log("Enemy Save Complete");
            }
            Debug.Log("Enemy Save Failed");
        }
        //현재 맵에 존재하는 모든 오브젝트의 정보
    }
Exemplo n.º 10
0
    public void OnClick()
    {
        string strStageIndex = MapManager.instance.GetStageIndex(); //현재 몇 스테이지 인가 확인

        if (strStageIndex != "")                                    //인덱스가 받아올 수 있다.
        {
            string strTmp = "Assets/Resources/" + strStageIndex + "Stage_Map.csv";
            using (var Writer = new CsvFileWriter(strTmp))  //using을 쓰고 난 후 해당 영역을 넘어가면 삭제
            {
                List <string> columns = new List <string>()
                {
                    "Prefab", "LocX", "LocY", "LocZ", "QuaW", "QuaX", "QuaY", "QuaZ", "ScaleX", "ScaleY", "ScaleZ"
                };
                Writer.WriteRow(columns);
                columns.Clear();

                for (int i = 0; i < m_ListMapObject.Count; i++)
                {
                    columns.Add(m_ListMapObject[i].name);
                    //해당 프리펩의 이름
                    columns.Add(m_ListMapObject[i].transform.position.x.ToString());
                    columns.Add(m_ListMapObject[i].transform.position.y.ToString());
                    columns.Add(m_ListMapObject[i].transform.position.z.ToString());
                    //포지션
                    columns.Add(m_ListMapObject[i].transform.rotation.w.ToString());
                    columns.Add(m_ListMapObject[i].transform.rotation.x.ToString());
                    columns.Add(m_ListMapObject[i].transform.rotation.y.ToString());
                    columns.Add(m_ListMapObject[i].transform.rotation.z.ToString());
                    //쿼터니언 회전값
                    columns.Add(m_ListMapObject[i].transform.localScale.x.ToString());
                    columns.Add(m_ListMapObject[i].transform.localScale.y.ToString());
                    columns.Add(m_ListMapObject[i].transform.localScale.z.ToString());
                    //스케일
                    Writer.WriteRow(columns);
                    columns.Clear();
                }
                Writer.Dispose();
                Debug.Log("Map Save Complete");
            }
        }
        else
        {
            Debug.Log("Map Save Failed");
        }
        //현재 맵에 존재하는 모든 오브젝트의 정보
    }
Exemplo n.º 11
0
    public void DataSave()

    /*
     * 현재 List에 저장된 데이터들을 .csv 파일에 저장
     * columns에 각 행의 내용들을 add하고 writer.WriteRow()를 사용해 행을 저장
     */
    {
        var writer = new CsvFileWriter(Application.dataPath + "/Resources/abilities.csv");

        List <string> columns = new List <string>();

        // 첫 행은 data_header
        foreach (dataHeader h in System.Enum.GetValues(typeof(dataHeader)))
        {
            string temp = h.ToString();
            columns.Add(temp);
        }

        writer.WriteRow(columns);
        columns.Clear();

        // 이후 행들은 실제 데이터 삽입
        for (int i = 0; i < abilities.Count; i++)
        {
            columns.Clear();

            foreach (dataHeader h in System.Enum.GetValues(typeof(dataHeader)))
            {
                string header = h.ToString();
                string temp   = abilities[i][header].ToString();
                columns.Add(temp);
            }
            writer.WriteRow(columns);
            columns.Clear();
        }

        writer.Dispose();
        Debug.Log("data saved");
    }
Exemplo n.º 12
0
    public void WriteHighScore()
    {
        CsvFileWriter writer = new CsvFileWriter("000001.csv");
        CsvRow        row    = new CsvRow();

        /*
         *
         *      Method for writing the high score from the game to a single value
         *      in a csv file that is empty so that no other high scores are overwritten.
         *      Enables keeping a temp file, a building file, and one to send to server
         *      (if gets to point of multi-threading and sending requests with multiple clients)
         *
         * Add the players name who belongs to this instantiation of PlayerObject
         * To the first row, and the points score in the second row, Then write the Row
         * to the CsvFileWriter IO and dispose and close the writer to prevent leaks.
         */
        row.Add(playerName);
        row.Add(string.Format("{0}", points));
        Console.Write(string.Format("You scored :{0}", points));
        writer.WriteRow(row);

        writer.Dispose();
        writer.Close();
    }
Exemplo n.º 13
0
    public void FillHighScores()
    {
        //Row to read values from Other files(dataset, new high score in 000001.csv)
        CsvRow readerRow;
        //Row to insert values into CsvFileWriter below for HighScoreFile good copy
        CsvRow row = new CsvRow();
        //Reader Object for New High Score (or old if run early)
        CsvFileReader reader = new CsvFileReader("HighScoreFile.csv");
        //Array of Player Objects to fill with readerRow's values read
        List <PlayerObject> pastPlayers = new List <PlayerObject> ();

        //Loop through the reader till the end
        while (!reader.EndOfStream)
        {
            //if (reader.BaseStream.ReadByte() == -1)
            //	break;
            //Build a new player Object to fill
            PlayerObject obj = new PlayerObject();
            //Instatiate the CsvRow
            readerRow = new CsvRow();
            //Build a string array to hold the CsvRow values
            string[] list = new string[2];
            //Read the rows and Copy the data to the array
            reader.ReadRow(readerRow);
            readerRow.CopyTo(list);
            //Check for "Player" as the first column and skip it
            if (list [0].ToString().Contains("Player"))
            {
                continue;
            }

            //Set player names by formatting the string, and parsing to a float
            obj.setPlayerName(string.Format("{0}", list[0].ToString()));
            obj.setPoints(float.Parse(list [1]));
            //Add the player Object to the array
            pastPlayers.Add(obj);
            readerRow.Clear();
        }        //End of while loop

        reader.Dispose();
        reader.Close();

        //Reader to loop through Dataset for run just taken. Keeps the values safe.
        reader = new CsvFileReader("000001.csv");

        while (!reader.EndOfStream)
        {
            PlayerObject obj = new PlayerObject();
            readerRow = new CsvRow();
            string[] list = new string[2];
            //Read the rows and Copy the data to the array
            reader.ReadRow(readerRow);
            readerRow.CopyTo(list);
            //Set player names by formatting the string, and parsing to a float
            obj.setPlayerName(string.Format("{0}", list [0].ToString()));
            obj.setPoints(float.Parse(list [1]));
            //Add the player Object to the array
            pastPlayers.Add(obj);
            readerRow.Clear();
        }

        reader.Dispose();
        reader.Close();
        //Reader to loop through Dataset given for assignment, which pulls the values
        //of the name of the commodity in the list, and the value of the commodity.
        //It has taken a shortened version, at the behest of Professor Stanley Pieda
        //when asked if I needed to keep the 100K+ file or revise it slightly.

        /*reader = new CsvFileReader ("000000.csv");
         *
         * while(!reader.EndOfStream){
         *
         *      PlayerObject obj = new PlayerObject();
         *      readerRow = new CsvRow();
         *      string[] list = new string[6];
         *
         *      reader.ReadRow (readerRow);
         *      readerRow.CopyTo(list);
         *      obj.setPlayerName(string.Format("{0}", list [2].ToString ()));
         *      obj.setPoints (float.Parse(list[5]));
         *
         *      pastPlayers.Add(obj);
         *      readerRow.Clear ();
         * }
         *
         * reader.Dispose ();
         * reader.Close ();
         */
        //CsvFileWriter Object to write the high score objects to the csv file
        CsvFileWriter writer = new CsvFileWriter("HighScoreFile.csv");

        //Adding the headers for Player and Score in the table
        row.Add(string.Format("Player"));
        row.Add(string.Format("Score"));
        //Writing it to the file, and clearing the row which was written
        writer.WriteRow(row);
        row.Clear();

        pastPlayers.Sort((x, y) => y.points.CompareTo(x.points));
        //Looping through the number of playerObjects in the List. Printing each one
        //To it's own row and clearing that row after it's written.
        for (int i = 0; i < pastPlayers.Count; i++)
        {
            row.Add(string.Format("{0}", pastPlayers[i].getPlayerName()));
            row.Add(string.Format("{0}", pastPlayers[i].getPoints()));
            writer.WriteRow(row);
            row.Clear();
        }
        //Clean up the writers
        writer.Dispose();
        writer.Close();

        //pastPlayers.Sort (0,pastPlayers.Count,pastPlayers [0].points);
    }
Exemplo n.º 14
0
    void WriteRowToCSV(bool sectionChange = false)
    {
        string id    = amaiManager.GetID();
        int    group = amaiManager.GetGroup();
        int    stage = amaiManager.GetStage();
        string now   = System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");

        if (stage < 1)
        {
            return;
        }

        string csvPath = basePath + "/" + id + ".csv";
        List <List <string> > dataGrid = new List <List <string> >();

        if (System.IO.File.Exists(csvPath))
        {
            dataGrid = CsvFileReader.ReadAll(csvPath, Encoding.GetEncoding("gbk"));
        }
        else
        {
            List <string> header = new List <string>()
            {
                "id",
                "group",
                "stage",
                "datetime",
                "emotion_joy",
                "emotion_fear",
                "emotion_disgust",
                "emotion_sadness",
                "emotion_anger",
                "emotion_surprise",
                "emotion_contempt",
                "emotion_valence",
                "emotion_engagement",
                "expression_smile",
                "music_valence_initial",
                "music_valence_overall",
                "music_section_change"
            };
            dataGrid.Add(header);
        }

        CsvFileWriter writer = new CsvFileWriter(csvPath);
        List <string> row    = new List <string> ()
        {
            id,
            group.ToString(),
            stage.ToString(),
            now,
            currentJoy.ToString(),
            currentFear.ToString(),
            currentDisgust.ToString(),
            currentSadness.ToString(),
            currentAnger.ToString(),
            currentSurprise.ToString(),
            currentContempt.ToString(),
            currentValence.ToString(),
            currentEngagement.ToString(),
            currentSmile.ToString(),
            initialValence.ToString(),
            overallValence.ToString(),
            sectionChange ? "1" : "0"
        };

        //writer.WriteRow (row);
        //writer.Dispose ();

        dataGrid.Add(row);
        //CsvFileWriter.WriteAll (dataGrid, csvPath, Encoding.GetEncoding("utf-32"));
        foreach (List <string> r in dataGrid)
        {
            writer.WriteRow(r);
        }
        writer.Dispose();
    }
Exemplo n.º 15
0
    //Start Function
    public static void Run(string[] args)
    {
        try
        {
            Console.WriteLine("-------------------------------START--------------------------------");

            Parser.Default.ParseArguments <Options>(args).WithParsed <Options>(o =>
            {
                List <string> Targets = TargetParsing(o.TargetString);
                if (Targets == null)
                {
                    Console.WriteLine("Error: Targets is null");
                }

                if (o.Verbose && !o.SkipDetection)
                {
                    Console.WriteLine("Pinging target list to identify live systems");
                }

                if (!o.SkipDetection)
                {
                    Targets = LiveTargetDetection(Targets);
                }

                if (o.Verbose)
                {
                    Console.WriteLine("-----------------------------PARAMETERS-----------------------------");
                    Console.WriteLine("Targets: {0}", string.Join(",", Targets));
                    Console.WriteLine("Poll Amount: {0}", o.PollAmount);
                    Console.WriteLine("Will Poll for {0} minutes (30 second poll frequency * poll amount)", o.PollAmount * 0.5);
                    Console.WriteLine("--------------------------------------------------------------------");
                }

                Console.WriteLine("Creating profiles.csv with target information");
                foreach (string Target in Targets.ToArray())
                {
                    if (o.Verbose)
                    {
                        Console.WriteLine("Populating profiles.csv for {0}", Target);
                    }

                    ManagementScope msTargetScope = ScopeConnect("\\\\" + Target + "\\root\\Cimv2", 1);
                    if (msTargetScope != null)
                    {
                        CsvFileWriter writer = new CsvFileWriter("profiles.csv", true);
                        GenerateTargetCSV(msTargetScope, writer);
                        writer.Dispose();
                    }
                    else
                    {
                        Console.WriteLine("Error connecting to {0}", Target);
                        if (o.AutoRemove)
                        {
                            if (o.Verbose)
                            {
                                Console.WriteLine("Removing {0} from target list ", Target);
                            }
                            Targets.Remove(Target);
                        }
                    }
                }

                Console.WriteLine("Creating networkconnections.csv with connection information");
                int iCounter = 0;
                while (iCounter < o.PollAmount && Targets.Count != 0)
                {
                    foreach (string Target in Targets.ToArray())
                    {
                        if (o.Verbose)
                        {
                            Console.WriteLine("Populating networkconnections.csv for {0}", Target);
                        }
                        ManagementScope msConnectionScope = ScopeConnect("\\\\" + Target + "\\root\\StandardCimv2", 1);
                        if (msConnectionScope != null)
                        {
                            CsvFileWriter writer = new CsvFileWriter("networkconnections.csv", true);
                            CollectNetworkConnections(msConnectionScope, writer);
                            writer.Dispose();
                        }
                        else
                        {
                            Console.WriteLine("Error connecting to {0}", Target);
                            if (o.AutoRemove)
                            {
                                if (o.Verbose)
                                {
                                    Console.WriteLine("Removing {0} from target list ", Target);
                                }
                                Targets.Remove(Target);
                            }
                        }
                    }
                    Thread.Sleep(30000);
                    iCounter++;
                }
            });
            return;
        }
        catch (Exception e)
        {
            Console.WriteLine("{0} Expection Caught.", e);
        }
    }
Exemplo n.º 16
0
 public virtual void StopLogger()
 {
     csvWriter.Dispose();
 }