Exemplo n.º 1
0
        public override void ParseFromStream(StreamReader sr)
        {
            String tkn = "";

            while (true)
            {
                tkn = Parser.GetToken(sr);
                if (tkn == "END")
                {
                    tkn = Parser.GetToken(sr);
                    if (tkn != ":")
                    {
                        throw new InvalidDocumentStructureExeption();
                    }
                    tkn = Parser.GetToken(sr);
                    if (tkn != "VCALENDAR")
                    {
                        throw new InvalidDocumentStructureExeption();
                    }
                    return;
                }

                vObjectProperty pr = null;
                switch (tkn)
                {
                case "BEGIN":
                {
                    tkn = Parser.GetToken(sr);
                    if (tkn != ":")
                    {
                        throw new InvalidDocumentStructureExeption();
                    }
                    tkn = Parser.GetToken(sr);
                    vObject ent = null;
                    if (tkn == "VEVENT")
                    {
                        ent = new vEvent();
                    }
                    if (tkn == "VTODO")
                    {
                        ent = new vTodo();
                    }
                    if ((tkn != "VEVENT") && (tkn != "VTODO"))
                    {
                        throw new InvalidDocumentStructureExeption();
                    }
                    ent.ParseFromStream(sr);
                    AddEntity(ent);
                    break;
                }

                case "GEO":
                    pr = new GeographicPosition(this);
                    break;

                case "PRODID":
                    pr = new ProductID(this);
                    break;

                case "TZ":
                    pr = new TZone(this);
                    break;

                case "VERSION":
                    pr = new SpecificationVersion(this);
                    break;

                default:
                    if (tkn.Substring(0, 2) == "X-")                          // Extention property
                    {
                        pr = new ExtensionProperty(tkn, this);
                    }
                    else                              // Comment this if optional properties support is not required
                    {
                        pr = new OptionalProperty(tkn, this);
                    }
                    break;
                }
                if (pr != null)
                {
                    pr.ParseFromStream(sr);
                    SetProperty(pr);
                }
            }
        }
Exemplo n.º 2
0
		public override void ParseFromStream(StreamReader sr)
		{
			String tkn="";
			while(true)
			{
				tkn=Parser.GetToken(sr);
				if(tkn=="END")
				{
					tkn=Parser.GetToken(sr);
					if(tkn!=":")throw new InvalidDocumentStructureExeption();
					tkn=Parser.GetToken(sr);
					if(tkn!="VCALENDAR")throw new InvalidDocumentStructureExeption();
					return ;
				}

				vObjectProperty pr=null;
				switch(tkn)
				{
					case "BEGIN":
					{
						tkn=Parser.GetToken(sr);
						if(tkn!=":")throw new InvalidDocumentStructureExeption();
						tkn=Parser.GetToken(sr);
						vObject ent=null;
						if(tkn=="VEVENT")
							ent=new vEvent();
						if(tkn=="VTODO")
							ent=new vTodo();
						if((tkn!="VEVENT")&&(tkn!="VTODO"))throw new InvalidDocumentStructureExeption();
						ent.ParseFromStream(sr);
						AddEntity(ent);
						break;
					}
					case "GEO":
						pr=new GeographicPosition(this);
						break;
					case "PRODID":
						pr=new ProductID(this);
						break;
					case "TZ":
						pr=new TZone(this);
						break;
					case "VERSION":
						pr=new SpecificationVersion(this);
						break;
					default:
						if(tkn.Substring(0,2)=="X-")  // Extention property
						{
							pr=new ExtensionProperty(tkn,this);
						}
						else  // Comment this if optional properties support is not required
						{
							pr=new OptionalProperty(tkn,this);
						}
						break;
				}
				if(pr!=null)
				{
					pr.ParseFromStream(sr);
					SetProperty(pr);
				}
			}
		}