Load() public method

Loads this instance.
public Load ( ) : bool
return bool
        private static void WriteSingleCredential()
        {
            var credential = new Credential {Target = "Test"};
            credential.Load();

            Console.WriteLine("User name: {0}, Password: {1}", credential.Username, credential.Password);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var credential = new Credential {Target = "Test"};
            credential.Load();

            Console.WriteLine("User name: {0}, Password: {1}", credential.Username, credential.Password);
        }
        public static string GetPassword(Uri targetUri, string username)
        {
            using (Credential creds = new Credential())
            {
                creds.Target = GetTargetString(targetUri, username);
                creds.PersistenceType = PersistenceType.LocalComputer;

                if (creds.Exists())
                {
                    creds.Load();
                    return creds.Password;
                }
                else
                {
                    return null;
                }
            }
        }
        /// <summary>
        ///     Existses this instance.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.InvalidOperationException">Target must be specified to check existance of a credential.</exception>
        public bool Exists()
        {
            CheckNotDisposed();
            UnmanagedCodePermission.Demand();

            if (string.IsNullOrEmpty(Target))
                throw new InvalidOperationException("Target must be specified to check existance of a credential.");

            using (var existing = new Credential {Target = Target, Type = Type})
            {
                return existing.Load();
            }
        }