Пример #1
0
        /// <summary>
        /// Gets a property ID associated with the name
        /// </summary>
        /// <remarks>
        /// <para>
        /// Property IDs are specific to a context and cannot be used across contexts.
        /// </para>
        /// <para>
        /// Requires an active script context.
        /// </para>
        /// </remarks>
        /// <param name="name">The name of the property ID to get or create.
        /// The name may consist of only digits.</param>
        /// <returns>The property ID in this runtime for the given name</returns>
        public static JsPropertyId FromString(string name)
        {
            string processedName;
            int    byteCount;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                processedName = EncodingHelpers.UnicodeToAnsi(name, out byteCount);
            }
            else
            {
                processedName = name;
                byteCount     = Encoding.UTF8.GetByteCount(processedName);
            }

            JsPropertyId id;
            UIntPtr      length = new UIntPtr((uint)byteCount);

            JsErrorCode errorCode = NativeMethods.JsCreatePropertyId(processedName, length, out id);

            JsErrorHelpers.ThrowIfError(errorCode);

            return(id);
        }
Пример #2
0
 static HunspellTests()
 {
     EncodingHelpers.EnsureEncodingsReady();
 }
Пример #3
0
 public static void Main(string[] args)
 {
     var encoding = EncodingHelpers.GetShiftJis();
 }
Пример #4
0
        public void FromBase64ToBytes_NullString()
        {
            string _nullString = null;

            Assert.Throws <ArgumentNullException>(() => EncodingHelpers.FromBase64ToBytes(_nullString));
        }
Пример #5
0
        public void FromBase64_NonBase64String()
        {
            string _nonBase64String = "abc";

            Assert.Throws <FormatException>(() => EncodingHelpers.ToBase64(EncodingHelpers.FromBase64(_nonBase64String)));
        }
Пример #6
0
 public void FromBase64_Base64String(string encodedString)
 {
     Assert.AreEqual(encodedString, EncodingHelpers.ToBase64(EncodingHelpers.FromBase64(encodedString)));
 }
Пример #7
0
 /// <summary>
 /// Decodes a logical time stored within the specified bufferStream,
 /// returning a <code>ILogicalTime</code> object corresponding to
 /// the decoded parameterValue.
 /// </summary>
 /// <param name="bufferStream">the bufferStream that contains the encoded parameterValue
 /// </param>
 /// <param name="offset">the offset within the bufferStream at which the
 /// encoded parameterValue is stored
 /// </param>
 /// <returns> a new <code>ILogicalTime</code> representing the
 /// decoded parameterValue
 /// </returns>
 /// <exception cref="CouldNotDecode"> if the parameterValue could not be decoded
 /// </exception>
 public virtual ILogicalTime Decode(byte[] buffer, int offset)
 {
     return(new LongValuedLogicalTime(EncodingHelpers.DecodeLong(buffer, offset)));
 }
 /// <summary>
 /// Decodes a logical time interval stored within the specified
 /// bufferStream, returning a corresponding new <code>ILogicalTimeInterval</code>.
 /// </summary>
 /// <param name="bufferStream">the bufferStream containing the encoded interval
 /// </param>
 /// <param name="offset">the offset within the bufferStream at which the encoded
 /// interval is stored
 /// </param>
 /// <returns> a new <code>ILogicalTimeInterval</code> corresponding to the
 /// encoded interval
 /// </returns>
 /// <exception cref="CouldNotDecode"> if the time interval could not be decoded
 /// </exception>
 public virtual ILogicalTimeInterval Decode(byte[] buffer, int offset)
 {
     return(new DoubleValuedLogicalTimeInterval(EncodingHelpers.DecodeDouble(buffer, offset)));
 }
Пример #9
0
 public void ToBase64_String(string plainText)
 {
     Assert.AreEqual(plainText, EncodingHelpers.FromBase64(EncodingHelpers.ToBase64(plainText)));
 }
Пример #10
0
 public void ToBase64_NullByteArray()
 {
     Assert.Throws <ArgumentNullException>(() => EncodingHelpers.ToBase64(_nullByteArray));
 }
Пример #11
0
        public void ToBase64_NullString()
        {
            string _nullString = null;

            Assert.Throws <ArgumentNullException>(() => EncodingHelpers.ToBase64(_nullString));
        }
Пример #12
0
 public void TryBase64Decode_NonBase64String()
 {
     Assert.IsFalse(EncodingHelpers.TryBase64Decode(_nonBase64String, out string decodedValue));
 }
Пример #13
0
 public void TryBase64Decode_Base64String(string encodedString)
 {
     Assert.IsTrue(EncodingHelpers.TryBase64Decode(encodedString, out string decodedValue));
 }
Пример #14
0
        public void TryBase64Decode_NullString()
        {
            string _nullString = null;

            Assert.IsFalse(EncodingHelpers.TryBase64Decode(_nullString, out string decodedValue));
        }
Пример #15
0
 public void Encode(string chars, int index, int count, byte[] expected) =>
 EncodingHelpers.Encode(new CustomEncoding(), chars, index, count, expected);
Пример #16
0
 public void Decode(byte[] bytes, int index, int count, string expected) =>
 EncodingHelpers.Decode(new CustomEncoding(), bytes, index, count, expected);
Пример #17
0
 public void ToBase64_NonEmptyByteArray()
 {
     Assert.AreEqual(_nonEmptyByteArray, EncodingHelpers.FromBase64ToBytes(EncodingHelpers.ToBase64(_nonEmptyByteArray)));
 }
        /// <summary>
        /// Encodes this logical time interval, placing the result into the
        /// specified bufferStream.
        /// </summary>
        /// <param name="bufferStream">the bufferStream in which to place the encoded interval
        /// </param>
        /// <param name="offset">the offset within the bufferStream at which to store
        /// the encoded interval
        /// </param>
        public virtual void Encode(byte[] buffer, int offset)
        {
            byte[] encodedValue = EncodingHelpers.EncodeLong(val);

            Array.Copy(encodedValue, 0, buffer, offset, encodedValue.Length);
        }
Пример #19
0
 public void FromBase64_NullString()
 {
     Assert.Throws <ArgumentNullException>(() => EncodingHelpers.FromBase64(_nullString));
 }