Beispiel #1
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            VNote o = new VNote();

            o.Clone(this);
            return(o);
        }
Beispiel #2
0
        /// <summary>
        /// This is overridden to allow proper comparison of vNote 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)
        {
            VNote vn = obj as VNote;

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

            // The ToString() method returns a text representation of the vNote based on all of its settings so
            // it's a reliable way to tell if two instances are the same.
            return(this == vn || this.ToString() == vn.ToString());
        }
Beispiel #3
0
        /// <summary>
        /// This is overridden to allow copying of the additional properties
        /// </summary>
        /// <param name="p">The PDI object from which the settings are to be copied</param>
        protected override void Clone(PDIObject p)
        {
            VNote o = (VNote)p;

            this.ClearProperties();

            dateCreated    = (DateCreatedProperty)o.DateCreated.Clone();
            lastModified   = (LastModifiedProperty)o.LastModified.Clone();
            summary        = (SummaryProperty)o.Summary.Clone();
            body           = (BodyProperty)o.Body.Clone();
            classification = (ClassificationProperty)o.Classification.Clone();
            categories     = (CategoriesProperty)o.Categories.Clone();
            uid            = (UniqueIdProperty)o.UniqueId.Clone();

            this.CustomProperties.CloneRange(o.CustomProperties);
        }
Beispiel #4
0
        //=====================================================================

        /// <summary>
        /// This is overridden to allow cloning of a PDI object
        /// </summary>
        /// <returns>A clone of the object</returns>
        public override object Clone()
        {
            VNote o = new VNote();
            o.Clone(this);
            return o;
        }
Beispiel #5
0
        /// <summary>
        /// This version of the constructor is used when parsing vNote data that is to be stored in an existing
        /// vNote instance.
        /// </summary>
        /// <remarks>The properties in the passed vNote will be cleared</remarks>
        /// <param name="vNote">The existing vNote instance</param>
        /// <exception cref="ArgumentNullException">This is thrown if the specified vNote object is null</exception>
        protected VNoteParser(VNote vNote) : this()
        {
            if(vNote == null)
                throw new ArgumentNullException("vNote", LR.GetString("ExParseNullObject", "vNote"));

            currentNote = vNote;
            currentNote.ClearProperties();
            vNotes.Add(vNote);
        }
Beispiel #6
0
        /// <summary>
        /// This is implemented to handle properties as they are parsed from the data stream
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="parameters">A string collection containing the parameters and their values.  If empty,
        /// there are no parameters.</param>
        /// <param name="propertyValue">The value of the property.</param>
        /// <remarks><para>There may be a mixture of name/value pairs or values alone in the parameters string
        /// collection.  It is up to the derived class to process the parameter list based on the specification
        /// to which it conforms.  For entries that are parameter names, the entry immediately following it in
        /// the collection is its associated parameter value.  The property name, parameter names, and their
        /// values may be in upper, lower, or mixed case.</para>
        /// 
        /// <para>The value may be an encoded string.  The properties are responsible for any decoding that may
        /// need to occur (i.e. base 64 encoded image data).</para></remarks>
        /// <exception cref="PDIParserException">This is thrown if an error is encountered while parsing the data
        /// stream.  Refer to the and inner exceptions for information on the cause of the problem.</exception>
        protected override void PropertyParser(string propertyName, StringCollection parameters, string propertyValue)
        {
            string temp;
            int idx;

            // The last entry is always CustomProperty so scan for length minus one
            for(idx = 0; idx < ntv.Length - 1; idx++)
                if(ntv[idx].IsMatch(propertyName))
                    break;

            // An opening BEGIN:VNOTE property must have been seen
            if(currentNote == null && ntv[idx].EnumValue != PropertyType.Begin)
                throw new PDIParserException(this.LineNumber, LR.GetString("ExParseNoBeginProp", "BEGIN:VNOTE",
                    propertyName));

            // Handle or create the property
            switch(ntv[idx].EnumValue)
            {
                case PropertyType.Begin:
                    // The value must be VNOTE
                    if(String.Compare(propertyValue.Trim(), "VNOTE", StringComparison.OrdinalIgnoreCase) != 0)
                        throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                            ntv[idx].Name, propertyValue));

                    // NOTE: If serializing into an existing instance, this may not be null.  If so, it is
                    // ignored.
                    if(currentNote == null)
                    {
                        currentNote = new VNote();
                        vNotes.Add(currentNote);
                    }
                    break;

                case PropertyType.End:
                    // The value must be VNOTE
                    if(String.Compare(propertyValue.Trim(), "VNOTE", StringComparison.OrdinalIgnoreCase) != 0)
                        throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedTagValue",
                            ntv[idx].Name, propertyValue));

                    // When done, we'll propagate the version number to all objects to make it consistent
                    currentNote.PropagateVersion();

                    // The vNote is added to the collection when created so we don't have to rely on an END:VNOTE
                    // to add it.
                    currentNote = null;
                    break;

                case PropertyType.Version:
                    // Version must be 1.1
                    temp = propertyValue.Trim();

                    if(temp != "1.1")
                        throw new PDIParserException(this.LineNumber, LR.GetString("ExParseUnrecognizedVersion",
                            "vNote", temp));

                    currentNote.Version = SpecificationVersions.IrMC11;
                    break;

                case PropertyType.UniqueId:
                    currentNote.UniqueId.EncodedValue = propertyValue;
                    break;

                case PropertyType.Summary:
                    currentNote.Summary.DeserializeParameters(parameters);
                    currentNote.Summary.EncodedValue = propertyValue;
                    break;

                case PropertyType.Body:
                    currentNote.Body.DeserializeParameters(parameters);
                    currentNote.Body.EncodedValue = propertyValue;
                    break;

                case PropertyType.Class:
                    currentNote.Classification.EncodedValue = propertyValue;
                    break;

                case PropertyType.Categories:
                    currentNote.Categories.DeserializeParameters(parameters);
                    currentNote.Categories.EncodedValue = propertyValue;
                    break;

                case PropertyType.DateCreated:
                    currentNote.DateCreated.DeserializeParameters(parameters);
                    currentNote.DateCreated.EncodedValue = propertyValue;
                    break;

                case PropertyType.LastModified:
                    currentNote.LastModified.DeserializeParameters(parameters);
                    currentNote.LastModified.EncodedValue = propertyValue;
                    break;

                default:    // Anything else is a custom property
                    CustomProperty c = new CustomProperty(propertyName);
                    c.DeserializeParameters(parameters);
                    c.EncodedValue = propertyValue;
                    currentNote.CustomProperties.Add(c);
                    break;
            }
        }
Beispiel #7
0
 /// <summary>
 /// This static method can be used to load property values into an existing instance of a single vNote
 /// from a string.
 /// </summary>
 /// <param name="vNoteText">A set of properties for a single vNote in a string</param>
 /// <param name="vNote">The vNote instance into which the properties will be loaded</param>
 /// <remarks>The properties of the specified vNote will be cleared before the new properties are loaded
 /// into it.</remarks>
 /// <example>
 /// <code language="cs">
 /// VNote vNote = new VNote();
 /// VNoteParser.ParseFromString(oneVNote, vNote);
 /// </code>
 /// <code language="vbnet">
 /// Dim vNote As New VNote
 /// VNoteParser.ParseFromString(oneVNote, vNote)
 /// </code>
 /// </example>
 public static void ParseFromString(string vNoteText, VNote vNote)
 {
     VNoteParser vcp = new VNoteParser(vNote);
     vcp.ParseString(vNoteText);
 }