Exemple #1
0
        private ODataProperty ReadPropertyImplementation()
        {
            List <VCardItem> items = new List <VCardItem>();

            this.reader.Read();
            this.reader.Read();
            while (this.reader.State == VCardReaderState.Item)
            {
                VCardItem item = new VCardItem()
                {
                    Name   = this.reader.Name,
                    Value  = this.reader.Value,
                    Groups = this.reader.Groups,
                };

                if (this.reader.Params != null)
                {
                    item.Params = new Dictionary <string, string>();
                    foreach (string param in this.reader.Params.Split(';'))
                    {
                        int idx = param.IndexOf('=');
                        if (idx >= 0)
                        {
                            // need to care about when = appear in last.
                            item.Params.Add(param.Substring(0, idx), param.Substring(idx + 1));
                        }
                        else
                        {
                            if (item.Params.ContainsKey("TYPE"))
                            {
                                item.Params["TYPE"] = item.Params["TYPE"] + ";" + param;
                            }
                            else
                            {
                                item.Params.Add("TYPE", param);
                            }
                        }
                    }
                }

                items.Add(item);
                this.reader.Read();
            }

            Debug.Assert(this.reader.State == VCardReaderState.End);

            return(new ODataProperty()
            {
                Name = "fake", Value = GetEntryFromItems(items)
            });
        }
        private ODataProperty ReadPropertyImplementation()
        {
            List<VCardItem> items = new List<VCardItem>();
            this.reader.Read();
            this.reader.Read();
            while (this.reader.State == VCardReaderState.Item)
            {
                VCardItem item = new VCardItem()
                {
                    Name = this.reader.Name,
                    Value = this.reader.Value,
                    Groups = this.reader.Groups,
                };

                if (this.reader.Params != null)
                {
                    item.Params = new Dictionary<string, string>();
                    foreach (string param in this.reader.Params.Split(';'))
                    {
                        int idx = param.IndexOf('=');
                        if (idx >= 0)
                        {
                            // need to care about when = appear in last.
                            item.Params.Add(param.Substring(0, idx), param.Substring(idx + 1));
                        }
                        else
                        {
                            if (item.Params.ContainsKey("TYPE"))
                            {
                                item.Params["TYPE"] = item.Params["TYPE"] + ";" + param;
                            }
                            else
                            {
                                item.Params.Add("TYPE", param);
                            }
                        }
                    }
                }

                items.Add(item);
                this.reader.Read();
            }

            Debug.Assert(this.reader.State == VCardReaderState.End);

            return new ODataProperty() { Name = "fake", Value = GetEntryFromItems(items) };
        }
Exemple #3
0
        public override bool Read()
        {
            switch (this.state)
            {
            case ODataReaderState.Start:
                List <VCardItem> items = new List <VCardItem>();
                this.reader.Read();
                this.reader.Read();
                while (this.reader.State == VCardReaderState.Item)
                {
                    VCardItem vCardItem = new VCardItem()
                    {
                        Name   = this.reader.Name,
                        Value  = this.reader.Value,
                        Groups = this.reader.Groups,
                    };

                    if (this.reader.Params != null)
                    {
                        vCardItem.Params = new Dictionary <string, string>();
                        foreach (string param in this.reader.Params.Split(';'))
                        {
                            int idx = param.IndexOf('=');
                            if (idx >= 0)
                            {
                                // need to care about when = appear in last.
                                vCardItem.Params.Add(param.Substring(0, idx), param.Substring(idx + 1));
                            }
                            else
                            {
                                if (vCardItem.Params.ContainsKey("TYPE"))
                                {
                                    vCardItem.Params["TYPE"] = vCardItem.Params["TYPE"] + ";" + param;
                                }
                                else
                                {
                                    vCardItem.Params.Add("TYPE", param);
                                }
                            }
                        }
                    }

                    items.Add(vCardItem);
                    this.reader.Read();
                }

                Debug.Assert(this.reader.State == VCardReaderState.End);

                this.item  = GetEntryFromItems(items);
                this.state = ODataReaderState.ResourceEnd;
                break;

            case ODataReaderState.ResourceEnd:
                this.state = ODataReaderState.Completed;
                return(false);

            default:
                throw new ApplicationException("Invalid state");
            }

            return(true);
        }