【问题标题】:How does the recursive GetEndpoints-Method of the OPC/UA-.NETStandard work?OPC/UA-.NETStandard 的递归 GetEndpoints-Method 是如何工作的?
【发布时间】:2021-05-02 03:58:15
【问题描述】:

我想学习一些 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);
    }

我理解它是一种递归方法,一遍又一遍地调用自己。

  1. 它是如何结束的?可能是连续轮询吗?
  2. 内部调用的参数“null,this.Endpoint.EndpointUrl,null,profileUris,out endpoints”是 StringCollection 吗?因为 StringCollection "profileUris" 已经是 StringCollection!?

【问题讨论】:

    标签: c# .net recursion opc-ua


    【解决方案1】:

    该方法实际上不是递归的。您完全调用了不同的方法(或“重载”)。您可以查看in the code repo

    请注意,该类是部分的。如果您遵循 repo 中的引用,您会看到它导致生成的客户端和服务器部分类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 2021-03-26
      • 2023-02-09
      • 2020-03-08
      • 2011-08-19
      • 2021-12-26
      相关资源
      最近更新 更多