api 动作之前的 if else 语句
if else statement before api action
在网络中是否可能出现类似的情况 api :
[Route("api/bot1/messages")]
[BotAuthentication(id = ..., pass = '']
[Route("api/bot2/messages")]
[BotAuthentication(id = 2..., pass = 2...]
public class MessagesController : ApiController
PS : 我是小白
查看 [BotAuthentication]
属性的源代码,located here.
namespace Microsoft.Bot.Connector
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
public class BotAuthentication : ActionFilterAttribute {
...
}
}
在[AttributeUsage()]
属性(documentation here)中,我们看到class里面有一个属性:
AllowMultiple = false
来自documentation for the AllowMultiple property:
Gets or sets a Boolean value indicating whether more than one instance
of the indicated attribute can be specified for a single program
element.
true if more than one instance is allowed to be specified; otherwise, false. The default is false.
这意味着不能为消息控制器指定一个以上的 [BotAuthentication]
实例。
所以不,这样的事情是 不可能的。
(此外,作为下一次的注意事项,请尝试将您的问题与您发布的代码联系起来。您绝不会说您如何在代码中使用 "if-else" 控制语句,并且有些人可能无法推断出你的意思。)
在网络中是否可能出现类似的情况 api :
[Route("api/bot1/messages")]
[BotAuthentication(id = ..., pass = '']
[Route("api/bot2/messages")]
[BotAuthentication(id = 2..., pass = 2...]
public class MessagesController : ApiController
PS : 我是小白
查看 [BotAuthentication]
属性的源代码,located here.
namespace Microsoft.Bot.Connector
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
public class BotAuthentication : ActionFilterAttribute {
...
}
}
在[AttributeUsage()]
属性(documentation here)中,我们看到class里面有一个属性:
AllowMultiple = false
来自documentation for the AllowMultiple property:
Gets or sets a Boolean value indicating whether more than one instance of the indicated attribute can be specified for a single program element.
true if more than one instance is allowed to be specified; otherwise, false. The default is false.
这意味着不能为消息控制器指定一个以上的 [BotAuthentication]
实例。
所以不,这样的事情是 不可能的。
(此外,作为下一次的注意事项,请尝试将您的问题与您发布的代码联系起来。您绝不会说您如何在代码中使用 "if-else" 控制语句,并且有些人可能无法推断出你的意思。)