コード例 #1
0
        protected void AddElement(KeyValuePair <string, ApiObject> newElement, IDictionary <string, ApiObject> objects)
        {
            if (objects.ContainsKey(newElement.Key))
            {
                if (UniquenessHelper.HasSameProperties(objects[newElement.Key], objects, newElement.Key,
                                                       new Dictionary <string, ApiObject>(), new Dictionary <string, ApiObject>()))
                {
                    return;
                }

                var apiObject = objects[newElement.Key];
                var oldName   = apiObject.Name;
                apiObject.Name = UniquenessHelper.GetUniqueName(objects, apiObject.Name, new Dictionary <string, ApiObject>(), new Dictionary <string, ApiObject>());
                var newKey = UniquenessHelper.GetUniqueKey(objects, newElement.Key, new Dictionary <string, ApiObject>());
                objects.Add(newKey, apiObject);
                objects.Remove(objects.First(o => o.Key == newElement.Key));
                foreach (var apiObj in objects)
                {
                    foreach (var prop in apiObj.Value.Properties)
                    {
                        if (prop.Type == oldName)
                        {
                            prop.Type = apiObject.Name;
                        }
                    }
                }
            }
            objects.Add(newElement.Key, newElement.Value);
        }
コード例 #2
0
        private static KeyValuePair <string, ApiObject> HandleDuplicatedObjectName(KeyValuePair <string, ApiObject> newElement, IDictionary <string, ApiObject> objects)
        {
            var apiObject = newElement.Value;
            var oldName   = apiObject.Name;

            apiObject.Name = UniquenessHelper.GetUniqueName(objects, apiObject.Name, new Dictionary <string, ApiObject>(), new Dictionary <string, ApiObject>());
            var newKey = UniquenessHelper.GetUniqueKey(objects, newElement.Key, new Dictionary <string, ApiObject>());

            objects.Add(newKey, apiObject);
            //objects.Remove(objects.First(o => o.Key == newElement.Key));
            foreach (var apiObj in objects)
            {
                foreach (var prop in apiObj.Value.Properties)
                {
                    if (prop.TypeId == apiObject.Id)
                    {
                        prop.Type = apiObject.Name;
                    }
                }
            }

            return(newElement);
        }