예제 #1
0
        public override void Finish(IIBReferenceResolver resolver)
        {
            base.Finish(resolver);

            if (this.usesXmlCoder)
            {
                IIBItem item1  = this.Find <IIBItem>("dict.sortedKeys");
                IBArray keys   = this.DereferenceItem(resolver, item1) as IBArray;
                IIBItem item2  = this.Find <IIBItem>("dict.values");
                IBArray values = this.DereferenceItem(resolver, item2) as IBArray;
                if (keys != null && values != null)
                {
                    for (int i = 0; i < keys.Count; i++)
                    {
                        IBString key   = keys[i] as IBString;
                        IIBItem  value = values[i];
                        if (key != null)
                        {
                            this.Add(key.ToString(), value);
                        }
                    }
                }
                else
                {
                    throw new Exception("It seems that the parsing has really gone wrong. Can't find either keys or values...");
                }
            }
            else if (this.Value.Count > 0)
            {
                bool useKeyValuePair;

                // Probe for the keys used.
                IIBItem item = this[0];
                useKeyValuePair = item.Key.StartsWith("NS.key.");

                if (useKeyValuePair)
                {
                    for (int i = 0; i < this.Value.Count;)
                    {
                        IIBItem keyItem   = this[i++];
                        IIBItem valueItem = this[i++];
                        this.Add(keyItem.ToString(), valueItem);
                    }
                }
                else
                {
                    for (int i = 0; i < this.Value.Count; i++)
                    {
                        item = this[i];
                        this.Add(item.Key, item);
                    }
                }
            }
        }