Skip to content

Commit

Permalink
Format opc.ua.client - no bug fixes / features (#1358)
Browse files Browse the repository at this point in the history
for upcoming async improvements, changes will not be cluttered with formatting
  • Loading branch information
mregen committed Apr 13, 2021
1 parent 901a171 commit 8a8a382
Show file tree
Hide file tree
Showing 10 changed files with 558 additions and 691 deletions.
117 changes: 56 additions & 61 deletions Libraries/Opc.Ua.Client/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
* ======================================================================*/

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace Opc.Ua.Client
{
/// <summary>
/// Stores the options to use for a browse operation.
/// </summary>
[DataContract(Namespace=Namespaces.OpcUaXsd)]
[DataContract(Namespace = Namespaces.OpcUaXsd)]
public class Browser
{
#region Constructors
Expand Down Expand Up @@ -67,15 +65,15 @@ public Browser(Browser template)

if (template != null)
{
m_session = template.m_session;
m_view = template.m_view;
m_session = template.m_session;
m_view = template.m_view;
m_maxReferencesReturned = template.m_maxReferencesReturned;
m_browseDirection = template.m_browseDirection;
m_referenceTypeId = template.m_referenceTypeId;
m_includeSubtypes = template.m_includeSubtypes;
m_nodeClassMask = template.m_nodeClassMask;
m_resultMask = template.m_resultMask;
m_continueUntilDone = template.m_continueUntilDone;
m_browseDirection = template.m_browseDirection;
m_referenceTypeId = template.m_referenceTypeId;
m_includeSubtypes = template.m_includeSubtypes;
m_nodeClassMask = template.m_nodeClassMask;
m_resultMask = template.m_resultMask;
m_continueUntilDone = template.m_continueUntilDone;
}
}

Expand All @@ -84,31 +82,31 @@ public Browser(Browser template)
/// </summary>
private void Initialize()
{
m_session = null;
m_view = null;
m_session = null;
m_view = null;
m_maxReferencesReturned = 0;
m_browseDirection = Opc.Ua.BrowseDirection.Forward;
m_referenceTypeId = null;
m_includeSubtypes = true;
m_nodeClassMask = 0;
m_resultMask = (uint)BrowseResultMask.All;
m_continueUntilDone = false;
m_browseInProgress = false;
m_browseDirection = Opc.Ua.BrowseDirection.Forward;
m_referenceTypeId = null;
m_includeSubtypes = true;
m_nodeClassMask = 0;
m_resultMask = (uint)BrowseResultMask.All;
m_continueUntilDone = false;
m_browseInProgress = false;
}
#endregion

#region Public Properties
/// <summary>
/// The session that the browse is attached to.
/// </summary>
public Session Session
{
get { return m_session; }

set
{
CheckBrowserState();
m_session = value;
m_session = value;
}
}

Expand All @@ -119,11 +117,11 @@ public Session Session
public ViewDescription View
{
get { return m_view; }

set
{
CheckBrowserState();
m_view = value;
m_view = value;
}
}

Expand All @@ -134,78 +132,78 @@ public ViewDescription View
public uint MaxReferencesReturned
{
get { return m_maxReferencesReturned; }

set
{
CheckBrowserState();
m_maxReferencesReturned = value;
m_maxReferencesReturned = value;
}
}

/// <summary>
/// The direction to browse.
/// </summary>
[DataMember(Order = 3)]
public BrowseDirection BrowseDirection
{
get { return m_browseDirection; }

set
{
CheckBrowserState();
m_browseDirection = value;
m_browseDirection = value;
}
}

/// <summary>
/// The reference type to follow.
/// </summary>
/// </summary>
[DataMember(Order = 4)]
public NodeId ReferenceTypeId
{
get { return m_referenceTypeId; }

set
{
CheckBrowserState();
m_referenceTypeId = value;
m_referenceTypeId = value;
}
}

/// <summary>
/// Whether subtypes of the reference type should be included.
/// </summary>
/// </summary>
[DataMember(Order = 5)]
public bool IncludeSubtypes
{
get { return m_includeSubtypes; }

set
{
CheckBrowserState();
m_includeSubtypes = value;
m_includeSubtypes = value;
}
}

/// <summary>
/// The classes of the target nodes.
/// </summary>
[DataMember(Order = 6)]
public int NodeClassMask
{
get { return Utils.ToInt32(m_nodeClassMask); }

set
{
CheckBrowserState();
m_nodeClassMask = Utils.ToUInt32(value);
m_nodeClassMask = Utils.ToUInt32(value);
}
}

/// <summary>
/// The results to return.
/// </summary>
[DataMember(Order=6)]
[DataMember(Order = 6)]
public uint ResultMask
{
get { return m_resultMask; }
Expand All @@ -223,7 +221,7 @@ public uint ResultMask
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1009:DeclareEventHandlersCorrectly")]
public event BrowserEventHandler MoreReferences
{
add { m_MoreReferences += value; }
add { m_MoreReferences += value; }
remove { m_MoreReferences -= value; }
}

Expand All @@ -233,15 +231,15 @@ public uint ResultMask
public bool ContinueUntilDone
{
get { return m_continueUntilDone; }

set
{
CheckBrowserState();
m_continueUntilDone = value;
m_continueUntilDone = value;
}
}
#endregion

#region Public Methods
/// <summary>
/// Browses the specified node.
Expand All @@ -252,7 +250,7 @@ public ReferenceDescriptionCollection Browse(NodeId nodeId)
{
throw new ServiceResultException(StatusCodes.BadServerNotConnected, "Cannot browse if not connected to a server.");
}

try
{
m_browseInProgress = true;
Expand Down Expand Up @@ -315,7 +313,7 @@ public ReferenceDescriptionCollection Browse(NodeId nodeId)

m_continueUntilDone = args.ContinueUntilDone;
}

additionalReferences = BrowseNext(ref continuationPoint, false);
if (additionalReferences != null && additionalReferences.Count > 0)
{
Expand All @@ -326,7 +324,7 @@ public ReferenceDescriptionCollection Browse(NodeId nodeId)
Utils.Trace("Continuation point exists, but the browse results are null/empty.");
break;
}
}
}

// return the results.
return references;
Expand Down Expand Up @@ -383,13 +381,13 @@ private ReferenceDescriptionCollection BrowseNext(ref byte[] continuationPoint,
}

// update continuation point.
continuationPoint = results[0].ContinuationPoint;
continuationPoint = results[0].ContinuationPoint;

// return references.
return results[0].References;
}
#endregion

#region Private Fields
private Session m_session;
private ViewDescription m_view;
Expand All @@ -404,7 +402,7 @@ private ReferenceDescriptionCollection BrowseNext(ref byte[] continuationPoint,
private bool m_browseInProgress;
#endregion
}

#region BrowserEventArgs Class
/// <summary>
/// The event arguments provided a browse operation returns a continuation point.
Expand All @@ -427,7 +425,7 @@ internal BrowserEventArgs(ReferenceDescriptionCollection references)
/// </summary>
public bool Cancel
{
get { return m_cancel; }
get { return m_cancel; }
set { m_cancel = value; }
}

Expand All @@ -436,26 +434,23 @@ public bool Cancel
/// </summary>
public bool ContinueUntilDone
{
get { return m_continueUntilDone; }
get { return m_continueUntilDone; }
set { m_continueUntilDone = value; }
}

/// <summary>
/// The references that have been fetched so far.
/// </summary>
public ReferenceDescriptionCollection References
{
get { return m_references; }
}
public ReferenceDescriptionCollection References => m_references;
#endregion

#region Private Fields
private bool m_cancel;
private bool m_continueUntilDone;
private ReferenceDescriptionCollection m_references;
#endregion
}

/// <summary>
/// A delegate used to received browser events.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Opc.Ua.Client/DataDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/

using Opc.Ua.Schema;
using Opc.Ua.Schema.Binary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Opc.Ua.Schema;
using Opc.Ua.Schema.Binary;

namespace Opc.Ua.Client
{
Expand Down Expand Up @@ -132,7 +132,7 @@ public async Task Load(NodeId dictionaryId, string name)
}

// Interoperability: some server may return a null terminated dictionary string, adjust length
int zeroTerminator = Array.IndexOf<byte>(schema, (byte)0);
int zeroTerminator = Array.IndexOf<byte>(schema, 0);
if (zeroTerminator >= 0)
{
Array.Resize(ref schema, zeroTerminator);
Expand Down

0 comments on commit 8a8a382

Please sign in to comment.