Пример #1
0
        public bool AddMinerProgram(IMinerProgram program)
        {
            bool      toSave   = false;
            string    algoName = program.MainCoin.Algorithm.Name;
            MinerAlgo algo     = null;

            foreach (MinerAlgo item in MinerAlgos)
            {
                if (item.Name == algoName)
                {
                    algo = item;
                    break;
                }
            }
            if (algo != null)
            {
                MinerProgram prog = new MinerProgram();
                prog.ProgramType = program.Type;
                prog.Exepath     = program.MinerEXE;
                prog.ExeFolder   = program.MinerFolder;

                //if a similar type is alredy present, them remove it
                List <int> removeIds = new List <int>();
                int        i         = 0;
                foreach (MinerProgram item in algo.MinerPrograms)
                {
                    if (item.ProgramType == program.Type)
                    {
                        removeIds.Add(i);
                    }
                    i++;
                }
                foreach (int j in removeIds)
                {
                    algo.MinerPrograms.RemoveAt(j);
                }
                algo.MinerPrograms.Add(prog);
                toSave = true;
            }
            return(toSave);
        }
Пример #2
0
        public bool AddAlgorithms(List <IHashAlgorithm> algorithms)
        {
            bool      toSave       = false;
            Hashtable presentAlgos = new Hashtable();

            foreach (MinerAlgo item in MinerAlgos)
            {
                presentAlgos[item.Name] = item;
            }
            foreach (IHashAlgorithm item in algorithms)
            {
                MinerAlgo algo = presentAlgos[item.Name] as MinerAlgo;
                if (algo == null)
                {
                    algo      = new MinerAlgo();
                    algo.Name = item.Name;
                    MinerAlgos.Add(algo);
                    toSave = true;
                }
            }
            return(toSave);
        }