forked from briandunnington/growl-for-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ee1234
commit 74f27c9
Showing
63 changed files
with
15,346 additions
and
1,310 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Growl Extras/Growl Display SDK/libraries/Growl.CoreLibrary.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Growl Extras/Growl Display SDK/libraries/Growl.DisplayStyle.dll
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Growl.CoreLibrary | ||
{ | ||
/// <summary> | ||
/// Helper class for converting basic data types to a byte array. | ||
/// This class is similar to the <see cref="StringBuilder"/> class. | ||
/// </summary> | ||
public class ByteBuilder | ||
{ | ||
protected List<byte> byteList = new List<byte>(); | ||
protected bool isLittleEndian = BitConverter.IsLittleEndian; | ||
|
||
/// <summary> | ||
/// Appends a single byte to the array | ||
/// </summary> | ||
/// <param name="val">The byte to append</param> | ||
public void Append(byte val) | ||
{ | ||
this.byteList.Add(val); | ||
} | ||
|
||
/// <summary> | ||
/// Appends an array of bytes to the array | ||
/// </summary> | ||
/// <param name="val">The bytes to append</param> | ||
public void Append(byte[] val) | ||
{ | ||
this.byteList.AddRange(val); | ||
} | ||
|
||
/// <summary> | ||
/// Appends a string as an array of UTF8-encoded bytes | ||
/// </summary> | ||
/// <param name="val">The string to append</param> | ||
public void Append(string val) | ||
{ | ||
if (val != null) | ||
this.byteList.AddRange(Encoding.UTF8.GetBytes(val)); | ||
} | ||
|
||
/// <summary> | ||
/// Appends an <see cref="int"/> as a 4-byte array using Big Endian encoding | ||
/// </summary> | ||
/// <param name="val">The number to append</param> | ||
public void Append(int val) | ||
{ | ||
byte[] b = BitConverter.GetBytes(val); | ||
if (this.isLittleEndian) Array.Reverse(b); | ||
this.byteList.AddRange(b); | ||
} | ||
|
||
/// <summary> | ||
/// Appends a <see cref="short"/> as a 2-byte array using Big Endian encoding | ||
/// </summary> | ||
/// <param name="val">The number to append</param> | ||
public void Append(short val) | ||
{ | ||
byte[] b = BitConverter.GetBytes(val); | ||
if(this.isLittleEndian) Array.Reverse(b); | ||
this.byteList.AddRange(b); | ||
} | ||
|
||
/// <summary> | ||
/// Appends a <see cref="long"/> as a 8-byte array using Big Endian encoding | ||
/// </summary> | ||
/// <param name="val">The number to append</param> | ||
public void Append(long val) | ||
{ | ||
byte[] b = BitConverter.GetBytes(val); | ||
if (this.isLittleEndian) Array.Reverse(b); | ||
this.byteList.AddRange(b); | ||
} | ||
|
||
/// <summary> | ||
/// Returns all of the bytes as an array | ||
/// </summary> | ||
/// <returns>Array of <see cref="byte"/>s</returns> | ||
public byte[] GetBytes() | ||
{ | ||
return this.byteList.ToArray(); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the number of bytes making up the string | ||
/// </summary> | ||
/// <param name="val">The string whose length you want</param> | ||
/// <returns>The number of bytes making up the string (NOT the number of characters, since some characters will require 2 bytes)</returns> | ||
public static short GetStringLengthAsShort(string val) | ||
{ | ||
return (short) Encoding.UTF8.GetBytes(val).Length; | ||
} | ||
} | ||
} |
Oops, something went wrong.