Beispiel #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="OscBundle" /> class.
 /// </summary>
 /// <param name="sourceEndPoint">The packet origin.</param>
 /// <param name="timeStamp">The creation time of the bundle.</param>
 public OscBundleReference(IPEndPoint sourceEndPoint, OscTimeTag timeStamp)
     : base(sourceEndPoint, BundlePrefix)
 {
     TimeStamp = timeStamp;
 }
Beispiel #2
0
 /// <summary>
 ///     Determines whether two specified instances of OscTimeTag are equal.
 /// </summary>
 /// <param name="lhs">An OscTimeTag.</param>
 /// <param name="rhs">An OscTimeTag.</param>
 /// <returns>true if lhs and rhs represent the same time tag; otherwise, false.</returns>
 public static bool Equals(OscTimeTag lhs, OscTimeTag rhs)
 {
     return(lhs.Equals(rhs));
 }
Beispiel #3
0
 /// <summary>
 ///     Returns a value indicating whether this instance is equal to a specified OscTimeTag instance.
 /// </summary>
 /// <param name="value">An object to compare to this instance.</param>
 /// <returns>true if value is an instance of System.DateTime and equals the value of this instance; otherwise, false.</returns>
 public bool Equals(OscTimeTag value)
 {
     return((object)value != null && m_timeStamp.Equals(value.m_timeStamp));
 }
        /// <summary>
        ///     Deserialize a value.
        /// </summary>
        /// <typeparam name="T">The value's data type.</typeparam>
        /// <param name="data">The serialized data source.</param>
        /// <param name="start">The starting index into the serialized data stream.</param>
        /// <returns>The newly deserialized value.</returns>
        public static T ValueFromByteArray <T>(byte[] data, ref int start)
        {
            var    type = typeof(T);
            object value;

            switch (type.Name)
            {
            case "String":
            {
                var count = 0;
                for (var index = start; index < data.Length && data[index] != 0; index++)
                {
                    count++;
                }
                value  = Encoding.ASCII.GetString(data, start, count);
                start += count + 1;
                start  = ((start + 3) / 4) * 4;
                break;
            }

            case "Byte[]":
            {
                var length = ValueFromByteArray <int>(data, ref start);
                var buffer = data.CopySubArray(start, length);

                value  = buffer;
                start += buffer.Length + 1;
                start  = ((start + 3) / 4) * 4;
                break;
            }

            case "OscTimeTag":
            {
                var buffer = data.CopySubArray(start, 8);
                value  = new OscTimeTag(buffer);
                start += buffer.Length;
                break;
            }

            case "Char":
            {
                value = Convert.ToChar(ValueFromByteArray <int>(data, ref start));
                break;
            }

            case "Color":
            {
                var buffer = data.CopySubArray(start, 4);
                start += buffer.Length;

                value = Color.FromArgb(buffer[3], buffer[0], buffer[1], buffer[2]);
                break;
            }

            default:
            {
                value = ByteArrayToNumeric(data, ref start, type);
                break;
            }
            }

            return((T)value);
        }