コード例 #1
0
 /// <summary>
 /// Instantiates the connection helper with user credentials
 /// </summary>
 /// <param name="instanceUrl"></param>
 /// <param name="username"></param>
 /// <param name="password"></param>
 public ConnectionHelper(string instanceUrl, string username, string password)
 {
     _baseUrl  = instanceUrl;
     _user     = username;
     _password = password;
     _authType = Constants.Enums.AuthType.UsernamePassword;
 }
コード例 #2
0
        /// <summary>
        /// Instantiate with path to credentials file in the format:
        /// InstanceUrl
        /// Relativity username
        /// Relativity password
        /// </summary>
        /// <param name="filePath"></param>
        public ConnectionHelper(string filePath)
        {
            try
            {
                string[] creds = File.ReadAllLines(filePath);

                if (creds.Length == 1)
                {
                    Console.WriteLine("Using IntegratedAuth");
                    _baseUrl  = creds[0];
                    _authType = Constants.Enums.AuthType.Integrated;
                }
                else if (creds.Length == 3)
                {
                    _baseUrl  = creds[0];
                    _user     = creds[1];
                    _password = creds[2];
                    Console.WriteLine("Using UsernamePassword");
                    _authType = Constants.Enums.AuthType.UsernamePassword;
                }

                else
                {
                    throw new ApplicationException($"File at {filePath} does not contain the correct number of lines.");
                }
            }

            catch (IOException)
            {
                Console.WriteLine("Specified credentials file not found.");
                throw;
            }
        }