Exemple #1
0
 public InputModel(InputModelParameters parameters)
 {
     Module           = parameters.Module;
     NodeSet          = parameters.Nodeset;
     Nodepath         = parameters.Nodepath;
     BindingKey       = parameters.BindingKey;
     IsWriteOperation = parameters.IsWriteOperation;
     LoaderType       = parameters.LoaderType;
     KraftGlobalConfigurationSettings = parameters.KraftGlobalConfigurationSettings;
     Client        = new ReadOnlyDictionary <string, object>(UpdateParameters(parameters));
     Server        = new ReadOnlyDictionary <string, object>(parameters.ServerVariables ?? new Dictionary <string, object>());
     SecurityModel = parameters.SecurityModel;
     Data          = new ReadOnlyDictionary <string, object>(parameters.Data);
 }
Exemple #2
0
        private Dictionary <string, object> UpdateParameters(InputModelParameters parameters)
        {
            //Mix all parameter's collections
            Dictionary <string, object> result = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> headerItem in parameters.HeaderCollection ?? new Dictionary <string, object>())
            {
                if (!result.ContainsKey(headerItem.Key))
                {
                    result.Add(headerItem.Key, headerItem.Value);
                }
                else
                {
                    KraftLogger.LogWarning($"Parameter from header-collection {headerItem.Key} with value {headerItem.Value} already exist in the collection and cannot be added.");
                }
            }
            foreach (KeyValuePair <string, object> formItem in parameters.FormCollection ?? new Dictionary <string, object>())
            {
                if (!result.ContainsKey(formItem.Key))
                {
                    result.Add(formItem.Key, formItem.Value);
                }
                else
                {
                    KraftLogger.LogWarning($"Parameter from form-body {formItem.Key} with value {formItem.Value} already exist in the collection and cannot be added.");
                }
            }
            foreach (KeyValuePair <string, object> queryItem in parameters.QueryCollection ?? new Dictionary <string, object>())
            {
                if (!result.ContainsKey(queryItem.Key))
                {
                    result.Add(queryItem.Key, queryItem.Value);
                }
                else
                {
                    KraftLogger.LogWarning($"Parameter from query-string {queryItem.Key} with value {queryItem.Value} already exist in the collection and cannot be added.");
                }
            }
            return(result);
        }