/// <summary> /// Creates a copy of the current AggregateFilterContainer including new copies of all subcontainers, filters (including those in subcontainers) and paramaters of those /// filters. This is a recursive operation that will clone the entire tree no matter how deep. /// </summary> /// <returns></returns> public AggregateFilterContainer DeepCloneEntireTreeRecursivelyIncludingFilters() { //clone ourselves AggregateFilterContainer clone = ShallowClone(); //clone our filters foreach (AggregateFilter filterToClone in GetFilters()) { //clone it AggregateFilter cloneFilter = filterToClone.ShallowClone(clone); //clone parameters foreach (AggregateFilterParameter parameterToClone in filterToClone.GetAllParameters()) { parameterToClone.ShallowClone(cloneFilter); } } //now clone all subcontainers foreach (AggregateFilterContainer toCloneSubcontainer in GetSubContainers()) { //clone the subcontainer recursively AggregateFilterContainer clonedSubcontainer = toCloneSubcontainer.DeepCloneEntireTreeRecursivelyIncludingFilters(); //get the returned filter subcontainer and assocaite it with the cloned version of this clone.AddChild(clonedSubcontainer); } //return the cloned version return(clone); }
private AggregateFilterContainer ShallowClone() { var container = new AggregateFilterContainer(CatalogueRepository, Operation); CopyShallowValuesTo(container); return(container); }
public AggregateFilter ShallowClone(AggregateFilterContainer into) { var clone = new AggregateFilter(CatalogueRepository, Name, into); CopyShallowValuesTo(clone); return(clone); }
public void CreateRootContainerIfNotExists() { if (RootFilterContainer_ID == null) { var container = new AggregateFilterContainer(CatalogueRepository, FilterContainerOperation.AND); RootFilterContainer_ID = container.ID; SaveToDatabase(); } }
/// <summary> /// Defines a new filter (line of WHERE SQL) in the specified AggregateFilterContainer (AND / OR). Calling this constructor creates a new object in the database /// </summary> /// <param name="repository"></param> /// <param name="name"></param> /// <param name="container"></param> public AggregateFilter(ICatalogueRepository repository, string name = null, AggregateFilterContainer container = null) { name = name ?? "New AggregateFilter" + Guid.NewGuid(); repository.InsertAndHydrate(this, new Dictionary <string, object> { { "Name", name }, { "FilterContainer_ID", container != null ? (object)container.ID : DBNull.Value } }); }