public bool toVCFilter(VCFilter parent) { bool hasFiles = files.Count > 0; if (files.Count > 0 || folders.Count > 0) { VCFilter filter = parent.AddFilter(name); foreach (var file in files) { filter.AddFile(Path.Combine(path, file)); } foreach (var folder in folders) { hasFiles |= folder.toVCFilter(filter); } if (!hasFiles) { parent.RemoveFilter(filter); } } return hasFiles; }
public bool toVCFilter(VCFilter parent) { bool hasFiles = files.Count > 0; if (files.Count > 0 || folders.Count > 0) { VCFilter filter = parent.AddFilter(name); foreach (var file in files) { filter.AddFile(Path.Combine(path, file)); } foreach (var folder in folders) { hasFiles |= folder.toVCFilter(filter); } if (!hasFiles) { parent.RemoveFilter(filter); } } return(hasFiles); }
private void CleanupFilter(VCFilter filter) { IVCCollection subFilters = filter.Filters as IVCCollection; if (subFilters == null) return; for (int i = subFilters.Count; i > 0; i--) { VCFilter subFilter = subFilters.Item(i)as VCFilter; IVCCollection subFilterFilters = subFilter.Filters as IVCCollection; if (subFilterFilters == null) continue; CleanupFilter(subFilter); bool filterOrFileFound = false; foreach (object itemObject in subFilter.Items as IVCCollection) { if (itemObject is VCFilter || itemObject is VCFile) { filterOrFileFound = true; break; } } if (!filterOrFileFound) { filter.RemoveFilter(subFilter); } } }
public static void removeAddons(VCProject vcproject, string ofRoot, IEnumerable <string> addonsNames) { // Parse current settings in the project List <string> includes32Debug = new List <string>(); List <string> includes32Release = new List <string>(); List <string> includes64Debug = new List <string>(); List <string> includes64Release = new List <string>(); List <string> libs32Debug = new List <string>(); List <string> libs32Release = new List <string>(); List <string> libs64Debug = new List <string>(); List <string> libs64Release = new List <string>(); foreach (VCConfiguration config in vcproject.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (config.Name == "Debug|Win32") { ParseProjectConfig(tool, includes32Debug, libs32Debug); } else if (config.Name == "Release|Win32") { ParseProjectConfig(tool, includes32Release, libs32Release); } else if (config.Name == "Debug|x64") { ParseProjectConfig(tool, includes64Debug, libs64Debug); } else if (config.Name == "Release|x64") { ParseProjectConfig(tool, includes64Release, libs64Release); } } } // Retrieve all addons config var addons = addonsNames.Select((addonName) => { return(new Addon(ofRoot, addonName, vcproject.ProjectDirectory)); }); // Filter out the addons to remove config from the existing one foreach (var addon in addons) { libs32Debug = libs32Debug.Except(addon.getLibs32Debug()).ToList(); libs32Release = libs32Release.Except(addon.getLibs32Release()).ToList(); libs64Debug = libs64Debug.Except(addon.getLibs64Debug()).ToList(); libs64Release = libs32Release.Except(addon.getLibs64Release()).ToList(); includes32Debug = includes32Debug.Except(addon.getIncludes()).ToList(); includes32Release = includes32Release.Except(addon.getIncludes()).ToList(); includes64Debug = libs64Debug.Except(addon.getIncludes()).ToList(); includes64Release = includes32Release.Except(addon.getIncludes()).ToList(); } // Add the config back to the project: foreach (VCConfiguration config in vcproject.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (config.Name == "Debug|Win32") { ListToProjectConfig(tool, includes32Debug, libs32Debug); } else if (config.Name == "Release|Win32") { ListToProjectConfig(tool, includes32Release, libs32Release); } else if (config.Name == "Debug|x64") { ListToProjectConfig(tool, includes64Debug, libs64Debug); } else if (config.Name == "Release|x64") { ListToProjectConfig(tool, includes64Release, libs64Release); } } } // Find addons filter and remove the specified addons from it VCFilter addonsFolder = null; List <VCFilter> addonsFiltersToRemove = new List <VCFilter>(); IVCCollection filters = vcproject.Filters; foreach (var filter in filters) { if (filter is VCFilter) { if (((VCFilter)filter).Name == "addons") { addonsFolder = ((VCFilter)filter); foreach (var addon in addonsFolder.Filters) { if (addon is VCFilter && addonsNames.Contains(((VCFilter)addon).Name)) { addonsFiltersToRemove.Add((VCFilter)addon); } } break; } } } foreach (var addon in addonsFiltersToRemove) { addonsFolder.RemoveFilter(addon); } }