Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions TitaniumAS.Opc.Client/Da/OpcDaGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ public TimeSpan KeepAlive
}
set
{
if (!Is<OpcGroupStateMgt2>())
if (!Is<OpcGroupStateMgt2>(out var v))
return;
_keepAlive = As<OpcGroupStateMgt2>().SetKeepAlive(value);
_keepAlive = v.SetKeepAlive(value);
}
}

Expand Down Expand Up @@ -918,6 +918,19 @@ public bool Is<T>() where T : ComWrapper
return As<T>() != null;
}

/// <summary>
/// Determines whether this instance is of specified COM wrapper type.
/// </summary>
/// <typeparam name="T">The COM wrapper type.</typeparam>
/// <param name="value">Casted to type <typeparamref name="T"/> value</param>
/// <returns><c>true</c> if this instance is of specified COM wrapper type; otherwise, <c>false</c>.</returns>
public bool Is<T>(out T value) where T : ComWrapper
{
value = As<T>();

return value != null;
}

private OpcDaItemResult[] CreateItemResults(IList<OpcDaItemDefinition> itemDefinitions, OPCITEMDEF[] pItemArray,
OPCITEMRESULT[] opcDaItemResults, HRESULT[] ppErrors, bool setGroup)
{
Expand Down Expand Up @@ -1047,9 +1060,9 @@ private HRESULT[] SetClientHandles(int[] serverHandles, int[] clientHandles)

private TimeSpan RefreshKeepAlive()
{
if (!Is<OpcGroupStateMgt2>())
if (!Is<OpcGroupStateMgt2>(out var v))
return TimeSpan.Zero;
return As<OpcGroupStateMgt2>().GetKeepAlive();
return v.GetKeepAlive();
}

// Protected implementation of Dispose pattern.
Expand Down
13 changes: 13 additions & 0 deletions TitaniumAS.Opc.Client/Da/OpcDaServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,19 @@ public bool Is<T>() where T : ComWrapper
return As<T>() != null;
}

/// <summary>
/// Determines whether this instance is of specified COM wrapper type.
/// </summary>
/// <typeparam name="T">The COM wrapper type.</typeparam>
/// <param name="value">Casted to type <typeparamref name="T"/> value</param>
/// <returns><c>true</c> if this instance is of specified COM wrapper type; otherwise, <c>false</c>.</returns>
public bool Is<T>(out T value) where T : ComWrapper
{
value = As<T>();

return value != null;
}

private void RemoveAllGroups(bool rpcFailed = false)
{
foreach (OpcDaGroup opcDaGroup in _groups.ToArray())
Expand Down