public static void SetValues(this IHasCredentials target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } var credentials = target.TryGetCredentials(); if (credentials == null) { return; } var mappedProperties = CredentialMappedProperty.GetCredentialMappedProperties(target.GetType()); foreach (var mappedProperty in mappedProperties) { if (mappedProperty.Property.GetValue(target) != null) { continue; } mappedProperty.SetValue(target, credentials); } target.CredentialName = null; }
public static ResourceCredentials TryGetCredentials(this IHasCredentials obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } var name = CredentialName.TryParse(obj.CredentialName); if (name == null) { return(null); } var credentialInfo = RompDb.GetCredentialsByName(name.TypeName, name.Name); if (credentialInfo == null) { return(null); } return(Factory.CreateResourceCredentials(credentialInfo)); }