EddiCompanionAppService.CompanionAppCredentials.ToFile C# (CSharp) Method

ToFile() public method

Obtain credentials to a file. If the filename is not supplied then the path used when reading in the credentials will be used, or the default path of Constants.Data_DIR\credentials.json will be used
public ToFile ( string filename = null ) : void
filename string
return void
        public void ToFile(string filename=null)
        {
            if (filename == null)
            {
                filename = dataPath;
            }
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\credentials.json";
            }

            string json = JsonConvert.SerializeObject(this, Formatting.Indented);
            File.WriteAllText(filename, json);
        }
    }

Usage Example

コード例 #1
0
 /// <summary>
 /// Log out of the companion API and remove local credentials
 /// </summary>
 public void Logout()
 {
     // Remove everything other than the local email address
     Credentials = CompanionAppCredentials.FromFile();
     Credentials.machineToken = null;
     Credentials.machineId    = null;
     Credentials.appId        = null;
     Credentials.password     = null;
     Credentials.ToFile();
     CurrentState = State.NEEDS_LOGIN;
 }
All Usage Examples Of EddiCompanionAppService.CompanionAppCredentials::ToFile
CompanionAppCredentials