private Dictionary <string, string> CreateDictionary(XElement element, APIXmlNode Base = null, bool Querystring = false, bool header = false) { Dictionary <string, string> dict = new Dictionary <string, string>(); if (element != null) { foreach (var item in element.Elements()) { if (item.Attribute("Key") != null && item.Attribute("Value") != null) { dict.Add(item.Attribute("Key").Value, item.Attribute("Value").Value); } } } if (!IncludeKeyFromBase.Empty() && Base != null) { if ((KeyPlacement == APIKeyPlacement.QUERYSTRING && Querystring && !header) || (KeyPlacement == APIKeyPlacement.BODY && !Querystring && !header) || (KeyPlacement == APIKeyPlacement.HEADER && !Querystring && header)) { dict.Add(IncludeKeyFromBase, Base.ApiKey); IncludeKeyFromBase = ""; //empty it there after so that it does not repeat addition. } } return(dict); }
private void ValidityChecks(string baseUrl) { if (BaseUrl.Empty()) { BaseUrl = baseUrl; } if (!Token.Empty()) { RequiredAuthorization = true; } if (Name.Empty()) { Name = $"{Prefix}{Guid.NewGuid()}{Postfix}"; Cache = false; } //Caching is not possible without a name if (IncludeKeyFromBase.Empty()) { IncludeKeyFromBase = null; } if (!RequiredAuthorization) { AuthenticationType = APIAuthenticationType.Basic; Token = null; TokenAsHeader = false; } if (ParametersQuery != null && ParametersQuery.Count <= 0) { ParametersQuery = null; } if (ParametersBody != null && ParametersBody.Count <= 0) { ParametersBody = null; ParameterContentType = null; } if (Headers != null && Headers.Count <= 0) { Headers = null; } if (ContentTypes.Empty()) { ContentTypes = null; } }