Esempio n. 1
0
 /// <summary>
 /// Formats part of the URI, which specifies all key and value pairs
 /// </summary>
 /// <param name="referenceByKeys">part of the URI, which specifies all key and value pairs</param>
 /// <param name="format">Format of the key name/value pair in the uri</param>
 /// <returns>formated key/value pair string</returns>
 protected override string FormatODataReferenceByKeys(string referenceByKeys, UriResourcePathKeyFormat format)
 {
     if (format == UriResourcePathKeyFormat.EmbeddedKey && !referenceByKeys.StartsWith("(", StringComparison.Ordinal) && !referenceByKeys.EndsWith(")", StringComparison.Ordinal))
     {
         return("(" + referenceByKeys + ")");
     }
     else
     {
         return(referenceByKeys);
     }
 }
Esempio n. 2
0
        public override string GetODataReferenceByKeys(List <Tuple <string, object> > keys)
        {
            if (keys == null)
            {
                throw new ArgumentNullException("keys");
            }
            string result = String.Empty;

            if (keys.Count == 0)
            {
                return(result);
            }

            // EmbeddedKey is the default uri resource path construction convention
            UriResourcePathKeyFormat format    = UriResourcePathKeyFormat.EmbeddedKey;
            string UriResourcePathKeyFormatStr = String.Empty;

            if (PrivateData != null &&
                true == PrivateData.TryGetValue("UriResourcePathKeyFormat", out UriResourcePathKeyFormatStr) &&
                !UriResourcePathKeyFormatStr.Equals(format.ToString()))
            {
                format = UriResourcePathKeyFormat.SeparateKey;
            }

            if (format == UriResourcePathKeyFormat.SeparateKey)
            {
                foreach (var key in keys)
                {
                    // Redfish Service (ODataV4) services URI construction convention supports format
                    // where the key value is specified, but not the key name.
                    result += "/" + key.Item2;
                }
            }
            else
            {
                result = base.GetODataReferenceByKeys(keys);
            }

            return(FormatODataReferenceByKeys(result, format));
        }