/// <summary> /// Add a literal prefix for the given EdmType. /// </summary> /// <example>filter=MyProperty eq MyCustomLiteral'VALUE'. /// "MyCustomLiteral" is the literal prefix and the <paramref name="literalEdmTypeReference"/> is the type of the "VALUE".</example> /// <param name="literalPrefix">The custom name of the literal prefix</param> /// <param name="literalEdmTypeReference">The edm type of the custom literal</param> /// <exception cref="ArgumentNullException">Arguments are null or empty</exception> /// <exception cref="ArgumentException">The given literal prefix is not valid</exception> /// <exception cref="ODataException">The given literal prefix already exists</exception> public static void AddCustomLiteralPrefix(string literalPrefix, IEdmTypeReference literalEdmTypeReference) { // Arguments validation ExceptionUtils.CheckArgumentNotNull(literalEdmTypeReference, "literalEdmTypeReference"); ExceptionUtils.CheckArgumentStringNotNullOrEmpty(literalPrefix, "literalPrefix"); UriParserHelper.ValidatePrefixLiteral(literalPrefix); // Try to add the custom uri literal to cache lock (Locker) { // Check if literal does already exists if (CustomLiteralPrefixesOfEdmTypes.ContainsKey(literalPrefix)) { throw new ODataException(ODataErrorStrings.CustomUriTypePrefixLiterals_AddCustomUriTypePrefixLiteralAlreadyExists(literalPrefix)); } CustomLiteralPrefixesOfEdmTypes.Add(literalPrefix, literalEdmTypeReference); } }