本文整理汇总了C#中Asset.GetFilterList方法的典型用法代码示例。如果您正苦于以下问题:C# Asset.GetFilterList方法的具体用法?C# Asset.GetFilterList怎么用?C# Asset.GetFilterList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset.GetFilterList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConfigAsset
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");
}
示例2: GetFilterList
/// <summary>
/// Filters everything even subfolders from the selected folder. Key = AssetID, Value = Asset.
/// <para>If AssetType.Unspecified is selected, it will return all folders and files.</para>
/// </summary>
public static List<Asset> GetFilterList(Asset _assetFolder, AssetType _assetType = AssetType.Unspecified, string _path = "", bool excludeProjectTypes = false, List<string> excludeFolders = null, IhSiteBuilderLog siteLog = null)
{
FilterParams fpFilter = new FilterParams();
fpFilter.ExcludeProjectTypes = excludeProjectTypes;
if (!_assetType.Equals(AssetType.Unspecified))
fpFilter.Add(Comparison.Equals, _assetType);
Dictionary<string, Asset> dtAssets = new Dictionary<string, Asset>();
if (!string.IsNullOrWhiteSpace(_path))
{
if (Asset.Load(_path).IsLoaded)
_assetFolder = Asset.Load(_path);
}
List<Asset> laAssets = _assetFolder.GetFilterList(fpFilter);
if (excludeFolders != null)
{
laAssets = ExcludeFolderList(laAssets, excludeFolders);
}
foreach (Asset asAsset in laAssets)
{
if (!dtAssets.Keys.Contains(asAsset.BranchId.ToString()))
{
if (asAsset.Type.Equals(AssetType.Folder))
{
dtAssets.Add(asAsset.BranchId.ToString(), asAsset);
}
else if (asAsset.Type.Equals(AssetType.File))
{
if (asAsset.WorkflowStatus.Name.Equals("Live") || asAsset.WorkflowStatus.Name.Equals("Stage") || asAsset.WorkflowStatus.Name.Equals("Draft") || asAsset.WorkflowStatus.Name.Equals(""))
{
dtAssets.Add(asAsset.BranchId.ToString(), asAsset);
}
}
}
else
{
if (asAsset.WorkflowStatus.Name.Equals("Live"))
{
dtAssets[asAsset.BranchId.ToString()] = asAsset;
}
else if (asAsset.WorkflowStatus.Name.Equals("Stage"))
{
if (!dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Live") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Stage"))
{
dtAssets[asAsset.BranchId.ToString()] = asAsset;
}
}
else if (asAsset.WorkflowStatus.Name.Equals("Draft"))
{
if (!dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Live") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Stage") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Draft"))
{
dtAssets[asAsset.BranchId.ToString()] = asAsset;
}
}
}
}
return dtAssets.Values.ToList<Asset>();
}