/// <summary> /// Inserts a FilterMangler instance into the collection. /// </summary> /// <param name="item">The item to add.</param> public void Insert(int index, FilterMangler item) { if (item == null) { throw new ArgumentNullException("item"); } List.Insert(index, item); }
/// <summary> /// Removes a FilterMangler item to the collection. /// </summary> /// <param name="item">The item to remove.</param> public void Remove(FilterMangler item) { if (item == null) { throw new ArgumentNullException("item"); } List.Remove(item); }
/// <summary> /// Adds a FilterMangler instance to the collection. /// </summary> /// <param name="item">The item to add.</param> public int Add(FilterMangler item) { if (item == null) { throw new ArgumentNullException("item"); } return(List.Add(item)); }
/// <summary> /// Discovers if the given item is in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>Returns true if the given item is in the collection.</returns> public bool Contains(FilterMangler item) { return(Contains(item.ManglerId)); }
/// <summary> /// Returns the index of the item in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>The index of the item, or -1 if it is not found.</returns> public int IndexOf(FilterMangler item) { return(IndexOf(item.ManglerId)); }
private static FilterMangler LoadMangler(SqlSearchSettings settings, XmlElement element) { if (settings == null) { throw new ArgumentNullException("settings"); } if (element == null) { throw new ArgumentNullException("element"); } // get the type... string manglerId = XmlHelper.GetAttributeString(element, "manglerId", OnNotFound.ThrowException); if (manglerId == null) { throw new InvalidOperationException("'manglerId' is null."); } if (manglerId.Length == 0) { throw new InvalidOperationException("'manglerId' is zero-length."); } // get the type... Type type = XmlHelper.GetAttributeType(element, "type", OnNotFound.ThrowException); if (type == null) { throw new InvalidOperationException("type is null."); } // create... ISqlFilterMangler filter = (ISqlFilterMangler)CreateInstance(type); if (filter == null) { throw new InvalidOperationException("filter is null."); } // get the settings element... XmlElement settingsElement = (XmlElement)element.SelectSingleNode("Settings"); if (settingsElement == null) { throw new InvalidOperationException("settingsElement is null."); } // load... SimpleXmlPropertyBag bag = SimpleXmlPropertyBag.Load(settingsElement, typeof(SimpleXmlPropertyBag)); if (bag == null) { throw new InvalidOperationException("bag is null."); } // Lets deserialize the bag into the control filter.DeserializeSqlSearchSettings(bag); FilterMangler mangler = new FilterMangler(manglerId, bag, filter); // patch... //mangler.DeserializeSqlSearchSettings(bag); // return... return(mangler); }
public static SqlSearchSettings FromXml(XmlDocument doc) { if (doc == null) { throw new ArgumentNullException("doc"); } // root... XmlElement rootElement = (XmlElement)doc.SelectSingleNode(RootElementName); if (rootElement == null) { throw new InvalidOperationException("The root element was not found."); } // create... Type type = XmlHelper.GetAttributeType(rootElement, "type", OnNotFound.ThrowException); if (type == null) { throw new InvalidOperationException("type is null."); } // create one... SqlSearchSettings newSettings = (SqlSearchSettings)CreateInstance(type); if (newSettings == null) { throw new InvalidOperationException("newSettings is null."); } // load the entity type... type = XmlHelper.GetElementType(rootElement, "EntityType", OnNotFound.ThrowException, true); if (type == null) { throw new InvalidOperationException("type is null."); } newSettings._entityType = EntityType.GetEntityType(type, OnNotFound.ThrowException); // load the manglers... foreach (XmlElement manglerElement in rootElement.SelectNodes("Manglers/Mangler")) { FilterMangler mangler = LoadMangler(newSettings, manglerElement); if (mangler == null) { throw new InvalidOperationException("mangler is null."); } // add... newSettings.Manglers.Add(mangler); } // load the settings... XmlElement settingsElement = (XmlElement)rootElement.SelectSingleNode("Settings"); if (settingsElement == null) { throw new InvalidOperationException("settingsElement is null."); } newSettings.LoadSettings(settingsElement); // deser... newSettings.OnAfterXmlDeserialization(); // return... return(newSettings); }