/// <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); }
static HunspellTests() { EncodingHelpers.EnsureEncodingsReady(); }
public static void Main(string[] args) { var encoding = EncodingHelpers.GetShiftJis(); }
public void FromBase64ToBytes_NullString() { string _nullString = null; Assert.Throws <ArgumentNullException>(() => EncodingHelpers.FromBase64ToBytes(_nullString)); }
public void FromBase64_NonBase64String() { string _nonBase64String = "abc"; Assert.Throws <FormatException>(() => EncodingHelpers.ToBase64(EncodingHelpers.FromBase64(_nonBase64String))); }
public void FromBase64_Base64String(string encodedString) { Assert.AreEqual(encodedString, EncodingHelpers.ToBase64(EncodingHelpers.FromBase64(encodedString))); }
/// <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))); }
public void ToBase64_String(string plainText) { Assert.AreEqual(plainText, EncodingHelpers.FromBase64(EncodingHelpers.ToBase64(plainText))); }
public void ToBase64_NullByteArray() { Assert.Throws <ArgumentNullException>(() => EncodingHelpers.ToBase64(_nullByteArray)); }
public void ToBase64_NullString() { string _nullString = null; Assert.Throws <ArgumentNullException>(() => EncodingHelpers.ToBase64(_nullString)); }
public void TryBase64Decode_NonBase64String() { Assert.IsFalse(EncodingHelpers.TryBase64Decode(_nonBase64String, out string decodedValue)); }
public void TryBase64Decode_Base64String(string encodedString) { Assert.IsTrue(EncodingHelpers.TryBase64Decode(encodedString, out string decodedValue)); }
public void TryBase64Decode_NullString() { string _nullString = null; Assert.IsFalse(EncodingHelpers.TryBase64Decode(_nullString, out string decodedValue)); }
public void Encode(string chars, int index, int count, byte[] expected) => EncodingHelpers.Encode(new CustomEncoding(), chars, index, count, expected);
public void Decode(byte[] bytes, int index, int count, string expected) => EncodingHelpers.Decode(new CustomEncoding(), bytes, index, count, expected);
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); }
public void FromBase64_NullString() { Assert.Throws <ArgumentNullException>(() => EncodingHelpers.FromBase64(_nullString)); }