Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The value.</param>
        public ExtendedProperty(ExtendedPropertyTag tag, string value)
        {
            this.tag = tag;

            if (tag.Type == PropertyType.String)
            {
                this.value = System.Text.Encoding.Unicode.GetBytes(value);
            }
            else
            {
                this.value = System.Text.Encoding.UTF8.GetBytes(value);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The value.</param>
        public ExtendedProperty(ExtendedPropertyTag tag, DateTime value)
        {
            this.tag = tag;

            DateTime year1601 = new DateTime(1601, 1, 1);
            TimeSpan timeSpan = value.ToUniversalTime().Subtract(year1601);

            long ticks = timeSpan.Ticks;

            byte[] ticksBytes = BitConverter.GetBytes(ticks);

            this.value = ticksBytes;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The value.</param>
        public ExtendedProperty(ExtendedPropertyTag tag, string[] value)
        {
            this.tag = tag;

            if (value != null && value.Length > 0)
            {
                System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();

                using (memoryStream)
                {
                    uint   count       = (uint)value.Length;
                    byte[] countBuffer = BitConverter.GetBytes(count);

                    memoryStream.Write(countBuffer, 0, countBuffer.Length);

                    for (int i = 0; i < count; i++)
                    {
                        if (tag.Type == PropertyType.String)
                        {
                            byte[] buffer = System.Text.Encoding.Unicode.GetBytes(value[i]);

                            byte[] lengthBuffer = BitConverter.GetBytes(buffer.Length);

                            memoryStream.Write(lengthBuffer, 0, lengthBuffer.Length);
                            memoryStream.Write(buffer, 0, buffer.Length);
                        }
                        else
                        {
                            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(value[i]);

                            byte[] lengthBuffer = BitConverter.GetBytes(buffer.Length);

                            memoryStream.Write(lengthBuffer, 0, lengthBuffer.Length);
                            memoryStream.Write(buffer, 0, buffer.Length);
                        }
                    }

                    this.value = memoryStream.ToArray();
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="value">The value.</param>
 public ExtendedProperty(ExtendedPropertyTag tag, double value)
 {
     this.tag   = tag;
     this.value = BitConverter.GetBytes(value);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 public ExtendedProperty(ExtendedPropertyTag tag)
 {
     this.tag = tag;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 /// <param name="value">The value.</param>
 public ExtendedProperty(ExtendedPropertyTag tag, byte[] value)
 {
     this.tag   = tag;
     this.value = value;
 }
Ejemplo n.º 7
0
        public ExtendedProperty this[ExtendedPropertyTag tag]
        {
            get
            {
                if (tag != null)
                {
                    if (tag is ExtendedPropertyId)
                    {
                        ExtendedPropertyId extendedPropertyId = (ExtendedPropertyId)tag;

                        for (int i = 0; i < this.Count; i++)
                        {
                            ExtendedProperty current = this[i];

                            if (current.Tag is ExtendedPropertyId)
                            {
                                ExtendedPropertyId currentPropertyId = (ExtendedPropertyId)current.Tag;

                                if (currentPropertyId.Id == extendedPropertyId.Id)
                                {
                                    bool isGuidEqual = true;

                                    if (currentPropertyId.Guid != null && extendedPropertyId.Guid != null && currentPropertyId.Guid.Length == extendedPropertyId.Guid.Length)
                                    {
                                        for (int j = 0; j < currentPropertyId.Guid.Length; j++)
                                        {
                                            if (currentPropertyId.Guid[j] != extendedPropertyId.Guid[j])
                                            {
                                                isGuidEqual = false;
                                                break;
                                            }
                                        }
                                    }

                                    if (isGuidEqual)
                                    {
                                        return(current);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ExtendedPropertyName extendedPropertyName = (ExtendedPropertyName)tag;

                        for (int i = 0; i < this.Count; i++)
                        {
                            ExtendedProperty current = this[i];

                            if (current.Tag is ExtendedPropertyName)
                            {
                                ExtendedPropertyName currentPropertyName = (ExtendedPropertyName)current.Tag;

                                if (currentPropertyName.Name == extendedPropertyName.Name)
                                {
                                    bool isGuidEqual = true;

                                    if (currentPropertyName.Guid != null && extendedPropertyName.Guid != null && currentPropertyName.Guid.Length == extendedPropertyName.Guid.Length)
                                    {
                                        for (int j = 0; j < currentPropertyName.Guid.Length; j++)
                                        {
                                            if (currentPropertyName.Guid[j] != extendedPropertyName.Guid[j])
                                            {
                                                isGuidEqual = false;
                                                break;
                                            }
                                        }
                                    }

                                    if (isGuidEqual)
                                    {
                                        return(current);
                                    }
                                }
                            }
                        }
                    }
                }

                return(null);
            }
        }