Beispiel #1
0
        /// <summary>
        /// This is overridden to allow proper comparison of property objects
        /// </summary>
        /// <param name="obj">The object to which this instance is compared</param>
        /// <returns>Returns true if the object equals this instance, false if it does not</returns>
        public override bool Equals(object obj)
        {
            BaseProperty bp = obj as BaseProperty;

            if (bp == null)
            {
                return(false);
            }

            // The ToString() method returns a text representation of the property based on all of its settings
            // so it's a reliable way to tell if two instances are the same.
            return(this == bp || this.ToString() == bp.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// This is overridden to allow copying values from the specified PDI object into the instance
        /// </summary>
        /// <param name="p">The PDI object from which the settings are to be copied</param>
        /// <remarks>Derived classes must call this method to copy the standard PDI object properties.  It only
        /// needs to be overridden if the derived class has additional properties.</remarks>
        protected override void Clone(PDIObject p)
        {
            BaseProperty o = (BaseProperty)p;

            if (o.Version != SpecificationVersions.None)
            {
                this.Version = o.Version;
            }

            this.Group            = o.Group;
            this.EncodingMethod   = o.EncodingMethod;
            this.CharacterSet     = o.CharacterSet;
            this.Language         = o.Language;
            this.ValueLocation    = o.ValueLocation;
            this.CustomParameters = o.CustomParameters;
            this.Value            = o.Value;
        }
Beispiel #3
0
        /// <summary>
        /// This is a helper method that converts a property to its string form and writes it to the given text
        /// writer.
        /// </summary>
        /// <param name="prop">The property to use.</param>
        /// <param name="sb"><para>A <see cref="System.Text.StringBuilder"/> used by the property to convert
        /// itself to a string.  This is a shared instance used by all properties written to the text writer.  It
        /// is cleared before the specified property is converted.</para>
        ///
        /// <para>It can be null if the TextWriter is a <see cref="System.IO.StringWriter"/>.  In that case, the
        /// property will append itself directly to its StringBuilder instead.</para></param>
        /// <param name="tw">A <see cref="System.IO.TextWriter"/> to which the string form is written.</param>
        /// <remarks>Properties use a StringBuilder to convert themselves to a string rather than writing
        /// directly to the TextWriter as they may need to manipulate the string to fold lines, etc.</remarks>
        /// <exception cref="InvalidCastException">This is thrown if the StringBuilder parameter is null and the
        /// TextWriter is not a StringWriter.</exception>
        public static void WriteToStream(BaseProperty prop, StringBuilder sb, TextWriter tw)
        {
            if (prop != null)
            {
                if (sb != null)
                {
                    sb.Length = 0;
                    prop.ToString(sb);

                    if (sb.Length != 0)
                    {
                        tw.Write(sb.ToString());
                    }
                }
                else
                {
                    prop.ToString(((StringWriter)tw).GetStringBuilder());
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// This is a helper method that converts a property to its string form and writes it to the given text
        /// writer.
        /// </summary>
        /// <param name="prop">The property to use.</param>
        /// <param name="sb"><para>A <see cref="System.Text.StringBuilder"/> used by the property to convert
        /// itself to a string.  This is a shared instance used by all properties written to the text writer.  It
        /// is cleared before the specified property is converted.</para>
        /// 
        /// <para>It can be null if the TextWriter is a <see cref="System.IO.StringWriter"/>.  In that case, the
        /// property will append itself directly to its StringBuilder instead.</para></param>
        /// <param name="tw">A <see cref="System.IO.TextWriter"/> to which the string form is written.</param>
        /// <remarks>Properties use a StringBuilder to convert themselves to a string rather than writing
        /// directly to the TextWriter as they may need to manipulate the string to fold lines, etc.</remarks>
        /// <exception cref="InvalidCastException">This is thrown if the StringBuilder parameter is null and the
        /// TextWriter is not a StringWriter.</exception>
        public static void WriteToStream(BaseProperty prop, StringBuilder sb, TextWriter tw)
        {
            if(prop != null)
                if(sb != null)
                {
                    sb.Length = 0;
                    prop.ToString(sb);

                    if(sb.Length != 0)
                        tw.Write(sb.ToString());
                }
                else
                    prop.ToString(((StringWriter)tw).GetStringBuilder());
        }