/// <summary>
        /// Deletes a lookup.
        /// </summary>
        /// <param name="name"></param>
        public void DeleteLookup(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            // walk...
            foreach (ExtendedPropertyDefinition prop in this.Properties)
            {
                if (prop.DataType is LookupExtendedPropertyDataType &&
                    string.Compare(((LookupExtendedPropertyDataType)prop.DataType).LookupName, name, true, System.Globalization.CultureInfo.InvariantCulture) == 0)
                {
                    throw new InvalidOperationException(string.Format("The lookup '{0}' is currently used by property '{1}' on '{2}'.", name, prop.NativeName,
                                                                      prop.EntityTypeId));
                }
            }

            // remove it...
            ExtendedLookupDefinition lookup = this.Lookups[name];

            if (lookup != null)
            {
                this.Lookups.Remove(lookup);
            }
        }
        private static ExtendedPropertySettings FromXmlVersion3Schema(XmlElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            // load...
            ExtendedPropertySettings settings = new ExtendedPropertySettings();

            // load the extended properties
            foreach (XmlElement propertyElement in element.SelectNodes("ExtendedProperties/ExtendedProperty"))
            {
                settings.Properties.Add(ExtendedPropertyDefinition.FromXml(propertyElement));
            }

            // load the extended lookups
            foreach (XmlElement lookupElement in element.SelectNodes("Lookups/Lookup"))
            {
                settings.Lookups.Add(ExtendedLookupDefinition.FromXml(lookupElement));
            }

            // return...
            return(settings);
        }
Example #3
0
 public LookupExtendedPropertyDataType(ExtendedLookupDefinition lookup)
 {
     if (lookup == null)
     {
         throw new ArgumentNullException("lookup");
     }
     _lookupName = lookup.Name;
 }
        public void Remove(ExtendedLookupDefinition lookup)
        {
            if (!Contains(lookup))
            {
                return;
            }

            InnerList.RemoveAt(IndexOf(lookup));
        }
        public int IndexOf(string name)
        {
            for (int i = 0; i < InnerList.Count; i++)
            {
                ExtendedLookupDefinition existingProperty = (ExtendedLookupDefinition)InnerList[i];
                if (existingProperty.Name == name)
                {
                    return(i);
                }
            }

            return(-1);
        }
        public int Add(ExtendedLookupDefinition lookup)
        {
            if (InnerList.Contains(lookup))
            {
                return(InnerList.IndexOf(lookup));
            }

            if (Contains(lookup))
            {
                throw new DuplicateNameException(lookup.Name);
            }

            return(InnerList.Add(lookup));
        }
 public bool Contains(ExtendedLookupDefinition lookup)
 {
     return(Contains(lookup.Name));
 }
 public int IndexOf(ExtendedLookupDefinition lookup)
 {
     return(IndexOf(lookup.Name));
 }