src/Shared/EntityFramework/Core/Common/EntitySql/AST/Literal.cs
// <summary>
// Returns the string literal value.
// </summary>
Returns the string literal value.
Returns the string literal value .
private static string GetStringLiteralValue(string stringLiteralValue, bool isUnicode)
        {
            Debug.Assert(stringLiteralValue.Length >= 2);
            Debug.Assert(isUnicode == ('N' == stringLiteralValue[0]), "invalid string literal value");
            var startIndex = (isUnicode ? 2 : 1);
            var delimiter = stringLiteralValue[startIndex - 1];
            if (delimiter != '\''
                && delimiter != '\"')
            {
                var message = Strings.MalformedStringLiteralPayload;
                throw new EntitySqlException(message);
            }
            var result = "";
            var before = stringLiteralValue.Split(new[] { delimiter }).Length - 1;
            Debug.Assert(before % 2 == 0, "must have an even number of delimiters in the string literal");
            if (0 != (before % 2))
            {
                var message = Strings.MalformedStringLiteralPayload;
                throw new EntitySqlException(message);
            }
             Extract the payload and replace escaped chars that match the envelope delimiter
            result = stringLiteralValue.Substring(startIndex, stringLiteralValue.Length - (1 + startIndex));
            result = result.Replace(new String(delimiter, 2), new String(delimiter, 1));
            var after = result.Split(new[] { delimiter }).Length - 1;
            Debug.Assert(after == (before - 2) / 2);
            if ((after != ((before - 2) / 2)))
            {
                var message = Strings.MalformedStringLiteralPayload;
                throw new EntitySqlException(message);
            }
            return result;
        }
private static string GetStringLiteralValue ( string stringLiteralValue , bool isUnicode ) { Debug . Assert ( stringLiteralValue . Length >= 2 ) ; Debug . Assert ( isUnicode == ( ' ' == stringLiteralValue [ 0 ] ) , " " ) ; var startIndex = ( isUnicode ? 2 : 1 ) ; var delimiter = stringLiteralValue [ startIndex - 1 ] ; if ( delimiter != ' \' ' && delimiter != ' \" ' ) { var message = Strings . MalformedStringLiteralPayload ; throw new EntitySqlException ( message ) ; } var result = " " ; var before = stringLiteralValue . Split ( new [ ] { delimiter } ) . Length - 1 ; Debug . Assert ( before % 2 == 0 , " " ) ; if ( 0 != ( before % 2 ) ) { var message = Strings . MalformedStringLiteralPayload ; throw new EntitySqlException ( message ) ; } result = stringLiteralValue . Substring ( startIndex , stringLiteralValue . Length - ( 1 + startIndex ) ) ; result = result . Replace ( new String ( delimiter , 2 ) , new String ( delimiter , 1 ) ) ; var after = result . Split ( new [ ] { delimiter } ) . Length - 1 ; Debug . Assert ( after == ( before - 2 ) / 2 ) ; if ( ( after != ( ( before - 2 ) / 2 ) ) ) { var message = Strings . MalformedStringLiteralPayload ; throw new EntitySqlException ( message ) ; } return result ; }
Returns the string literal value.
Returns the string literal value .
// NOTE: this is not a precondition validation. This validation is for security purposes based on the  // paranoid assumption that all input is evil. we should not see this exception under normal  // conditions. // NOTE: this is not a precondition validation. This validation is for security purposes based on the  // paranoid assumption that all input is evil. we should not see this exception under normal  // conditions. // // Extract the payload and replace escaped chars that match the envelope delimiter // // NOTE: this is not a precondition validation. This validation is for security purposes based on the  // paranoid assumption that all input is evil. we should not see this exception under normal  // conditions.
stringLiteralValue
string
isUnicode
bool