在System.Web.Optimization.Bundle中找到新的IItemTransform [0].我试图谷歌搜索有关此语法的任何内容,但由于过于通用的单词的搜索查询而没有成功.
public virtual Bundle IncludeDirectory(string directoryVirtualPath, string searchPattern, bool searchSubdirectories) { if (ExceptionUtil.IsPureWildcardSearchPattern(searchPattern)) throw new ArgumentException(OptimizationResources.InvalidWildcardSearchPattern, "searchPattern"); PatternType patternType = PatternHelper.GetPatternType(searchPattern); Exception exception1 = PatternHelper.ValidatePattern(patternType, searchPattern, "virtualPaths"); if (exception1 != null) throw exception1; Exception exception2 = this.Items.IncludeDirectory(directoryVirtualPath, searchPattern, patternType, searchSubdirectories, new IItemTransform[0]); if (exception2 != null) throw exception2; else return this; }
IItemTransform:
namespace System.Web.Optimization { public interface IItemTransform { string Process(string includedVirtualPath, string input); } }
这种感觉真的不直观,有没有人认识到语法?
new IItemTransform[0]
只是创建一个类型的引用数组(大小为零)IItemTransform
.它不会创建任何实现的对象IItemTransform
.
它在语法上与创建一个空字符串数组相同:
string[] foo; foo = new string[0];
它只是一个阵列而IItemTransform
不是string
.