示例#1
0
        //!banned SPECIFIC HANDLING. WE JUST HANDLE MORE VARIABLES HERE.
        public static void BannedXML(string command, string who, float days, int amount)
        {
            XMLRead.BannedReadXML(who);
            int   initialAmount = XMLRead.commandAmountRead;
            float initialDays   = XMLRead.daysRead;

            GankCommandInfo overview = new GankCommandInfo();

            overview.who           = command;
            overview.commandAmount = initialAmount + amount;
            overview.days          = initialDays + days; //ADD TO THE TOTAL DAYS COUNT
            overview.victim        = who;                //SETTING A VICTIM

            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(GankCommandInfo));

            //AS THIS IS BANNED SPECIFIC WE PREDEFINE BANNED, AND INSTEAD USE THE VICTIM TO CHANGE THE FILENAME
            string whopath = "//gankbot/banned" + who + "BotVariables.xml";
            var    path    = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + whopath;

            System.IO.FileStream file = System.IO.File.Create(path);

            writer.Serialize(file, overview);
            file.Close();
        }
示例#2
0
        //SAME AS ABOVE BUT WE PERFORM A FILE READ BEFORE HAND TO GET CORRECT AMOUNT VALUES.
        public static void ReadThenWrite(string who, int amount)
        {
            XMLRead.ReadXML(who); //READ THE FILE
            int initialAmount = XMLRead.commandAmountRead;

            GankCommandInfo overview = new GankCommandInfo();

            overview.who           = who;
            overview.commandAmount = initialAmount + amount; //<<<< --- THIS IS CHANGED TO ADD TO THE PREVIOUS AMOUNT
            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(GankCommandInfo));
            string whopath = "//gankbot/" + who + "BotVariables.xml";
            var    path    = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + whopath;

            System.IO.FileStream file = System.IO.File.Create(path);

            writer.Serialize(file, overview);
            file.Close();
        }