Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3175 Moving usings to GlobalUsing.cs #3186

Merged
merged 10 commits into from
Oct 22, 2024
  •  
  •  
  •  
38 changes: 38 additions & 0 deletions src/IoTHub.Portal.Application/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Runtime.CompilerServices;
global using System.Security.Cryptography;
global using System.Text;
global using System.Text.Json;
global using System.Text.RegularExpressions;
global using System.Threading;
global using System.Threading.Tasks;
global using Amazon.IoT.Model;
global using Amazon.IotData.Model;
global using AutoMapper;
global using Azure;
global using Azure.Messaging.EventHubs;
global using IoTHub.Portal.Application.Helpers;
global using IoTHub.Portal.Crosscutting.Extensions;
global using IoTHub.Portal.Domain.Entities;
global using IoTHub.Portal.Domain.Shared;
global using IoTHub.Portal.Models.v10;
global using IoTHub.Portal.Models.v10.LoRaWAN;
global using IoTHub.Portal.Shared.Models;
global using IoTHub.Portal.Shared.Models.v1._0;
global using IoTHub.Portal.Shared.Models.v10;
global using IoTHub.Portal.Shared.Models.v10.Filters;
global using IoTHub.Portal.Shared.Models.v10.IoTEdgeModule;
global using Microsoft.AspNetCore.Http;
global using Microsoft.Azure.Devices;
global using Microsoft.Azure.Devices.Provisioning.Service;
global using Microsoft.Azure.Devices.Shared;
global using Microsoft.Extensions.DependencyInjection;
global using Newtonsoft.Json.Linq;
global using Stream = System.IO.Stream;
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Helpers/AWSDeviceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Helpers
{
using System;
using Amazon.IotData.Model;
using Newtonsoft.Json.Linq;

public static class AWSDeviceHelper
{
public static JObject RetrieveDesiredProperties(GetThingShadowResponse shadow)
Expand Down
10 changes: 1 addition & 9 deletions src/IoTHub.Portal.Application/Helpers/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@

namespace IoTHub.Portal.Application.Helpers
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using IoTHub.Portal.Models.v10;
using IoTHub.Portal.Shared.Models.v10;
using IoTHub.Portal.Shared.Models.v10.IoTEdgeModule;
using Microsoft.Azure.Devices;
using Newtonsoft.Json.Linq;
using Configuration = Microsoft.Azure.Devices.Configuration;

public static class ConfigHelper
{
Expand Down
18 changes: 3 additions & 15 deletions src/IoTHub.Portal.Application/Helpers/DeviceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@

namespace IoTHub.Portal.Application.Helpers
{
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using IoTHub.Portal.Crosscutting.Extensions;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Models.v10;
using Microsoft.Azure.Devices.Provisioning.Service;
using Microsoft.Azure.Devices.Shared;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

public static class DeviceHelper
{
/// <summary>
Expand Down Expand Up @@ -244,7 +232,7 @@ public static TwinCollection PropertiesWithDotNotationToTwinCollection(Dictionar
}
}

return new TwinCollection(JsonConvert.SerializeObject(root));
return new TwinCollection(JsonSerializer.Serialize(root));
}

public static string? RetrieveClientThumbprintValue(Twin twin)
Expand All @@ -259,7 +247,7 @@ public static TwinCollection PropertiesWithDotNotationToTwinCollection(Dictionar

try
{
var clientThumbprintArray=JsonConvert.DeserializeObject<string[]>(serializedClientThumbprint);
var clientThumbprintArray=JsonSerializer.Deserialize<string[]>(serializedClientThumbprint);

if (clientThumbprintArray?.Length == 0)
{
Expand All @@ -269,7 +257,7 @@ public static TwinCollection PropertiesWithDotNotationToTwinCollection(Dictionar

return clientThumbprintArray?[0];
}
catch (JsonReaderException)
catch (JsonException)
{
// clientThumbprint is not an array in the device twin
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace IoTHub.Portal.Application.Managers
{
using System.Threading.Tasks;

public interface IDeviceModelImageManager
{
Task<string> GetDeviceModelImageAsync(string deviceModelId);
Expand Down
5 changes: 0 additions & 5 deletions src/IoTHub.Portal.Application/Managers/IExportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

namespace IoTHub.Portal.Application.Managers
{
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using IoTHub.Portal.Shared.Models.v10;

public interface IExportManager
{
Task ExportDeviceList(Stream stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

namespace IoTHub.Portal.Application.Mappers.AWS
{
using System.Text;
using Amazon.IoT;
using Amazon.IoT.Model;
using Amazon.IotData.Model;
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using Models.v10;
using Newtonsoft.Json;
using Device = Domain.Entities.Device;

public class AWSDeviceThingProfile : Profile
{
Expand Down Expand Up @@ -80,7 +73,7 @@ private static MemoryStream EmptyPayload()
}
};

return new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(json)));
return new MemoryStream(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(json)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Application.Helpers;
using IoTHub.Portal.Domain.Entities;
using Microsoft.Azure.Devices.Shared;
using Models.v10.LoRaWAN;
using Shared.Models.v1._0;

public class ConcentratorProfile : Profile
{
public ConcentratorProfile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using Models.v10.LoRaWAN;

public class DeviceModelCommandProfile : Profile
{
public DeviceModelCommandProfile()
Expand Down
7 changes: 0 additions & 7 deletions src/IoTHub.Portal.Application/Mappers/DeviceModelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using Amazon.IoT.Model;
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Domain.Shared;
using Models.v10;
using Models.v10.LoRaWAN;

public class DeviceModelProfile : Profile
{
public DeviceModelProfile()
Expand Down
12 changes: 1 addition & 11 deletions src/IoTHub.Portal.Application/Mappers/DeviceProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@

namespace IoTHub.Portal.Application.Mappers
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using AutoMapper;
using IoTHub.Portal.Application.Helpers;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;
using Microsoft.Azure.Devices.Shared;
using Models.v10;
using Models.v10.LoRaWAN;
using Device = Domain.Entities.Device;

public class DeviceProfile : Profile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Models.v10;

public class DevicePropertyProfile : Profile
{
public DevicePropertyProfile()
Expand Down
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Mappers/DeviceTagProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Models.v10;

public class DeviceTagProfile : Profile
{
public DeviceTagProfile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;

public class EdgeDeviceModelCommandProfile : Profile
{
public EdgeDeviceModelCommandProfile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Models.v10;

public class EdgeDeviceModelProfile : Profile
{
public EdgeDeviceModelProfile()
Expand Down
10 changes: 0 additions & 10 deletions src/IoTHub.Portal.Application/Mappers/EdgeDeviceProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using AutoMapper;
using IoTHub.Portal.Application.Helpers;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Models.v10;
using Microsoft.Azure.Devices.Shared;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;

public class EdgeDeviceProfile : Profile
{
public EdgeDeviceProfile()
Expand Down
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Mappers/EnumerableProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using System.Collections.Generic;
using AutoMapper;
using Azure;

public class EnumerableProfile : Profile
{
public EnumerableProfile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using IoTHub.Portal.Models.v10.LoRaWAN;
using Microsoft.Azure.Devices.Shared;

public interface IConcentratorTwinMapper
{
ConcentratorDto CreateDeviceDetails(Twin twin);
Expand Down
5 changes: 0 additions & 5 deletions src/IoTHub.Portal.Application/Mappers/IDeviceTwinMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using IoTHub.Portal.Models.v10;
using IoTHub.Portal.Shared.Models;
using Microsoft.Azure.Devices.Shared;
using System.Collections.Generic;

public interface IDeviceTwinMapper<TListItem, TDevice>
where TListItem : DeviceListItem
where TDevice : IDeviceDetails
Expand Down
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Mappers/IEdgeDeviceMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Application.Mappers
{
using System.Collections.Generic;
using IoTHub.Portal.Models.v10;
using Microsoft.Azure.Devices.Shared;

public interface IEdgeDeviceMapper
{
IoTEdgeListItem CreateEdgeDeviceListItem(Twin deviceTwin);
Expand Down
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Mappers/LabelProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Infrastructure.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;

public class LabelProfile : Profile
{
public LabelProfile()
Expand Down
4 changes: 0 additions & 4 deletions src/IoTHub.Portal.Application/Mappers/LayerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace IoTHub.Portal.Infrastructure.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;

public class LayerProfile : Profile
{
public LayerProfile()
Expand Down
3 changes: 0 additions & 3 deletions src/IoTHub.Portal.Application/Mappers/PlanningProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace IoTHub.Portal.Infrastructure.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;

public class PlanningProfile : Profile
{
Expand Down
3 changes: 0 additions & 3 deletions src/IoTHub.Portal.Application/Mappers/ScheduleProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

namespace IoTHub.Portal.Infrastructure.Mappers
{
using AutoMapper;
using IoTHub.Portal.Domain.Entities;
using IoTHub.Portal.Shared.Models.v10;

public class ScheduleProfile : Profile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

namespace IoTHub.Portal.Application.Providers
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Provisioning.Service;
using Microsoft.Azure.Devices.Shared;
using Shared.Models.v10;

public interface IDeviceRegistryProvider
{
/// <summary>
Expand Down
6 changes: 1 addition & 5 deletions src/IoTHub.Portal.Application/Services/IConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

namespace IoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
using IoTHub.Portal.Models.v10;
using IoTHub.Portal.Shared.Models.v10;
using Microsoft.Azure.Devices;
using Configuration = Microsoft.Azure.Devices.Configuration;

public interface IConfigService
{
Expand Down
Loading