示例#1
0
        /// <summary>
        /// Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string, stripping the trailing null character. If
        /// the string doesn't contain null characters, the empty string is returned.
        /// </summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string</returns>
        public string Format(MappingDataRange dataRange)
        {
            if (dataRange == null)
            {
                throw new ArgumentNullException("dataRange");
            }

            var data = dataRange.GetData();

            if ((data.Length & 1) != 0)
            {
                throw new LinguisticException(LinguisticException.InvalidArgs);
            }

            var nullIndex = data.Length;

            for (var i = 0; i < data.Length; i += 2)
            {
                if (data[i] == 0 && data[i + 1] == 0)
                {
                    nullIndex = i;
                    break;
                }
            }

            var resultText = Encoding.Unicode.GetString(data, 0, nullIndex);

            return(resultText);
        }
示例#2
0
        /// <summary>
        /// Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string.
        /// </summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string</returns>
        public string Format(MappingDataRange dataRange)
        {
            byte[] data       = dataRange.GetData();
            string resultText = Encoding.Unicode.GetString(data);

            return(resultText);
        }
示例#3
0
        /// <summary>
        /// Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string array by splitting on each null character and
        /// removing the empty entries.
        /// </summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string array</returns>
        public string[] Format(MappingDataRange dataRange)
        {
            byte[] data       = dataRange.GetData();
            string resultText = Encoding.Unicode.GetString(data);

            return(resultText.Split(Separator, StringSplitOptions.RemoveEmptyEntries));
        }
示例#4
0
        /// <summary>
        /// Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string array by splitting on each null character and
        /// removing the empty entries.
        /// </summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string array</returns>
        public string[] Format(MappingDataRange dataRange)
        {
            if (dataRange == null)
            {
                throw new ArgumentNullException("dataRange");
            }

            byte[] data       = dataRange.GetData();
            string resultText = Encoding.Unicode.GetString(data);

            return(resultText.Split(Separator, StringSplitOptions.RemoveEmptyEntries));
        }
        /// <summary>Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string.</summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string</returns>
        public string Format(MappingDataRange dataRange)
        {
            if (dataRange == null)
            {
                throw new ArgumentNullException("dataRange");
            }

            var data       = dataRange.GetData();
            var resultText = Encoding.Unicode.GetString(data);

            return(resultText);
        }
示例#6
0
        /// <summary>
        /// Converts a single <see cref="MappingDataRange">MappingDataRange</see> into a string, stripping the trailing null character.
        /// If the string doesn't contain null characters, the empty string is returned.
        /// </summary>
        /// <param name="dataRange">The <see cref="MappingDataRange">MappingDataRange</see> to convert</param>
        /// <returns>The resulting string</returns>
        public string Format(MappingDataRange dataRange)
        {
            byte[] data = dataRange.GetData();
            if ((data.Length & 1) != 0)
            {
                throw new LinguisticException(LinguisticException.E_INVALIDARG);
            }
            int nullIndex = data.Length;

            for (int i = 0; i < data.Length; i += 2)
            {
                if (data[i] == 0 && data[i + 1] == 0)
                {
                    nullIndex = i;
                    break;
                }
            }
            string resultText = Encoding.Unicode.GetString(data, 0, nullIndex);

            return(resultText);
        }