Skip to content

Commit

Permalink
Remove LocalCollector dependency from Abstractions and Core package, …
Browse files Browse the repository at this point in the history
…moved the interfaces and entities under Abstraction package from LocalCollector.

Fix EndToEndTests
  • Loading branch information
lilla28 committed Apr 21, 2023
1 parent 6785ece commit acdb894
Show file tree
Hide file tree
Showing 28 changed files with 177 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@
// or implied. See the License for the specific language governing permissions
// and limitations under the License.

using ProcessExplorer.Abstractions.Entities.Connections;

namespace LocalCollector.Connections;

public class ConnectionMonitor : IConnectionMonitor
{
private ConnectionMonitorInfo Data { get; } = new();
ConnectionMonitorInfo IConnectionMonitor.Data
private readonly ConnectionMonitorInfo _connections = new();
ConnectionMonitorInfo IConnectionMonitor.Connections
{
get => Data;
get
{
lock (_locker)
{
return _connections;
}
}
}

private readonly object _locker = new();
Expand All @@ -26,31 +34,31 @@ ConnectionMonitorInfo IConnectionMonitor.Data

public ConnectionMonitor(SynchronizedCollection<ConnectionInfo> connections)
{
Data.Connections = connections;
_connections.Connections = connections;
}

public void AddConnection(ConnectionInfo connectionInfo)
{
lock (_locker)
{
Data.Connections.Add(connectionInfo);
_connections.Connections.Add(connectionInfo);
}
}

public void RemoveConnection(ConnectionInfo connectionInfo)
{
lock (_locker)
{
var element = Data.Connections
var element = _connections.Connections
.FirstOrDefault(x => x.Id == connectionInfo.Id);

if (element == null)
{
return;
}

var index = Data.Connections.IndexOf(element);
Data.Connections.RemoveAt(index);
var index = _connections.Connections.IndexOf(element);
_connections.Connections.RemoveAt(index);
}
}

Expand All @@ -60,37 +68,37 @@ public void AddConnections(SynchronizedCollection<ConnectionInfo> connections)
{
foreach (var conn in connections)
{
var element = Data.Connections
var element = _connections.Connections
.FirstOrDefault(item => item.Id == conn.Id);

if (element == null)
{
continue;
}

var index = Data.Connections.IndexOf(element);
var index = _connections.Connections.IndexOf(element);
if (index != -1)
{
Data.Connections[index] = conn;
_connections.Connections[index] = conn;
}
else
{
Data.Connections.Add(conn);
_connections.Connections.Add(conn);
}
}
}
}

public void UpdateConnection(Guid connId, ConnectionStatus status)
{
if (Data.Connections.Count <= 0)
{
return;
}

lock (_locker)
{
var conn = Data.Connections
if (_connections.Connections.Count <= 0)
{
return;
}

var conn = _connections.Connections
.FirstOrDefault(c => c.Id == connId);

if (conn == null || conn.Status == status.ToStringCached())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
// or implied. See the License for the specific language governing permissions
// and limitations under the License.

using LocalCollector.Communicator;
using LocalCollector.Connections;
using LocalCollector.EnvironmentVariables;
using LocalCollector.Modules;
using LocalCollector.Registrations;
using ProcessExplorer.Abstractions.Entities;
using ProcessExplorer.Abstractions.Entities.Connections;
using ProcessExplorer.Abstractions.Infrastructure;

namespace LocalCollector;

Expand All @@ -23,7 +25,7 @@ public interface IProcessInfoCollector
/// <summary>
/// Contains information of the environment variables, connections, registrations, modules
/// </summary>
ProcessInfoCollectorData Data { get; }
ProcessInfoCollectorData ProcessInformation { get; }

/// <summary>
/// Adds a list of connections to the existing one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.9.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ProcessExplorer.Abstractions\ProcessExplorer.Abstractions.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// or implied. See the License for the specific language governing permissions
// and limitations under the License.

using ProcessExplorer.Abstractions.Entities.Modules;

namespace LocalCollector.Modules;

public class ModuleMonitorInfo
Expand Down
Loading

0 comments on commit acdb894

Please sign in to comment.