Esempio n. 1
0
        private ObjectClass GetObjectClass(string objectClassName)
        {
            //если такой есть, то возвращаем его
            foreach (ObjectClass oc in ObjectClasses)
            {
                if (oc.Name == objectClassName)
                {
                    return(oc);
                }
            }

            //иначе, добавляем и возвращаем добавленный
            ObjectClasses.Add(new ObjectClass(objectClassName));
            return(ObjectClasses[ObjectClasses.Count - 1]);
        }
Esempio n. 2
0
        /// <summary>
        /// Merges non-existing data from another set
        /// </summary>
        /// <param name="dataToMerge"></param>
        public void Merge(S57Data dataToMerge)
        {
            foreach (KeyValuePair <string, S57ObjectClass> pair in dataToMerge.ObjectClasses)
            {
                if (!ObjectClasses.Keys.Contains(pair.Key))
                {
                    ObjectClasses.Add(pair.Key, pair.Value);
                    _classes.Add(pair.Value.Code, pair.Value);
                }
            }

            foreach (KeyValuePair <string, S57Attribute> pair in dataToMerge.Attributes)
            {
                if (!Attributes.Keys.Contains(pair.Key))
                {
                    Attributes.Add(pair.Key, pair.Value);
                    _attrs.Add(pair.Value.Code, pair.Value);
                }
                else
                {
                    foreach (KeyValuePair <int, string> decode in pair.Value.AttrDecode)
                    {
                        if (!Attributes[pair.Key].AttrDecode.Keys.Contains(decode.Key))
                        {
                            Attributes[pair.Key].AttrDecode.Add(decode.Key, decode.Value);
                        }
                    }
                    foreach (KeyValuePair <int, string> expectedInput in pair.Value.ExpectedInput)
                    {
                        if (!Attributes[pair.Key].ExpectedInput.Keys.Contains(expectedInput.Key))
                        {
                            Attributes[pair.Key].ExpectedInput.Add(expectedInput.Key, expectedInput.Value);
                        }
                    }
                }
            }
        }