点击或拖拽改变大小
盛派网络

MacroAttribute 类

Senparc.Weixin SDK 官方教程《微信开发深度解析》已出版,支持中国开源事业,请【购买正版】
《微信公众号+小程序》视频课程已经上线,【点击这里】学习!

NeuChar(纽插)已经上线,为开发者提供一站式跨平台管理枢纽,并可将应用入驻到 NeuChar 应用商店!新功能正在不断增加中,快来使用吧! https://www.neuchar.com
在线动态微信接口 Swagger WebApi 文档: https://weixin.senparc.com:8039

Allows specifying a macro for a parameter of a source template.
继承层次
SystemObject
  SystemAttribute
    Senparc.Weixin.AnnotationsMacroAttribute

命名空间:  Senparc.Weixin.Annotations
程序集:  Senparc.Weixin (在 Senparc.Weixin.dll 中) 版本:6.5.0.26158
语法
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Parameter, AllowMultiple = true)]
public sealed class MacroAttribute : Attribute

MacroAttribute 类型公开以下成员。

构造函数
  名称说明
公共方法MacroAttribute
初始化 MacroAttribute 类的一个新实例
Top
属性
  名称说明
公共属性Editable
Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
公共属性Expression
Allows specifying a macro that will be executed for a source template parameter when the template is expanded.
公共属性Target
Identifies the target parameter of a source template if the MacroAttribute is applied on a template method.
Top
扩展方法
  名称说明
公共扩展器方法Serialize
序列化对象
(由 StackExchangeRedisExtensions 定义。)
公共扩展器方法ToHashEntries
Serialize in Redis format
(由 RedisUtils 定义。)
公共扩展器方法ToJson
把数据转换为Json格式(使用Newtonsoft.Json.dll)
(由 ObjectExtensions 定义。)
Top
备注
You can apply the attribute on the whole method or on any of its additional parameters. The macro expression is defined in the Expression property. When applied on a method, the target template parameter is defined in the Target property. To apply the macro silently for the parameter, set the Editable property value = -1.
示例
Applying the attribute on a source template method:
[SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
public static void forEach<T>(this IEnumerable<T> collection) {
  foreach (var item in collection) {
    //$ $END$
  }
}
Applying the attribute on a template method parameter:
[SourceTemplate]
public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
  /*$ var $x$Id = "$newguid$" + x.ToString();
  x.DoSomething($x$Id); */
}
参见