Artemis.DAL.ProfileProvider.LoadProfileIfValid C# (CSharp) Method

LoadProfileIfValid() public static method

Attempts to load a profile from a given path
public static LoadProfileIfValid ( string path ) : ProfileModel
path string The absolute path to load the profile from
return Artemis.Profiles.ProfileModel
        public static ProfileModel LoadProfileIfValid(string path)
        {
            try
            {
                var prof = JsonConvert.DeserializeObject<ProfileModel>(File.ReadAllText(path));
                if (prof == null)
                    return null;
                if (prof.GameName.Length < 1 || prof.KeyboardSlug.Length < 1 || prof.Name.Length < 1)
                    return null;
                return prof;
            }
            catch (JsonSerializationException)
            {
                return null;
            }
        }