类 TypePrefixSubscription
此订阅基于类型的前缀匹配主题,并使用主题的来源作为代理键映射到代理。此订阅导致每个来源都有其自己的代理实例。
public class TypePrefixSubscription : ISubscriptionDefinition
- 继承
-
TypePrefixSubscription
- 实现
- 继承的成员
备注
示例
var subscription = new TypePrefixSubscription("t1", "a1");
在这种情况下
构造函数
TypePrefixSubscription(string, AgentType, string?)
初始化 TypePrefixSubscription 类的新实例。
public TypePrefixSubscription(string topicTypePrefix, AgentType agentType, string? id = null)
参数
topicTypePrefix
string要匹配的主题类型前缀。
agentType
AgentType处理此订阅的代理类型。
id
string订阅的唯一标识符。 如果未提供,将生成新的 UUID。
属性
AgentType
获取处理此订阅的代理类型。
public AgentType AgentType { get; }
属性值
Id
获取订阅的唯一标识符。
public string Id { get; }
属性值
TopicTypePrefix
获取用于匹配的主题类型前缀。
public string TopicTypePrefix { get; }
属性值
方法
Equals(object?)
确定指定的对象是否等于当前订阅。
public override bool Equals(object? obj)
参数
obj
object要与当前实例进行比较的对象。
返回值
- bool
如果指定的对象等于此实例,则为
true
;否则,为false
。
GetHashCode()
返回此实例的哈希代码。
public override int GetHashCode()
返回值
- int
此实例的哈希代码,适合在哈希算法和数据结构中使用。
MapToAgent(TopicId)
将 TopicId 映射到 AgentId。 只有在 Matches(TopicId) 返回 true 时才应调用。
public AgentId MapToAgent(TopicId topic)
参数
topic
TopicId要映射的主题。
返回值
异常
- InvalidOperationException
如果主题与订阅不匹配,则抛出。
Matches(TopicId)
检查给定的 TopicId 是否基于其类型前缀与订阅匹配。
public bool Matches(TopicId topic)
参数
topic
TopicId要检查的主题。
返回值
- bool
如果主题的类型以订阅的前缀开头,则为
true
;否则为false
。