/// <summary> /// Will read Configuration file if passed, or default COBieAttributesFilters.config /// </summary> /// <param name="configFileName">Full path/name for config file</param> /// <param name="import"></param> private void FiltersHelperInit(string configFileName = null, ImportSet import = ImportSet.All) { //set default var sourceFile = configFileName ?? RoleFilter.Unknown.ToResourceName(); var config = GetConfig(sourceFile); //IfcProduct and IfcTypeObject filters if (import == ImportSet.All || import == ImportSet.IfcFilters) { IfcProductFilter = new ObjectFilter(config.GetSection("IfcElementInclusion")); IfcTypeObjectFilter = new ObjectFilter(config.GetSection("IfcTypeInclusion")); IfcTypeObjectFilter.FillPreDefinedTypes(config.GetSection("IfcPreDefinedTypeFilter")); IfcAssemblyFilter = new ObjectFilter(config.GetSection("IfcAssemblyInclusion")); } //Property name filters if (import == ImportSet.All || import == ImportSet.PropertyFilters) { ZoneFilter = new PropertyFilter(config.GetSection("ZoneFilter")); TypeFilter = new PropertyFilter(config.GetSection("TypeFilter")); SpaceFilter = new PropertyFilter(config.GetSection("SpaceFilter")); FloorFilter = new PropertyFilter(config.GetSection("FloorFilter")); FacilityFilter = new PropertyFilter(config.GetSection("FacilityFilter")); SpareFilter = new PropertyFilter(config.GetSection("SpareFilter")); ComponentFilter = new PropertyFilter(config.GetSection("ComponentFilter")); CommonFilter = new PropertyFilter(config.GetSection("CommonFilter")); } // API restructure: // a call to File.Delete(config.FilePath); has been removed // it is strange for the configuration reading routine to delete a configuration file }
/// <summary> /// Copy values from passed ObjectFilter /// </summary> /// <param name="copyFilter">ObjectFilter to copy</param> public void Copy(ObjectFilter copyFilter) { _itemsToExclude = null; //reset exclude Items.Clear(); //fill dictionary from passed argument Items foreach (var pair in copyFilter.Items) { Items[pair.Key] = pair.Value; } PreDefinedType.Clear(); foreach (var pair in copyFilter.PreDefinedType) { PreDefinedType[pair.Key] = pair.Value; } }
/// <summary> /// Merge together ObjectFilter /// </summary> /// <param name="mergeFilter">ObjectFilter to merge</param> public void MergeInc(ObjectFilter mergeFilter) { _itemsToExclude = null; //reset exclude //find all includes for the incoming merge ObjectFilter var mergeInc = mergeFilter.Items.Where(i => i.Value).ToDictionary(i => i.Key, v => v.Value); //set the true flag on 'this' Items with same key as incoming merges found above in mergeInc foreach (var pair in mergeInc) { Items[pair.Key] = pair.Value; } var mergeData = PreDefinedType.Concat(mergeFilter.PreDefinedType).GroupBy(v => v.Key).ToDictionary(k => k.Key, v => v.SelectMany(x => x.Value).Distinct().ToArray()); //rebuild PreDefinedType from merge linq statement PreDefinedType.Clear(); foreach (var item in mergeData) { PreDefinedType.Add(item.Key, item.Value); } }
/// <summary> /// Empty constructor for Serialize /// </summary> public OutputFilters(ILogger logger) { _log = logger; //will flip filter result from true to false FlipResult = false; //object filters IfcProductFilter = new ObjectFilter(); IfcTypeObjectFilter = new ObjectFilter(); IfcAssemblyFilter = new ObjectFilter(); //Property name filters ZoneFilter = new PropertyFilter(); TypeFilter = new PropertyFilter(); SpaceFilter = new PropertyFilter(); FloorFilter = new PropertyFilter(); FacilityFilter = new PropertyFilter(); SpareFilter = new PropertyFilter(); ComponentFilter = new PropertyFilter(); CommonFilter = new PropertyFilter(); //role storage RolesFilterHolder = new Dictionary <RoleFilter, OutputFilters>(); }