private static Asset GetConfigAsset(Asset currentAsset, string fileName, ConfigFileType fileType) { if (currentAsset.IsFolder) { List<Asset> childAssets = null; if (fileType == ConfigFileType.WebConfig) childAssets = currentAsset.GetFileList(new AssetParams() { ExcludeFilterStatus = new List<string>() { "Retired", "Archived" } }); else childAssets = currentAsset.GetFilterList(new FilterParams() { ExcludeFilterStatus = new List<string>() { "Retired", "Archived" } }); var configAssets = childAssets.Where(a => a.Label.Equals(fileName, StringComparison.OrdinalIgnoreCase)); if (configAssets.Count() > 1) throw new Exception("Multple " + fileName + " assets found at: " + currentAsset.AssetPath); var configAsset = configAssets.SingleOrDefault(); if (configAsset != null && configAsset.IsLoaded) { Out.DebugWriteLine("Found " + fileName + " asset at: " + configAsset.AssetPath); return configAsset; } } if (fileType == ConfigFileType.WebConfig && currentAsset.Parent != null) return GetConfigAsset(currentAsset.Parent, fileName, fileType); else throw new Exception("No " + fileName + " assets found"); }
/// <summary> /// Filters only the folder or files from the selected folder. /// </summary> public static Dictionary<string, Asset> GetSubList(Asset _asset, AssetType _assetType) { Dictionary<string, Asset> dtAssets = new Dictionary<string, Asset>(); List<Asset> lasAssets; if (_assetType.Equals(AssetType.Folder)) lasAssets = _asset.GetFolderList(); else lasAssets = _asset.GetFileList(); foreach (Asset asAsset in lasAssets) { if (!dtAssets.Keys.Contains(asAsset.BranchId.ToString())) dtAssets.Add(asAsset.BranchId.ToString(), asAsset); } return dtAssets; }