/// <summary> /// 初始化一个新的带有事件Key的自定义菜单按钮。 /// </summary> /// <param name="name">菜单标题,不超过16个字节,子菜单不超过40个字节</param> /// <param name="type">菜单类型。</param> /// <param name="key">事件key。</param> /// <exception cref="ArgumentException">顶级菜单标题长度不能超过16个字节。</exception> /// <exception cref="ArgumentException">子级菜单标题长度不能超过40个字节。</exception> /// <exception cref="NotSupportedException"><paramref name="type"/> 为 <see cref="CustomMenuType.View"/> 或 <see cref="CustomMenuType.MediaId"/> 或 <see cref="CustomMenuType.ViewLimited"/>。</exception> /// <exception cref="ArgumentNullException"><paramref name="key"/> 为空。</exception> public CustomMenuKeyButton(string name, CustomMenuType type, string key) : base(name) { switch (type) { case CustomMenuType.View: case CustomMenuType.MediaId: case CustomMenuType.ViewLimited: throw new NotSupportedException("不支持的类型:" + type); } Type = type; Key = key.NotEmptyOrWhiteSpace("key"); }
/// <summary> /// 初始化一个新的使用永久素材的自定义菜单按钮。 /// </summary> /// <param name="name">菜单标题,不超过16个字节,子菜单不超过40个字节</param> /// <param name="type">菜单类型。</param> /// <param name="mediaId">调用新增永久素材接口返回的合法media_id。</param> /// <exception cref="ArgumentException">顶级菜单标题长度不能超过16个字节。</exception> /// <exception cref="ArgumentException">子级菜单标题长度不能超过40个字节。</exception> /// <exception cref="NotSupportedException"><paramref name="type"/> 不为 <see cref="CustomMenuType.MediaId"/> 或 <see cref="CustomMenuType.ViewLimited"/>。</exception> /// <exception cref="ArgumentNullException"><paramref name="mediaId"/> 为空。</exception> public CustomMenuMediaButton(string name, CustomMenuType type, string mediaId) : base(name) { switch (type) { case CustomMenuType.MediaId: case CustomMenuType.ViewLimited: break; default: throw new NotSupportedException("不支持的类型:" + type); } Type = type; MediaId = mediaId.NotEmptyOrWhiteSpace("mediaId"); }
/// <summary> /// 初始化一个新的使用永久素材的自定义菜单按钮。 /// </summary> /// <param name="name">菜单标题,不超过16个字节,子菜单不超过40个字节</param> /// <param name="type">菜单类型。</param> /// <param name="mediaId">调用新增永久素材接口返回的合法media_id。</param> /// <exception cref="ArgumentException">顶级菜单标题长度不能超过16个字节。</exception> /// <exception cref="ArgumentException">子级菜单标题长度不能超过40个字节。</exception> /// <exception cref="NotSupportedException"><paramref name="type"/> 不为 <see cref="CustomMenuType.MediaId"/> 或 <see cref="CustomMenuType.ViewLimited"/>。</exception> /// <exception cref="ArgumentNullException"><paramref name="mediaId"/> 为空。</exception> public CustomMenuMediaButton(string name, CustomMenuType type, string mediaId) : base(name) { switch (type) { case CustomMenuType.MediaId: case CustomMenuType.ViewLimited: break; default: throw new NotSupportedException("不支持的类型:" + type); } _type = type; MediaId = mediaId.NotEmptyOrWhiteSpace("mediaId"); }
/// <summary> /// 初始化一个新的带有事件Key的自定义菜单按钮。 /// </summary> /// <param name="name">菜单标题,不超过16个字节,子菜单不超过40个字节</param> /// <param name="type">菜单类型。</param> /// <param name="key">事件key。</param> /// <exception cref="ArgumentException">顶级菜单标题长度不能超过16个字节。</exception> /// <exception cref="ArgumentException">子级菜单标题长度不能超过40个字节。</exception> /// <exception cref="NotSupportedException"><paramref name="type"/> 为 <see cref="CustomMenuType.View"/> 或 <see cref="CustomMenuType.MediaId"/> 或 <see cref="CustomMenuType.ViewLimited"/>。</exception> /// <exception cref="ArgumentNullException"><paramref name="key"/> 为空。</exception> public CustomMenuKeyButton(string name, CustomMenuType type, string key) : base(name) { switch (type) { case CustomMenuType.View: case CustomMenuType.MediaId: case CustomMenuType.ViewLimited: throw new NotSupportedException("不支持的类型:" + type); } _type = type; Key = key.NotEmptyOrWhiteSpace("key"); }