Esempio n. 1
0
        /// <summary>
        /// Converts an encodeable object to an extension object.
        /// </summary>
        /// <remarks>
        /// Converts an encodeable object to an extension object.
        /// </remarks>
        /// <param name="encodeables">An enumerable array of ExtensionObjects to convert to a collection</param>
        public static ExtensionObjectCollection ToExtensionObjects(IEnumerable <IEncodeable> encodeables)
        {
            // return null if the input list is null.
            if (encodeables == null)
            {
                return(null);
            }

            // convert each encodeable to an extension object.
            ExtensionObjectCollection extensibles = new ExtensionObjectCollection();

            if (encodeables != null)
            {
                foreach (IEncodeable encodeable in encodeables)
                {
                    // check if already an extension object.
                    ExtensionObject extensible = encodeable as ExtensionObject;

                    if (extensible != null)
                    {
                        extensibles.Add(extensible);
                    }

                    // wrap the encodeable with an extension object and let the serializer choose the encoding.
                    else
                    {
                        extensibles.Add(new ExtensionObject(encodeable));
                    }
                }
            }

            return(extensibles);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a deep copy of the collection.
        /// </summary>
        /// <remarks>
        /// Creates a deep copy of the collection.
        /// </remarks>
        public object Clone() {
            ExtensionObjectCollection clone = new ExtensionObjectCollection(this.Count);

            foreach (ExtensionObject element in this) {
                clone.Add((ExtensionObject) Utils.Clone(element));
            }

            return clone;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a deep copy of the collection.
        /// </summary>
        /// <remarks>
        /// Creates a deep copy of the collection.
        /// </remarks>
        public new object MemberwiseClone()
        {
            ExtensionObjectCollection clone = new ExtensionObjectCollection(this.Count);

            foreach (ExtensionObject element in this)
            {
                clone.Add((ExtensionObject)Utils.Clone(element));
            }

            return(clone);
        }