// Translate the object of key in ODL path to string literal.
        private static string TranslateKeySegmentValue(object value, bool enableUriTemplateParsing)
        {
            if (value == null)
            {
                throw Error.ArgumentNull("value");
            }

            if (enableUriTemplateParsing)
            {
                Semantic.UriTemplateExpression uriTemplateExpression = value as Semantic.UriTemplateExpression;
                if (uriTemplateExpression != null)
                {
                    return(uriTemplateExpression.LiteralText);
                }
            }

            Semantic.ConstantNode constantNode = value as Semantic.ConstantNode;
            if (constantNode != null)
            {
                ODataEnumValue enumValue = constantNode.Value as ODataEnumValue;
                if (enumValue != null)
                {
                    return(ODataUriUtils.ConvertToUriLiteral(enumValue, ODataVersion.V4));
                }
            }

            return(ODataUriUtils.ConvertToUriLiteral(value, ODataVersion.V4));
        }
        /// <summary>
        /// Parse a literal as Uri template.
        /// </summary>
        /// <param name="literalText">The input text.</param>
        /// <param name="expectedType">The expected type of the object which the Uri template stands for.</param>
        /// <param name="expression">The <see cref="UriTemplateExpression"/> representing the Uri template.</param>
        /// <returns>True if successfully expression parsed, false otherwise. </returns>
        internal static bool TryParseLiteral(string literalText, IEdmTypeReference expectedType, out UriTemplateExpression expression)
        {
            if (IsValidTemplateLiteral(literalText))
            {
                expression = new UriTemplateExpression { LiteralText = literalText, ExpectedType = expectedType };
                return true;
            }

            expression = null;
            return false;
        }
        // Translate the node in ODL path to string literal.
        private string TranslateNode(object node)
        {
            if (node == null)
            {
                throw Error.ArgumentNull("node");
            }

            Semantic.ConstantNode constantNode = node as Semantic.ConstantNode;
            if (constantNode != null)
            {
                if (_enableUriTemplateParsing)
                {
                    Semantic.UriTemplateExpression uriTemplateExpression = constantNode.Value as Semantic.UriTemplateExpression;
                    if (uriTemplateExpression != null)
                    {
                        return(uriTemplateExpression.LiteralText);
                    }
                }

                // Make the enum prefix free to work.
                ODataEnumValue enumValue = constantNode.Value as ODataEnumValue;
                if (enumValue != null)
                {
                    return(ODataUriUtils.ConvertToUriLiteral(enumValue, ODataVersion.V4));
                }

                return(constantNode.LiteralText);
            }

            Semantic.ConvertNode convertNode = node as Semantic.ConvertNode;
            if (convertNode != null)
            {
                return(TranslateNode(convertNode.Source));
            }

            Semantic.ParameterAliasNode parameterAliasNode = node as Semantic.ParameterAliasNode;
            if (parameterAliasNode != null)
            {
                return(TranslateParameterAlias(parameterAliasNode.Alias));
            }

            throw Error.NotSupported(
                      SRResources.CannotRecognizeNodeType,
                      typeof(ODataPathSegmentTranslator),
                      node.GetType().FullName);
        }