Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

c# - How does the recursive GetEndpoints-Method of the OPC/UA-.NETStandard work?

I wanted to learn some C# and .net and network stuff. Thus, I've chosen the OPC UA code.

On github: UA-.NETStandard/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs

But I really don't understand how this method works:

    public virtual EndpointDescriptionCollection GetEndpoints(StringCollection profileUris)
    {
        EndpointDescriptionCollection endpoints = null;

        GetEndpoints(
            null,
            this.Endpoint.EndpointUrl,
            null,
            profileUris,
            out endpoints);

        return PatchEndpointUrls(endpoints);
    }

I understand that it is a recursive method, calling itself over and over again.

  1. How does it ever end? Is it maybe a continuous polling?
  2. Is the inner call's argument(s) "null,this.Endpoint.EndpointUrl,null,profileUris,out endpoints" a StringCollection? Because the StringCollection "profileUris" is already a StringCollection!?
question from:https://stackoverflow.com/questions/65934017/how-does-the-recursive-getendpoints-method-of-the-opc-ua-netstandard-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The method is not actually recursive. You're calling a different method(or "overload") altogether. You can check it out in the code repo.

Note that the class is partial. If you follow the references from the repo, you'll see that it leads to the generated client and server partial classes.

Github reference


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...