如何解决OPC/UA-.NETStandard 的递归 GetEndpoints-Method 是如何工作的?
我想学习一些 C# 和 .net 以及网络方面的东西。因此,我选择了 OPC UA 代码。
在github上:UA-.NETStandard/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs
但我真的不明白这个方法是如何工作的:
public virtual EndpointDescriptionCollection GetEndpoints(StringCollection profileUris)
{
EndpointDescriptionCollection endpoints = null;
GetEndpoints(
null,this.Endpoint.EndpointUrl,null,profileUris,out endpoints);
return PatchEndpointUrls(endpoints);
}
我知道它是一种递归方法,一遍又一遍地调用自己。
- 它是如何结束的?可能是连续轮询吗?
- 内部调用的参数“null,out endpoints”是一个StringCollection吗?因为 StringCollection "profileUris" 已经是 StringCollection!?
解决方法
该方法实际上不是递归的。您正在完全调用不同的方法(或“重载”)。你可以看看in the code repo。
请注意,该类是部分的。如果您遵循 repo 中的引用,您将看到它指向生成的客户端和服务器部分类。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。