예제 #1
0
        /// <summary>
        /// Method return list of users
        /// </summary>
        /// <returns></returns>
        public static ListUsers GetUsers()
        {
            if (users.Users == null)
            {
                users = ReadUsersData(userFile);
            }

            return(users);
        }
예제 #2
0
        /// <summary>
        /// Method return list of unregistered users
        /// </summary>
        /// <returns></returns>
        public static ListUsers GetUnregisteUsers()
        {
            if (unregisteredUsers.Users == null)
            {
                unregisteredUsers = ReadUsersData(unregisterUserFile);
            }

            return(users);
        }
예제 #3
0
        /// <summary>
        /// Private method for read data from file 'User.json' and return list of users
        /// </summary>
        /// <returns></returns>
        private static ListUsers ReadUsersData(string fileName)
        {
            string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                                .Replace("\\bin\\Debug", "\\Data");
            string path = Path.Combine(folderPath, fileName);
            string userData;

            using (StreamReader reader = new StreamReader(path))
            {
                userData = reader.ReadToEnd();
            }

            try
            {
                users = JsonConvert.DeserializeObject <ListUsers>(userData);
            }
            catch (JsonException exception)
            {
                Console.WriteLine(exception.Message);
            }

            return(users);
        }