Пример #1
0
        public static bool AddRobot(RobotConfig robot)
        {
            if (_instance == null)
            {
                throw new Exception("Create instance first before accessing method.");
            }

            if (_instance._robotConfigs.Count(T => T.Id == robot.Id) > 0)
            {
                return(false);
            }

            try
            {
                _instance._robotConfigs.Add(robot);

                Save();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
        public static bool ModifyRobot(RobotConfig previous, RobotConfig current)
        {
            if (_instance == null)
            {
                throw new Exception("Create instance first before accessing method.");
            }

            if (previous == null)
            {
                return(false);
            }

            try
            {
                var index = _instance._robotConfigs.IndexOf(previous);

                _instance._robotConfigs[index] = current;

                Save();

                return(true);
            }
            catch
            {
                return(false);
            }
        }