示例#1
0
        public void Add(string key)
        {
            var duplicate = ValueType.DefaultValue?.DeepClone() ?? JValue.CreateNull();

            JObject jsonObject;

            if (json.Type == JTokenType.Null)
            {
                jsonObject = new JObject();
                json.Replace(jsonObject);
                json = jsonObject;
            }
            else
            {
                jsonObject = (JObject)json;
            }

            jsonObject.Add(key, duplicate);

            if (!KeyValuePairs.TryGetValue(key, out var field))
            {
                field = new EditorKeyValuePair(Session, ValueType, (JProperty)jsonObject[key]);
            }
            KeyValuePairs.Add(key, field);
            Session.InvokeOnChanged();
        }
示例#2
0
        /// <summary>
        /// Update values to either default values or normalize values across key/value pairs
        /// For e.g. If ServicePrincipal is provided and password is provided, we assume password is ServicePrincipalSecret
        /// </summary>
        private void NormalizeKeyValuePairs()
        {
            string clientId, spn, password, spnSecret, userId, aadTenantId;

            KeyValuePairs.TryGetValue(ConnectionStringKeys.AADClientIdKey, out clientId);
            KeyValuePairs.TryGetValue(ConnectionStringKeys.ServicePrincipalKey, out spn);

            KeyValuePairs.TryGetValue(ConnectionStringKeys.UserIdKey, out userId);
            KeyValuePairs.TryGetValue(ConnectionStringKeys.PasswordKey, out password);
            KeyValuePairs.TryGetValue(ConnectionStringKeys.ServicePrincipalSecretKey, out spnSecret);
            KeyValuePairs.TryGetValue(ConnectionStringKeys.AADTenantKey, out aadTenantId);

            //ClientId was provided and servicePrincipal was empty, we want ServicePrincipal to be initialized
            //At some point we will deprecate ClientId keyName
            if (!string.IsNullOrEmpty(clientId) && (string.IsNullOrEmpty(spn)))
            {
                KeyValuePairs[ConnectionStringKeys.ServicePrincipalKey] = clientId;
            }

            //Set the value of PasswordKey to ServicePrincipalSecret ONLY if userId is empty
            //If UserId is not empty, we are not sure if it's a password for inter active login or ServicePrincipal SecretKey
            if (!string.IsNullOrEmpty(password) && (string.IsNullOrEmpty(spnSecret)) && (string.IsNullOrEmpty(userId)))
            {
                KeyValuePairs[ConnectionStringKeys.ServicePrincipalSecretKey] = password;
            }

            //Initialize default value for AADTenent
            if (string.IsNullOrEmpty(aadTenantId))
            {
                KeyValuePairs[ConnectionStringKeys.AADTenantKey] = DEFAULT_TENANTID;
            }
        }
示例#3
0
        internal bool HasNonEmptyValue(string connStrKey)
        {
            string keyValue = string.Empty;

            KeyValuePairs.TryGetValue(connStrKey, out keyValue);

            if (string.IsNullOrEmpty(keyValue))
            {
                return(false);
            }

            return(true);
        }
示例#4
0
 public static KeySender.ScanCodeShort GetKey(string Key)
 {
     KeyValuePairs.TryGetValue(Key, out KeySender.ScanCodeShort KeyCode);
     return(KeyCode);
 }