예제 #1
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a file.  The
        /// filename can be a disk file or a URL.
        /// </summary>
        /// <param name="filename">A path or URL to a file containing one or more vNotes</param>
        /// <returns>A new vNote collection as created from the file</returns>
        /// <example>
        /// <code language="cs">
        /// VNoteCollection vNotes1 = VNoteParser.ParseFromFile(@"C:\Notes.vnt");
        /// VNoteCollection vNotes2 = VNoteParser.ParseFromFile(
        ///     "http://www.mydomain.com/VNotes/Notes.vnt");
        /// </code>
        /// <code language="vbnet">
        /// Dim vNotes1 As VNoteCollection = VNoteParser.ParseFromFile("C:\Notes.vnt")
        /// Dim vNotes2 As VNoteCollection = VNoteParser.ParseFromFile( _
        ///     "http://www.mydomain.com/VNotes/Notes.vnt")
        /// </code>
        /// </example>
        public static VNoteCollection ParseFromFile(string filename)
        {
            VNoteParser vcp = new VNoteParser();

            vcp.ParseFile(filename);

            return(vcp.VNotes);
        }
예제 #2
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a
        /// <see cref="TextReader"/> derived object such as a <see cref="StreamReader"/> or a
        /// <see cref="StringReader"/>.
        /// </summary>
        /// <param name="stream">An IO stream from which to read the vNotes.  It is up to you to open the stream
        /// with the appropriate text encoding method if necessary.</param>
        /// <returns>A new vNote collection as created from the IO stream</returns>
        /// <example>
        /// <code language="cs">
        /// StreamReader sr = new StreamReader(@"C:\Test.vcf");
        /// VNoteCollection vNotes1 = VNoteParser.ParseFromStream(sr);
        /// sr.Close();
        /// </code>
        /// <code language="vbnet">
        /// Dim sr As New StreamReader("C:\Test.vcf")
        /// Dim vNotes1 As VNoteCollection = VNoteParser.ParseFromStream(sr)
        /// sr.Close()
        /// </code>
        /// </example>
        public static VNoteCollection ParseFromStream(TextReader stream)
        {
            VNoteParser vcp = new VNoteParser();

            vcp.ParseReader(stream);

            return(vcp.VNotes);
        }
예제 #3
0
        //=====================================================================

        /// <summary>
        /// This static method can be used to load property values into a new instance of a single vNote from a
        /// string.
        /// </summary>
        /// <param name="vNoteText">A set of properties for a single vNote in a string</param>
        /// <returns>A new vNote instance as created from the string</returns>
        /// <example>
        /// <code language="cs">
        /// VNote vNote = VNoteParser.ParseFromString(oneVNote);
        /// </code>
        /// <code language="vbnet">
        /// Dim vNote As VNote = VNoteParser.ParseFromString(oneVNote)
        /// </code>
        /// </example>
        public static VNote ParseFromString(string vNoteText)
        {
            VNoteParser vcp = new VNoteParser();

            vcp.ParseString(vNoteText);

            return(vcp.VNotes[0]);
        }
예제 #4
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a string
        /// containing one or more vNotes.
        /// </summary>
        /// <param name="vNotes">A set of properties for one or more vNotes in a string</param>
        /// <returns>A new vNote collection as created from the string</returns>
        /// <example>
        /// <code language="cs">
        /// VNoteCollection vNotes = VNoteParser.ParseSetFromString(vNotes);
        /// </code>
        /// <code language="vbnet">
        /// Dim vNotes As VNoteCollection = VNoteParser.ParseSetFromString(vNotes)
        /// </code>
        /// </example>
        public static VNoteCollection ParseSetFromString(string vNotes)
        {
            VNoteParser vcp = new VNoteParser();

            vcp.ParseString(vNotes);

            return(vcp.VNotes);
        }
예제 #5
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);
        }
예제 #6
0
		static void Main(string[] args)
		{
            string outputFolder, outputFile;

            if(args.GetUpperBound(0) < 1)
            {
                Console.WriteLine("Specify a folder name containing PDI files and a different one for the " +
                    "output files.");
                return;
            }

            try
            {
                // Set the default encoding to iso-8859-1 (Western European) as several of the files are encoded
                // that way.
                PDIParser.DefaultEncoding = BaseProperty.DefaultEncoding = Encoding.GetEncoding("iso-8859-1");

                outputFolder = args[1];

                if(!outputFolder.EndsWith(@"\", StringComparison.Ordinal))
                    outputFolder += @"\";

                if(!Directory.Exists(outputFolder))
                    Directory.CreateDirectory(outputFolder);

                Console.WriteLine("Parsing vCard files...");

                // Since we'll be parsing multiple files, we'll create an instance of the parser and re-use it
                // rather than using the static parsing methods.
                VCardParser vcardp = new VCardParser();

                foreach(string file in Directory.EnumerateFiles(args[0], "*.vcf"))
                {
                    Console.WriteLine("\n{0}", file);

                    vcardp.ParseFile(file);

                    Console.WriteLine(vcardp.VCards.ToString());

                    // Write it to a stream
                    outputFile = outputFolder + Path.GetFileName(file);

                    // NOTE: We must use the same encoding method when writing the file back out
                    using(var sw = new StreamWriter(outputFile, false, PDIParser.DefaultEncoding))
                    {
                        vcardp.VCards.WriteToStream(sw);
                    }

                    // Clear the collection ready for the next run
                    vcardp.VCards.Clear();
                }

                Console.WriteLine("\nParsing vCalendar files...");

                // Since we'll be parsing multiple files, we'll create an instance of the parser and re-use it
                // rather than using the static parser methods.
                VCalendarParser vcalp = new VCalendarParser();

                foreach(string file in Directory.EnumerateFiles(args[0], "*.vcs"))
                {
                    Console.WriteLine("\n{0}", file);

                    vcalp.ParseFile(file);

                    Console.WriteLine(vcalp.VCalendar.ToString());

                    // Write it to a stream
                    outputFile = outputFolder + Path.GetFileName(file);

                    // NOTE: We must use the same encoding method when writing the file back out
                    using(var sw = new StreamWriter(outputFile, false, PDIParser.DefaultEncoding))
                    {
                        vcalp.VCalendar.WriteToStream(sw);
                    }

                    // Clear the calendar ready for the next run
                    vcalp.VCalendar.ClearProperties();
                }

                Console.WriteLine("\nParsing iCalendar files...");

                // Get a list of iCalendar files to parse.  It uses the same parser as the vCalendar files
                foreach(string file in Directory.EnumerateFiles(args[0], "*.ics"))
                {
                    Console.WriteLine("\n{0}", file);

                    vcalp.ParseFile(file);

                    Console.WriteLine(vcalp.VCalendar.ToString());

                    // Write it to a stream
                    outputFile = outputFolder + Path.GetFileName(file);

                    // NOTE: We must use the same encoding method when writing the file back out
                    using(var sw = new StreamWriter(outputFile, false, PDIParser.DefaultEncoding))
                    {
                        vcalp.VCalendar.WriteToStream(sw);
                    }

                    // Clear the calendar ready for the next run
                    vcalp.VCalendar.ClearProperties();
                }

                Console.WriteLine("\nParsing vNote files...");

                // Since we'll be parsing multiple files, we'll create an instance of the parser and re-use it
                // rather than using the static parser methods.
                VNoteParser vnp = new VNoteParser();

                foreach(string file in Directory.EnumerateFiles(args[0], "*.vnt"))
                {
                    Console.WriteLine("\n{0}", file);

                    vnp.ParseFile(file);

                    Console.WriteLine(vnp.VNotes.ToString());

                    // Write it to a stream
                    outputFile = outputFolder + Path.GetFileName(file);

                    // NOTE: We must use the same encoding method when writing the file back out
                    using(var sw = new StreamWriter(outputFile, false, PDIParser.DefaultEncoding))
                    {
                        vnp.VNotes.WriteToStream(sw);
                    }

                    // Clear the collection ready for the next run
                    vnp.VNotes.Clear();
                }
            }
            catch(PDIParserException pe)
            {
                Console.WriteLine("\n\nError at line #{0}\n\n{1}", pe.LineNumber, pe.ToString());
            }
            catch(Exception ex)
            {
                Console.WriteLine("Unexpected failure:\n{0}", ex.ToString());
            }
        }
예제 #7
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a
        /// <see cref="TextReader"/> derived object such as a <see cref="StreamReader"/> or a
        /// <see cref="StringReader"/>.
        /// </summary>
        /// <param name="stream">An IO stream from which to read the vNotes.  It is up to you to open the stream
        /// with the appropriate text encoding method if necessary.</param>
        /// <returns>A new vNote collection as created from the IO stream</returns>
        /// <example>
        /// <code language="cs">
        /// StreamReader sr = new StreamReader(@"C:\Test.vcf");
        /// VNoteCollection vNotes1 = VNoteParser.ParseFromStream(sr);
        /// sr.Close();
        /// </code>
        /// <code language="vbnet">
        /// Dim sr As New StreamReader("C:\Test.vcf")
        /// Dim vNotes1 As VNoteCollection = VNoteParser.ParseFromStream(sr)
        /// sr.Close()
        /// </code>
        /// </example>
        public static VNoteCollection ParseFromStream(TextReader stream)
        {
            VNoteParser vcp = new VNoteParser();
            vcp.ParseReader(stream);

            return vcp.VNotes;
        }
예제 #8
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a file.  The
        /// filename can be a disk file or a URL.
        /// </summary>
        /// <param name="filename">A path or URL to a file containing one or more vNotes</param>
        /// <returns>A new vNote collection as created from the file</returns>
        /// <example>
        /// <code language="cs">
        /// VNoteCollection vNotes1 = VNoteParser.ParseFromFile(@"C:\Notes.vnt");
        /// VNoteCollection vNotes2 = VNoteParser.ParseFromFile(
        ///     "http://www.mydomain.com/VNotes/Notes.vnt");
        /// </code>
        /// <code language="vbnet">
        /// Dim vNotes1 As VNoteCollection = VNoteParser.ParseFromFile("C:\Notes.vnt")
        /// Dim vNotes2 As VNoteCollection = VNoteParser.ParseFromFile( _
        ///     "http://www.mydomain.com/VNotes/Notes.vnt")
        /// </code>
        /// </example>
        public static VNoteCollection ParseFromFile(string filename)
        {
            VNoteParser vcp = new VNoteParser();
            vcp.ParseFile(filename);

            return vcp.VNotes;
        }
예제 #9
0
        /// <summary>
        /// This static method can be used to load property values into a new vNote collection from a string
        /// containing one or more vNotes.
        /// </summary>
        /// <param name="vNotes">A set of properties for one or more vNotes in a string</param>
        /// <returns>A new vNote collection as created from the string</returns>
        /// <example>
        /// <code language="cs">
        /// VNoteCollection vNotes = VNoteParser.ParseSetFromString(vNotes);
        /// </code>
        /// <code language="vbnet">
        /// Dim vNotes As VNoteCollection = VNoteParser.ParseSetFromString(vNotes)
        /// </code>
        /// </example>
        public static VNoteCollection ParseSetFromString(string vNotes)
        {
            VNoteParser vcp = new VNoteParser();
            vcp.ParseString(vNotes);

            return vcp.VNotes;
        }
예제 #10
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);
 }
예제 #11
0
        //=====================================================================

        /// <summary>
        /// This static method can be used to load property values into a new instance of a single vNote from a
        /// string.
        /// </summary>
        /// <param name="vNoteText">A set of properties for a single vNote in a string</param>
        /// <returns>A new vNote instance as created from the string</returns>
        /// <example>
        /// <code language="cs">
        /// VNote vNote = VNoteParser.ParseFromString(oneVNote);
        /// </code>
        /// <code language="vbnet">
        /// Dim vNote As VNote = VNoteParser.ParseFromString(oneVNote)
        /// </code>
        /// </example>
        public static VNote ParseFromString(string vNoteText)
        {
            VNoteParser vcp = new VNoteParser();
            vcp.ParseString(vNoteText);

            return vcp.VNotes[0];
        }