示例#1
0
            public static CustomAttributeBuilder Build(Expression expression)
            {
                var s = new CustomAttributeConstructorVisitor();

                s.Visit(expression);
                if (s.properties.Count != s.values.Count)
                {
                    throw new Exception(SR.GetString(SRKind.PropertyValueLengthNotMatch));
                }

                return(new CustomAttributeBuilder(
                           s.constructor,
                           s.constructorArgs.ToArray(),
                           s.properties.ToArray(),
                           s.values.ToArray()));
            }
示例#2
0
 /// <summary>
 /// 使用自定义特性生成器设置此程序集的自定义特性。
 /// </summary>
 /// <param name="expression">一个 <see cref="Attribute"/> 的构造表达式。</param>
 public void SetCustomAttribute(Expression expression)
 {
     SetCustomAttribute(CustomAttributeConstructorVisitor.Build(expression));
 }