public void ParseFile(string file) { string name; iCalToken token = new iCalToken(), temp; if (System.IO.File.Exists(file)) { foreach (string line in System.IO.File.ReadAllLines(file)) { if (line.StartsWith("BEGIN:")) { name = line.Split(':')[1]; if (token[name] != null) { if (token[name].GetType() != typeof(iCalListToken)) { temp = token[name]; token[name] = new iCalListToken(token); ((iCalListToken)token[name]).Add(temp); } ((iCalListToken)token[name]).Add(new iCalToken(token[name])); token = ((iCalListToken)token[name])[((iCalListToken)token[name]).Count - 1]; } else { token[name] = new iCalToken(token); token = token[name]; } } else if (line.StartsWith("END:")) { token = token.Parent; if (token.GetType() == typeof(iCalListToken)) { token = token.Parent; } } else { name = line.Split(':')[0]; token[name] = new iCalPropertyToken(token, line.Split(':')[1]); } } } Root = token; }
public iCalToken(iCalToken Parent) { this.Parent = Parent; }
public iCalPropertyToken(iCalToken Parent, string Value) { this.Parent = Parent; this.Value = Value; }
public void Add(iCalToken Token) { this.childs.Add(Token); }