diff --git a/src/MalikP. IVAO Library/MalikP. IVAO Library.sln b/src/MalikP. IVAO Library/MalikP. IVAO Library.sln index 58993c1..f6a955a 100644 --- a/src/MalikP. IVAO Library/MalikP. IVAO Library.sln +++ b/src/MalikP. IVAO Library/MalikP. IVAO Library.sln @@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalikP.IVAO.Library.App", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalikP.IVAO.Library", "MalikP.IVAO.Library\MalikP.IVAO.Library.csproj", "{95BCECFF-D358-4FD8-BC81-3DF6C04DC8A2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MalikP.IVAO.Library.Test", "MalikP.IVAO.Library.Test\MalikP.IVAO.Library.Test.csproj", "{6939AC5E-4B9B-40B3-8044-437D0E20102F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalikP.IVAO.Library.Test", "MalikP.IVAO.Library.Test\MalikP.IVAO.Library.Test.csproj", "{6939AC5E-4B9B-40B3-8044-437D0E20102F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MalikP.IVAO.Library.IoC", "MalikP.IVAO.Library.IoC\MalikP.IVAO.Library.IoC.csproj", "{35EADA32-399B-4DB5-BBAD-773603F127A9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,9 +18,7 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DB2048CA-9DAA-4CFF-8840-481086CEDF70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB2048CA-9DAA-4CFF-8840-481086CEDF70}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB2048CA-9DAA-4CFF-8840-481086CEDF70}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB2048CA-9DAA-4CFF-8840-481086CEDF70}.Release|Any CPU.Build.0 = Release|Any CPU {95BCECFF-D358-4FD8-BC81-3DF6C04DC8A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {95BCECFF-D358-4FD8-BC81-3DF6C04DC8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU {95BCECFF-D358-4FD8-BC81-3DF6C04DC8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -27,6 +27,8 @@ Global {6939AC5E-4B9B-40B3-8044-437D0E20102F}.Debug|Any CPU.Build.0 = Debug|Any CPU {6939AC5E-4B9B-40B3-8044-437D0E20102F}.Release|Any CPU.ActiveCfg = Release|Any CPU {6939AC5E-4B9B-40B3-8044-437D0E20102F}.Release|Any CPU.Build.0 = Release|Any CPU + {35EADA32-399B-4DB5-BBAD-773603F127A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35EADA32-399B-4DB5-BBAD-773603F127A9}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/MalikP.IVAO.Library.App.csproj b/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/MalikP.IVAO.Library.App.csproj index b00e50a..a9243d2 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/MalikP.IVAO.Library.App.csproj +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/MalikP.IVAO.Library.App.csproj @@ -6,6 +6,11 @@ + + + + + diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/Program.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/Program.cs index 0d68495..207ed1a 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/Program.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.App/Program.cs @@ -2,11 +2,11 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.Serialization; -using System.Text; -using System.Xml; +using MalikP.IoC; +using MalikP.IoC.Factories; using MalikP.IVAO.Library.Common; +using MalikP.IVAO.Library.Common.Enhancers; using MalikP.IVAO.Library.Common.Parsers; using MalikP.IVAO.Library.Common.Selector; using MalikP.IVAO.Library.Data.Source; @@ -26,6 +26,66 @@ internal static class Program public static void Main(string[] args) { string path = GetPath(); + + OptionIoC(path); + + OptionDirect(path); + } + + private static void OptionIoC(string path) + { + IIoC ioc = Locator.GetContainer(new AdvancedContainerFactory()); + + ioc.RegisterIvaoDefaultWhazzupServices(); + ioc.RegisterIvaoModelBuilders(); + ioc.RegisterIvaoCachedDataSource(); + + ioc.Register() + .Extend() + .WithSpecific(path); + + //IIVAOWhazzupDataSource nonCachedWebDataSource = new WebIVAOWhazzupDataSource("http://api.ivao.aero/getdata/whazzup/whazzup.txt"); + //IIVAOWhazzupDataSource nonCachedWebGZippedDataSource = new WebGZippedIVAOWhazzupDataSource("http://api.ivao.aero/getdata/whazzup/whazzup.txt.gz", compression); + + //IIVAOWhazzupDataSource nonCachedLocalDataSource = new LocalIVAOWhazzupDataSource(path); + //IIVAOWhazzupDataSource nonCachedLocalGZippedDataSource = new LocalGZippedIVAOWhazzupDataSource(path, compression); + + IGeneralDataProvider generalDataProvider = ioc.Resolve(); + IClientsProvider clientsDataProvider = ioc.Resolve(); + IServersProvider serversDataProvider = ioc.Resolve(); + IAirportsProvider airportsDataProvider = ioc.Resolve(); + + IClientsProvider atcClientsDataProvider = ioc.Resolve(); + IClientsProvider pilotClientsDataProvider = ioc.Resolve(); + IClientsProvider followMeClientsDataProvider = ioc.Resolve(); + + IEnumerable providers = ioc.ResolveAll(); + + List generalDataModels = generalDataProvider.GetData().ToList(); + List clientDataModels = clientsDataProvider.GetData().ToList(); + List serversDataModels = serversDataProvider.GetData().ToList(); + List airportsDataModels = airportsDataProvider.GetData().ToList(); + + List atcDataModels = atcClientsDataProvider.GetData().ToList(); + List pilotDataModels = pilotClientsDataProvider.GetData().ToList(); + List followMeDataModels = followMeClientsDataProvider.GetData().ToList(); + + IAirTrafficControllerServerEnhancer atcServerEnhancer = ioc.Resolve(); + IPilotServerEnhancer pilotServerEnhancer = ioc.Resolve(); + IFollowMeServerEnhancer followMeServerEnhancer = ioc.Resolve(); + + atcDataModels = atcDataModels.Select(atcServerEnhancer.Enhance).Cast().ToList(); + pilotDataModels = pilotDataModels.Select(pilotServerEnhancer.Enhance).Cast().ToList(); + followMeDataModels = followMeDataModels.Select(followMeServerEnhancer.Enhance).Cast().ToList(); + + Client item = pilotDataModels.First(); + + IModelCloner modelCloner = ioc.Resolve(); + Client m = modelCloner.Clone(pilotDataModels[0]); + } + + private static void OptionDirect(string path) + { IGZipCompression compression = new GZipCompression(); IIVAOWhazzupDataSource nonCachedWebDataSource = new WebIVAOWhazzupDataSource("http://api.ivao.aero/getdata/whazzup/whazzup.txt"); @@ -37,6 +97,7 @@ public static void Main(string[] args) ICachedIVAOWhazzupDataSource dataSource = new CachedIVAOWhazzupDataSource(nonCachedLocalGZippedDataSource); IParserFactory parserFactory = new ParserFactory(); + IGeneralSelector generalSelector = new GeneralSelector(); IClientsSelector clientsSelector = new ClientsSelector(); IServersSelector serverSelector = new ServersSelector(); @@ -60,26 +121,18 @@ public static void Main(string[] args) List pilotDataModels = pilotClientsDataProvider.GetData().ToList(); List followMeDataModels = followMeClientsDataProvider.GetData().ToList(); - Client item = pilotDataModels.First(); + IAirTrafficControllerServerEnhancer atcServerEnhancer = new AirTrafficControllerServerEnhancer(serversDataProvider); + IPilotServerEnhancer pilotServerEnhancer = new PilotServerEnhancer(serversDataProvider); + IFollowMeServerEnhancer followMeServerEnhancer = new FollowMeServerEnhancer(serversDataProvider); - TrySerialize(item); - } + atcDataModels = atcDataModels.Select(atcServerEnhancer.Enhance).Cast().ToList(); + pilotDataModels = pilotDataModels.Select(pilotServerEnhancer.Enhance).Cast().ToList(); + followMeDataModels = followMeDataModels.Select(followMeServerEnhancer.Enhance).Cast().ToList(); - private static void TrySerialize(Client item) - { - using (MemoryStream ms = new MemoryStream()) - { - DataContractSerializer ser = new DataContractSerializer(typeof(Pilot)); - ser.WriteObject(ms, item); - - byte[] d = ms.ToArray(); - string s = Encoding.UTF8.GetString(d); - - ms.Position = 0; + Client item = pilotDataModels.First(); - XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(ms, new XmlDictionaryReaderQuotas()); - object deserializedPerson = ser.ReadObject(reader, true); - } + IModelCloner modelCloner = new ModelCloner(); + Client m = modelCloner.Clone(pilotDataModels[0]); } private static string GetPath() diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IVAOLibrary.ico b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IVAOLibrary.ico new file mode 100644 index 0000000..a7ba059 Binary files /dev/null and b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IVAOLibrary.ico differ diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IvaoIocExtensions.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IvaoIocExtensions.cs new file mode 100644 index 0000000..c25f50d --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/IvaoIocExtensions.cs @@ -0,0 +1,99 @@ +using MalikP.IVAO.Library.Common; +using MalikP.IVAO.Library.Common.Enhancers; +using MalikP.IVAO.Library.Common.Parsers; +using MalikP.IVAO.Library.Common.Selector; +using MalikP.IVAO.Library.Data.Source; +using MalikP.IVAO.Library.Models.Airports; +using MalikP.IVAO.Library.Models.Clients; +using MalikP.IVAO.Library.Models.General; +using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; +using MalikP.IVAO.Library.Providers; + +namespace MalikP.IoC +{ + public static class IvaoIocExtensions + { + public static IIoC RegisterIvaoDefaultWhazzupServices(this IIoC ioc) + { + ioc.Register(); + + ioc.Register(); + + //ioc.Register(); + //ioc.Register(); + //ioc.Register(); + //ioc.Register(); + + ioc.Register(); + ioc.Register(); + ioc.Register(); + ioc.Register(); + + ioc.Register(); + ioc.Register(); + ioc.Register(); + ioc.Register(); + + ioc.Register(); + ioc.Register(); + ioc.Register(); + + ioc.Register(); + ioc.Register(); + ioc.Register(); + + ioc.Register(); + ioc.Register(); + ioc.Register(); + + ioc.Register(); + + return ioc; + } + + /// + /// You have to register one service manually. + /// Possibilities: , , + /// , + /// + /// container + /// container + public static IIoC RegisterIvaoCachedDataSource(this IIoC ioc) + { + ioc.Register() + .Extend() + .ToSingleton(); + + ioc.Register(d => d.Resolve()); + + return ioc; + } + + public static IIoC RegisterIvaoSpecificDataSource(this IIoC ioc, TSpecific instance) + where TSpecific : IIVAOWhazzupSpecificDataSource + { + ioc.Register(instance); + + return ioc; + } + + public static IIoC RegisterIvaoModelBuilders(this IIoC ioc) + { + ioc.Register(_ => AirportBuilder.Create()); + + ioc.Register(_ => AirTrafficControllerBuilder.Create()); + ioc.Register(_ => FollowMeBuilder.Create()); + ioc.Register(_ => PilotBuilder.Create()); + + ioc.Register(_ => GeneralDataBuilder.Create()); + + ioc.Register(_ => FlightPlanBuilder.Create()); + ioc.Register(_ => GPSBuilder.Create()); + + ioc.Register(_ => ServerBuilder.Create()); + + return ioc; + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/MalikP.IVAO.Library.IoC.csproj b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/MalikP.IVAO.Library.IoC.csproj new file mode 100644 index 0000000..42323cd --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.IoC/MalikP.IVAO.Library.IoC.csproj @@ -0,0 +1,41 @@ + + + + netstandard2.1;netstandard2.0;net472;net471;net47;net462;net461;net46;net452;net451;net45 + + MalikP.IVAO.Library.IoC + 0.8.6 + Peter Malik (MalikP.) + Peter Malik (MalikP.) + MalikP. IVAO Library - IoC + Library to process IVAO data + Copyright © 2019 Peter Malik. (MalikP.) + https://github.com/peterM/IVAO-Library + https://github.com/peterM/IVAO-Library + GIT + IVAO;WHAZZUP + false + LICENSE + true + IVAOLibrary.ico + https://raw.githubusercontent.com/peterM/IVAO-Library/master/resource/IVAOLibrary64x64.png + + + + + + + + + + + + + + + True + + + + + diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsATCDataModelTest.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsATCDataModelTest.cs index 7e194d9..54e1a5c 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsATCDataModelTest.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsATCDataModelTest.cs @@ -30,7 +30,7 @@ public void Equals_WhenTwoSameInstancesAreCreated_ThenInstancesAreEqual() .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -66,7 +66,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -81,7 +81,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -117,7 +117,7 @@ public void GetHashCode_WhenTwoSameInstancesAreCreated_ThenInstanceHashCodesAreE .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -154,7 +154,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -169,7 +169,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -206,7 +206,7 @@ public void Equals_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstancesAreE .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -245,7 +245,7 @@ public void GetHashCode_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstance .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -285,7 +285,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesHashCodesAreEqual() .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") @@ -324,7 +324,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesAreEqual() .WithName("name") .WithProtocol("protocol") .WithRating(ATCRating.SeniorController) - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("1.2.3") .WithVID("123456") diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsFollowMeDataModelTest.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsFollowMeDataModelTest.cs index 1d33c50..a892c3d 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsFollowMeDataModelTest.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsFollowMeDataModelTest.cs @@ -25,7 +25,7 @@ public void Equals_WhenTwoSameInstancesAreCreated_ThenInstancesAreEqual() .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -55,7 +55,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -65,7 +65,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithCallsign("LZKZ_FOLLOW") .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -95,7 +95,7 @@ public void GetHashCode_WhenTwoSameInstancesAreCreated_ThenInstanceHashCodesAreE .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -126,7 +126,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -137,7 +137,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -168,7 +168,7 @@ public void Equals_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstancesAreE .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -201,7 +201,7 @@ public void GetHashCode_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstance .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -235,7 +235,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesHashCodesAreEqual() .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); @@ -268,7 +268,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesAreEqual() .WithLocation(null) .WithName("name") .WithProtocol("protocol") - .WithServer("server") + .WithServer(null) .WithSoftwareName("IVAC") .WithSoftwareVersion("3.2.1.3") .WithVID("1234567"); diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsPilotDataModelTest.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsPilotDataModelTest.cs index 5d14779..2d66a1d 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsPilotDataModelTest.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library.Test/Models/ClientsPilotDataModelTest.cs @@ -32,7 +32,7 @@ public void Equals_WhenTwoSameInstancesAreCreated_ThenInstancesAreEqual() .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -70,7 +70,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -87,7 +87,7 @@ public void Equals_WhenTwoDifferentInstancesAreCreated_ThenInstancesAreNotEqual( .WithHeading(222) .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -125,7 +125,7 @@ public void GetHashCode_WhenTwoSameInstancesAreCreated_ThenInstanceHashCodesAreE .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -164,7 +164,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -181,7 +181,7 @@ public void GetHashCode_WhenTwoDifferentInstancesAreCreated_ThenInstanceHashCode .WithHeading(222) .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -220,7 +220,7 @@ public void Equals_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstancesAreE .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -261,7 +261,7 @@ public void GetHashCode_WhenInstanceIsDeseraializeAndSerializedBack_ThenInstance .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -303,7 +303,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesHashCodesAreEqual() .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") @@ -344,7 +344,7 @@ public void Clone_WhenInstanceCloned_ThenInstancesAreEqual() .WithPlaneMTL("mtl") .WithProtocol("protocol") .WithRating(PilotRating.AirlineTransportPilot) - .WithServer("server") + .WithServer(null) .WithSoftwareName("sw name") .WithSoftwareVersion("1.2.3.4") .WithTransponderCode("7200") diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AbstractServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AbstractServerEnhancer.cs new file mode 100644 index 0000000..fea98a7 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AbstractServerEnhancer.cs @@ -0,0 +1,51 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: AbstractServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using MalikP.IVAO.Library.Models; +using MalikP.IVAO.Library.Models.Clients; +using MalikP.IVAO.Library.Providers; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public abstract class AbstractServerEnhancer : IDataEnhancer + where TClientModel : Client + { + protected AbstractServerEnhancer(IServersProvider serversProvider) + { + ServersProvider = serversProvider; + } + + protected IServersProvider ServersProvider { get; } + + public abstract TClientModel Enhance(TClientModel modelToEnhance); + + public IModel Enhance(IModel modelToEnhance) + { + return Enhance((TClientModel)modelToEnhance); + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AirTrafficControllerServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AirTrafficControllerServerEnhancer.cs new file mode 100644 index 0000000..c86746e --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/AirTrafficControllerServerEnhancer.cs @@ -0,0 +1,62 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: AirTrafficControllerServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Linq; +using MalikP.IVAO.Library.Models.Clients; +using MalikP.IVAO.Library.Models.Servers; +using MalikP.IVAO.Library.Providers; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public class AirTrafficControllerServerEnhancer : AbstractServerEnhancer, IAirTrafficControllerServerEnhancer + { + public AirTrafficControllerServerEnhancer(IServersProvider serversProvider) + : base(serversProvider) + { + } + + public override AirTrafficController Enhance(AirTrafficController modelToEnhance) + { + if (modelToEnhance.Server == null) + { + return modelToEnhance; + } + + Server server = ServersProvider.GetData() + .FirstOrDefault(d => d.Hostname == modelToEnhance.Server.Hostname); + + if (server == null) + { + return modelToEnhance; + } + + return AirTrafficControllerBuilder.FromModel(modelToEnhance) + .WithServer((Server)server.Clone()) + .Build(); + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/FollowMeServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/FollowMeServerEnhancer.cs new file mode 100644 index 0000000..29eb298 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/FollowMeServerEnhancer.cs @@ -0,0 +1,62 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: FollowMeServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Linq; +using MalikP.IVAO.Library.Models.Clients; +using MalikP.IVAO.Library.Models.Servers; +using MalikP.IVAO.Library.Providers; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public class FollowMeServerEnhancer : AbstractServerEnhancer, IFollowMeServerEnhancer + { + public FollowMeServerEnhancer(IServersProvider serversProvider) + : base(serversProvider) + { + } + + public override FollowMe Enhance(FollowMe modelToEnhance) + { + if (modelToEnhance.Server == null) + { + return modelToEnhance; + } + + Server server = ServersProvider.GetData() + .FirstOrDefault(d => d.Hostname == modelToEnhance.Server.Hostname); + + if (server == null) + { + return modelToEnhance; + } + + return FollowMeBuilder.FromModel(modelToEnhance) + .WithServer((Server)server.Clone()) + .Build(); + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IAirTrafficControllerServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IAirTrafficControllerServerEnhancer.cs new file mode 100644 index 0000000..d1f54f6 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IAirTrafficControllerServerEnhancer.cs @@ -0,0 +1,35 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: IAirTrafficControllerServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using MalikP.IVAO.Library.Models.Clients; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public interface IAirTrafficControllerServerEnhancer : IDataEnhancer + { + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IDataEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IDataEnhancer.cs new file mode 100644 index 0000000..56a4a54 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IDataEnhancer.cs @@ -0,0 +1,42 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: IDataEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using MalikP.IVAO.Library.Models; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public interface IDataEnhancer + { + IModel Enhance(IModel modelToEnhance); + } + + public interface IDataEnhancer : IDataEnhancer + where TModelToEnhance : IModel + { + TModelToEnhance Enhance(TModelToEnhance modelToEnhance); + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IFollowMeServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IFollowMeServerEnhancer.cs new file mode 100644 index 0000000..c669965 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IFollowMeServerEnhancer.cs @@ -0,0 +1,35 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: IFollowMeServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using MalikP.IVAO.Library.Models.Clients; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public interface IFollowMeServerEnhancer : IDataEnhancer + { + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IPilotServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IPilotServerEnhancer.cs new file mode 100644 index 0000000..6c493c0 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/IPilotServerEnhancer.cs @@ -0,0 +1,35 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: IPilotServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using MalikP.IVAO.Library.Models.Clients; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public interface IPilotServerEnhancer : IDataEnhancer + { + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/PilotServerEnhancer.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/PilotServerEnhancer.cs new file mode 100644 index 0000000..d2a7498 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Enhancers/PilotServerEnhancer.cs @@ -0,0 +1,63 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: PilotServerEnhancer.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Linq; + +using MalikP.IVAO.Library.Models.Clients; +using MalikP.IVAO.Library.Models.Servers; +using MalikP.IVAO.Library.Providers; + +namespace MalikP.IVAO.Library.Common.Enhancers +{ + public class PilotServerEnhancer : AbstractServerEnhancer, IPilotServerEnhancer + { + public PilotServerEnhancer(IServersProvider serversProvider) + : base(serversProvider) + { + } + + public override Pilot Enhance(Pilot modelToEnhance) + { + if (modelToEnhance.Server == null) + { + return modelToEnhance; + } + + Server server = ServersProvider.GetData() + .FirstOrDefault(d => d.Hostname == modelToEnhance.Server.Hostname); + + if (server == null) + { + return modelToEnhance; + } + + return PilotBuilder.FromModel(modelToEnhance) + .WithServer((Server)server.Clone()) + .Build(); + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/AbstractClientFactory.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/AbstractClientFactory.cs index bcc62c2..aed2346 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/AbstractClientFactory.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/AbstractClientFactory.cs @@ -32,6 +32,7 @@ using MalikP.IVAO.Library.Common.Parsers.DataExtractors.Client; using MalikP.IVAO.Library.Models.Clients; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Common.Parsers { @@ -69,13 +70,14 @@ protected TBuilder AssignGeneralData(TBuilder builder, string[] rowDat where TBuilder : AbstractClientBuilder { GPS location = GetLocation(rowData); + Server server = GetServer(rowData); return builder .WithCallsign(rowData[ClientIndex.All.Callsign]) .WithVID(rowData[ClientIndex.All.VID]) .WithName(rowData[ClientIndex.All.Name]) .WithLocation(location) - .WithServer(rowData[ClientIndex.All.Server]) + .WithServer(server) .WithProtocol(rowData[ClientIndex.All.Protocol]) .WithConnectionTime(_ivaoStringService.IVAO_GetDateTime(rowData[ClientIndex.All.ConnectionTime]) ?? DateTime.MinValue) .WithSoftwareName(rowData[ClientIndex.All.SoftwareName]) @@ -83,5 +85,12 @@ protected TBuilder AssignGeneralData(TBuilder builder, string[] rowDat .WithAdministrativeVersion((AdministrativeRating)_ivaoStringService.IVAO_GetInt(rowData[ClientIndex.All.AdministrativeVersion])) .WithClientRating(_ivaoStringService.IVAO_GetInt(rowData[ClientIndex.All.ClientRating])); } + + private Server GetServer(string[] rowData) + { + return ServerBuilder.Create() + .WithHostname(rowData[ClientIndex.All.Server]) + .Build(); + } } } \ No newline at end of file diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/ServerParser.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/ServerParser.cs index b2fa879..c9a286a 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/ServerParser.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Common/Parsers/ServerParser.cs @@ -26,7 +26,7 @@ // SOFTWARE. using System; - +using System.Net; using MalikP.IVAO.Library.Common.Indexes; using MalikP.IVAO.Library.Common.Selector; using MalikP.IVAO.Library.Models.Servers; @@ -56,7 +56,7 @@ protected override Server CreateItem(string data) return ServerBuilder.Create() .WithHostname(dataItems[ServerIndex.Hostname]) - .WithIP(dataItems[ServerIndex.IP]) + .WithIP(IPAddress.Parse(dataItems[ServerIndex.IP])) .WithLocation(dataItems[ServerIndex.Location]) .WithName(dataItems[ServerIndex.Name]) .WithConnectionsAllowed(Convert.ToBoolean(Convert.ToInt16(dataItems[ServerIndex.ConnectionsAllowed]))) diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/CachedIVAOWhazzupDataSource.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/CachedIVAOWhazzupDataSource.cs index 7e6cee3..daa8a6f 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/CachedIVAOWhazzupDataSource.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/CachedIVAOWhazzupDataSource.cs @@ -35,9 +35,14 @@ public sealed class CachedIVAOWhazzupDataSource : AbstractIVAOWhazzupDataSource, private readonly IIVAOWhazzupDataSource _datasource; private IWhazzup _cache; - public CachedIVAOWhazzupDataSource(IIVAOWhazzupDataSource ivaoWhazzupDataSource) + public CachedIVAOWhazzupDataSource(IIVAOWhazzupSpecificDataSource specificDataSource) + : this(specificDataSource as IIVAOWhazzupDataSource) { - _datasource = ivaoWhazzupDataSource; + } + + public CachedIVAOWhazzupDataSource(IIVAOWhazzupDataSource dataSource) + { + _datasource = dataSource; } public void DeleteCache() diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ICachedIVAOWhazzupDataSource.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ICachedIVAOWhazzupDataSource.cs index a044b58..ae00453 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ICachedIVAOWhazzupDataSource.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ICachedIVAOWhazzupDataSource.cs @@ -27,7 +27,7 @@ namespace MalikP.IVAO.Library.Data.Source { - public interface ICachedIVAOWhazzupDataSource : IIVAOWhazzupDataSource + public interface ICachedIVAOWhazzupDataSource : IIVAOWhazzupSpecificDataSource { void DeleteCache(); } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IIVAOWhazzupSpecificDataSource.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IIVAOWhazzupSpecificDataSource.cs new file mode 100644 index 0000000..9559588 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IIVAOWhazzupSpecificDataSource.cs @@ -0,0 +1,33 @@ +// MIT License +// +// Copyright (c) 2019 Peter Malik. (MalikP.) +// +// File: IIVAOWhazzupSpecificDataSource.cs +// Company: MalikP. +// +// Repository: https://github.com/peterM/IVAO-Library +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace MalikP.IVAO.Library.Data.Source +{ + public interface IIVAOWhazzupSpecificDataSource : IIVAOWhazzupDataSource + { + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ILocalIVAOWhazzupDataSource.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ILocalIVAOWhazzupDataSource.cs index e759967..60927cc 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ILocalIVAOWhazzupDataSource.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/ILocalIVAOWhazzupDataSource.cs @@ -27,7 +27,7 @@ namespace MalikP.IVAO.Library.Data.Source { - public interface ILocalIVAOWhazzupDataSource : IIVAOWhazzupDataSource + public interface ILocalIVAOWhazzupDataSource : IIVAOWhazzupSpecificDataSource { } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IWebIVAOWhazzupDataSource.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IWebIVAOWhazzupDataSource.cs index 785be2c..577ea06 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IWebIVAOWhazzupDataSource.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Data/Source/IWebIVAOWhazzupDataSource.cs @@ -27,7 +27,7 @@ namespace MalikP.IVAO.Library.Data.Source { - public interface IWebIVAOWhazzupDataSource : IIVAOWhazzupDataSource + public interface IWebIVAOWhazzupDataSource : IIVAOWhazzupSpecificDataSource { } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/MalikP.IVAO.Library.csproj b/src/MalikP. IVAO Library/MalikP.IVAO.Library/MalikP.IVAO.Library.csproj index df404fa..29d4abc 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/MalikP.IVAO.Library.csproj +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/MalikP.IVAO.Library.csproj @@ -3,7 +3,7 @@ netstandard2.1;netstandard2.0;net472;net471;net47;net462;net461;net46;net452;net451;net45 MalikP.IVAO.Library - 0.8.5 + 0.8.6 Peter Malik (MalikP.) Peter Malik (MalikP.) MalikP. IVAO Library diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/AbstractIvaoModel.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/AbstractIvaoModel.cs index 9ada301..b76eb08 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/AbstractIvaoModel.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/AbstractIvaoModel.cs @@ -73,5 +73,15 @@ protected int GetItemHashCode(object item) return item.GetHashCode(); } } + + public static bool operator !=(AbstractIvaoModel instance1, AbstractIvaoModel instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(AbstractIvaoModel instance1, AbstractIvaoModel instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Airports/Airport.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Airports/Airport.cs index 7d29eff..00c07f8 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Airports/Airport.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Airports/Airport.cs @@ -87,5 +87,15 @@ public override object Clone() } public static AirportBuilder Builder => AirportBuilder.Create(); + + public static bool operator !=(Airport instance1, Airport instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(Airport instance1, Airport instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AbstractClientBuilder.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AbstractClientBuilder.cs index 49339d3..43f9e5f 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AbstractClientBuilder.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AbstractClientBuilder.cs @@ -29,6 +29,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -39,7 +40,7 @@ public abstract class AbstractClientBuilder protected string name; protected ClientType clientType; protected GPS location; - protected string server; + protected Server server; protected string protocol; protected DateTime connectionTime; protected string softwareName; @@ -77,7 +78,7 @@ public TBuilder WithLocation(GPS location) return GetBuilder(); } - public TBuilder WithServer(string server) + public TBuilder WithServer(Server server) { this.server = server; return GetBuilder(); diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficController.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficController.cs index e3150a6..f0c77e0 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficController.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficController.cs @@ -31,6 +31,7 @@ using MalikP.IVAO.Library.Common.Annotation; using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -43,7 +44,7 @@ public AirTrafficController( string name, ClientType clientType, GPS location, - string server, + Server server, string protocol, DateTime connectionTime, string softwareName, @@ -146,5 +147,15 @@ public override object Clone() } public static AirTrafficControllerBuilder Builder => AirTrafficControllerBuilder.Create(); + + public static bool operator !=(AirTrafficController instance1, AirTrafficController instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(AirTrafficController instance1, AirTrafficController instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficControllerBuilder.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficControllerBuilder.cs index 1608cac..d11e5c1 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficControllerBuilder.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/AirTrafficControllerBuilder.cs @@ -29,6 +29,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -57,12 +58,12 @@ public static AirTrafficControllerBuilder FromModel(AirTrafficController model) .WithClientType(model.ClientType) .WithAdministrativeVersion(model.AdministrativeVersion) .WithCallsign(model.Callsign) - .WithClientRating(model.ClientRating) + .WithClientRating((int)model.ClientRating) .WithConnectionTime(model.ConnectionTime) .WithLocation(model.Location == null ? model.Location : (GPS)model.Location.Clone()) .WithName(model.Name) .WithProtocol(model.Protocol) - .WithServer(model.Server) + .WithServer(model.Server == null ? null : (Server)model.Server.Clone()) .WithSoftwareName(model.SoftwareName) .WithSoftwareVersion(model.SoftwareVersion) .WithVID(model.VID) diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Client.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Client.cs index ae3d866..e319188 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Client.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Client.cs @@ -31,10 +31,15 @@ using MalikP.IVAO.Library.Common.Annotation; using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { [DataContract] + [KnownType(typeof(AirTrafficController))] + [KnownType(typeof(Pilot))] + [KnownType(typeof(FollowMe))] + [KnownType(typeof(ClientWithRating<>))] public abstract class Client : AbstractIvaoModel { public Client( @@ -43,7 +48,7 @@ public Client( string name, ClientType clientType, GPS location, - string server, + Server server, string protocol, DateTime connectionTime, string softwareName, @@ -56,7 +61,7 @@ public Client( Name = name ?? string.Empty; ClientType = clientType; Location = location; - Server = server ?? string.Empty; + Server = server; Protocol = protocol ?? string.Empty; ConnectionTime = connectionTime; SoftwareName = softwareName ?? string.Empty; @@ -88,7 +93,7 @@ protected Client() public GPS Location { get; private set; } [DataMember] - public string Server { get; private set; } + public Server Server { get; private set; } [DataMember] public string Protocol { get; private set; } @@ -132,7 +137,7 @@ public override bool Equals(object obj) && string.Equals(casted.Name, Name, StringComparison.InvariantCultureIgnoreCase) && Equals(casted.ClientType, ClientType) && Equals(casted.Location, Location) - && string.Equals(casted.Server, Server, StringComparison.InvariantCultureIgnoreCase) + && Equals(casted.Server, Server) && string.Equals(casted.Protocol, Protocol, StringComparison.InvariantCultureIgnoreCase) && Equals(casted.ConnectionTime, ConnectionTime) && string.Equals(casted.SoftwareName, SoftwareName, StringComparison.InvariantCultureIgnoreCase) @@ -151,7 +156,7 @@ public override int GetHashCode() + (Name.ToUpper().GetHashCode() * 3) + (ClientType.GetHashCode() * 3) + (GetItemHashCode(Location) * 3) - + (Server.ToUpper().GetHashCode() * 3) + + (GetItemHashCode(Server) * 3) + (Protocol.ToUpper().GetHashCode() * 3) + (ConnectionTime.GetHashCode() * 3) + (SoftwareName.ToUpper().GetHashCode() * 3) @@ -160,5 +165,15 @@ public override int GetHashCode() + (ClientRating.GetHashCode() * 3) * 17; } } + + public static bool operator !=(Client instance1, Client instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(Client instance1, Client instance2) + { + return Equals(instance1, instance2); + } } } \ No newline at end of file diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/ClientWithRating.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/ClientWithRating.cs index a740a0a..0c3054f 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/ClientWithRating.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/ClientWithRating.cs @@ -30,6 +30,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -42,7 +43,7 @@ public ClientWithRating( string name, ClientType clientType, GPS location, - string server, + Server server, string protocol, DateTime connectionTime, string softwareName, @@ -72,5 +73,7 @@ protected ClientWithRating() [DataMember] public TRating Rating { get; private set; } + + public new TRating ClientRating => (TRating)Enum.Parse(typeof(TRating), base.ClientRating.ToString()); } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMe.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMe.cs index 2750992..bc472dc 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMe.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMe.cs @@ -30,6 +30,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -42,7 +43,7 @@ public FollowMe( string name, ClientType clientType, GPS location, - string server, + Server server, string protocol, DateTime connectionTime, string softwareName, @@ -104,5 +105,15 @@ public override object Clone() } public static FollowMeBuilder Builder => FollowMeBuilder.Create(); + + public static bool operator !=(FollowMe instance1, FollowMe instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(FollowMe instance1, FollowMe instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMeBuilder.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMeBuilder.cs index b1ed461..372d3e0 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMeBuilder.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/FollowMeBuilder.cs @@ -27,6 +27,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -52,7 +53,7 @@ public static FollowMeBuilder FromModel(FollowMe model) .WithLocation(model.Location == null ? model.Location : (GPS)model.Location.Clone()) .WithName(model.Name) .WithProtocol(model.Protocol) - .WithServer(model.Server) + .WithServer(model.Server == null ? null : (Server)model.Server.Clone()) .WithSoftwareName(model.SoftwareName) .WithSoftwareVersion(model.SoftwareVersion) .WithVID(model.VID); diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Pilot.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Pilot.cs index 13eb9ee..3837558 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Pilot.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/Pilot.cs @@ -31,6 +31,7 @@ using MalikP.IVAO.Library.Common.Annotation; using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -43,7 +44,7 @@ public Pilot( string name, ClientType clientType, GPS location, - string server, + Server server, string protocol, DateTime connectionTime, string softwareName, @@ -158,5 +159,15 @@ public override object Clone() } public static PilotBuilder Builder => PilotBuilder.Create(); + + public static bool operator !=(Pilot instance1, Pilot instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(Pilot instance1, Pilot instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/PilotBuilder.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/PilotBuilder.cs index 02ccf07..617fdac 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/PilotBuilder.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Clients/PilotBuilder.cs @@ -27,6 +27,7 @@ using MalikP.IVAO.Library.Common.Enums; using MalikP.IVAO.Library.Models.Other; +using MalikP.IVAO.Library.Models.Servers; namespace MalikP.IVAO.Library.Models.Clients { @@ -56,12 +57,12 @@ public static PilotBuilder FromModel(Pilot model) .WithClientType(model.ClientType) .WithAdministrativeVersion(model.AdministrativeVersion) .WithCallsign(model.Callsign) - .WithClientRating(model.ClientRating) + .WithClientRating((int)model.ClientRating) .WithConnectionTime(model.ConnectionTime) .WithLocation(model.Location == null ? model.Location : (GPS)model.Location.Clone()) .WithName(model.Name) .WithProtocol(model.Protocol) - .WithServer(model.Server) + .WithServer(model.Server == null ? null : (Server)model.Server.Clone()) .WithSoftwareName(model.SoftwareName) .WithSoftwareVersion(model.SoftwareVersion) .WithVID(model.VID) diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/General/GeneralData.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/General/GeneralData.cs index 776f0ea..cbd98e9 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/General/GeneralData.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/General/GeneralData.cs @@ -119,5 +119,15 @@ public override object Clone() } public static GeneralDataBuilder Builder => GeneralDataBuilder.Create(); + + public static bool operator !=(GeneralData instance1, GeneralData instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(GeneralData instance1, GeneralData instance2) + { + return Equals(instance1, instance2); + } } } \ No newline at end of file diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/Aerodrome.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/Aerodrome.cs index 118c456..3473c68 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/Aerodrome.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/Aerodrome.cs @@ -80,5 +80,15 @@ public override int GetHashCode() return ICAO.ToUpper().GetHashCode() * 3 * 17; } } + + public static bool operator !=(Aerodrome instance1, Aerodrome instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(Aerodrome instance1, Aerodrome instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/FlightPlan.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/FlightPlan.cs index 2883b16..e921651 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/FlightPlan.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/FlightPlan.cs @@ -211,5 +211,15 @@ public object Clone() } public static FlightPlanBuilder Builder => FlightPlanBuilder.Create(); + + public static bool operator !=(FlightPlan instance1, FlightPlan instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(FlightPlan instance1, FlightPlan instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/GPS.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/GPS.cs index 9556641..ba2b21c 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/GPS.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Other/GPS.cs @@ -101,5 +101,15 @@ public object Clone() } public static GPSBuilder Builder => GPSBuilder.Create(); + + public static bool operator !=(GPS instance1, GPS instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(GPS instance1, GPS instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/Server.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/Server.cs index 1195834..582279d 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/Server.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/Server.cs @@ -26,6 +26,7 @@ // SOFTWARE. using System; +using System.Net; using System.Runtime.Serialization; namespace MalikP.IVAO.Library.Models.Servers @@ -35,14 +36,14 @@ public sealed class Server : AbstractIvaoModel { public Server( string hostname, - string ip, + IPAddress ip, string location, string name, bool connectionsAllowed, int maximumConnections) { Hostname = hostname ?? string.Empty; - IP = ip ?? string.Empty; + IP = ip; Location = location ?? string.Empty; Name = name ?? string.Empty; ConnectionsAllowed = connectionsAllowed; @@ -56,8 +57,14 @@ private Server() [DataMember] public string Hostname { get; private set; } + public IPAddress IP { get; private set; } + [DataMember] - public string IP { get; private set; } + private string IPAddressIntenal + { + get { return IP == null ? string.Empty : IP.ToString(); } + set { IP = IPAddress.Parse(value); } + } [DataMember] public string Location { get; private set; } @@ -91,7 +98,7 @@ public override bool Equals(object obj) return base.Equals(obj) && string.Equals(casted.Hostname, Hostname, StringComparison.InvariantCultureIgnoreCase) - && string.Equals(casted.IP, IP, StringComparison.InvariantCultureIgnoreCase) + && Equals(casted.IP, IP) && Equals(casted.ConnectionsAllowed, ConnectionsAllowed) && Equals(casted.MaximumConnections, MaximumConnections) && string.Equals(casted.Name, Name, StringComparison.InvariantCultureIgnoreCase) @@ -104,7 +111,7 @@ public override int GetHashCode() { return base.GetHashCode() + (Hostname.ToUpper().GetHashCode() * 3) - + (IP.ToUpper().GetHashCode() * 3) + + (IP.GetHashCode() * 3) + (ConnectionsAllowed.GetHashCode() * 3) + (MaximumConnections.GetHashCode() * 3) + (Name.ToUpper().GetHashCode() * 3) @@ -119,5 +126,15 @@ public override object Clone() } public static ServerBuilder Builder => ServerBuilder.Create(); + + public static bool operator !=(Server instance1, Server instance2) + { + return !Equals(instance1, instance2); + } + + public static bool operator ==(Server instance1, Server instance2) + { + return Equals(instance1, instance2); + } } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/ServerBuilder.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/ServerBuilder.cs index 222a672..294266f 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/ServerBuilder.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Servers/ServerBuilder.cs @@ -25,12 +25,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +using System.Net; + namespace MalikP.IVAO.Library.Models.Servers { public sealed class ServerBuilder { private string _hostname; - private string _ip; + private IPAddress _ip; private string _location; private string _name; private bool _connectionsAllowed; @@ -50,7 +52,7 @@ public static ServerBuilder FromModel(Server model) return new ServerBuilder() .WithConnectionsAllowed(model.ConnectionsAllowed) .WithHostname(model.Hostname) - .WithIP(model.IP) + .WithIP(model.IP == null ? null : IPAddress.Parse(model.IP.ToString())) .WithLocation(model.Location) .WithMaximumConnections(model.MaximumConnections) .WithName(model.Name); @@ -62,12 +64,17 @@ public ServerBuilder WithHostname(string hostname) return this; } - public ServerBuilder WithIP(string ip) + public ServerBuilder WithIP(IPAddress ip) { _ip = ip; return this; } + public ServerBuilder WithIP(string ip) + { + return WithIP(IPAddress.Parse(ip)); + } + public ServerBuilder WithLocation(string location) { _location = location; diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AbstractStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AbstractStatusItem.cs new file mode 100644 index 0000000..fd3fe75 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AbstractStatusItem.cs @@ -0,0 +1,24 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public abstract class AbstractStatusItem + { + protected AbstractStatusItem(string key, string value) + { + Key = key; + Value = value; + } + + protected AbstractStatusItem() + { + } + + [DataMember] + public string Key { get; private set; } + + [DataMember] + public string Value { get; private set; } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AtisStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AtisStatusItem.cs new file mode 100644 index 0000000..2ad995a --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/AtisStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class AtisStatusItem : AbstractStatusItem + { + private AtisStatusItem() + { + } + + public AtisStatusItem(string value) + : base("atis0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/GZippedWhazzupStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/GZippedWhazzupStatusItem.cs new file mode 100644 index 0000000..f73cd05 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/GZippedWhazzupStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class GZippedWhazzupStatusItem : AbstractStatusItem + { + private GZippedWhazzupStatusItem() + { + } + + public GZippedWhazzupStatusItem(string value) + : base("gzurl0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/MetarStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/MetarStatusItem.cs new file mode 100644 index 0000000..ca58138 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/MetarStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class MetarStatusItem : AbstractStatusItem + { + private MetarStatusItem() + { + } + + public MetarStatusItem(string value) + : base("metar0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/ShortTafStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/ShortTafStatusItem.cs new file mode 100644 index 0000000..e641832 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/ShortTafStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class ShortTafStatusItem : AbstractStatusItem + { + private ShortTafStatusItem() + { + } + + public ShortTafStatusItem(string value) + : base("shorttaf0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/TafStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/TafStatusItem.cs new file mode 100644 index 0000000..5c63e46 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/TafStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class TafStatusItem : AbstractStatusItem + { + private TafStatusItem() + { + } + + public TafStatusItem(string value) + : base("taf0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/UserStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/UserStatusItem.cs new file mode 100644 index 0000000..c8ae5ee --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/UserStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class UserStatusItem : AbstractStatusItem + { + private UserStatusItem() + { + } + + public UserStatusItem(string value) + : base("user0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/VoiceStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/VoiceStatusItem.cs new file mode 100644 index 0000000..6115781 --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/VoiceStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class VoiceStatusItem : AbstractStatusItem + { + private VoiceStatusItem() + { + } + + public VoiceStatusItem(string value) + : base("url1", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/WhazzupStatusItem.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/WhazzupStatusItem.cs new file mode 100644 index 0000000..700101b --- /dev/null +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Models/Status/WhazzupStatusItem.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; + +namespace MalikP.IVAO.Library.Models.Status +{ + [DataContract] + public sealed class WhazzupStatusItem : AbstractStatusItem + { + private WhazzupStatusItem() + { + } + + public WhazzupStatusItem(string value) + : base("url0", value) + { + } + } +} diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IAirTrafficControllersProvider.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IAirTrafficControllersProvider.cs index 5216218..c6fb378 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IAirTrafficControllersProvider.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IAirTrafficControllersProvider.cs @@ -29,7 +29,7 @@ namespace MalikP.IVAO.Library.Providers { - public interface IAirTrafficControllersProvider : IProvider + public interface IAirTrafficControllersProvider : IClientsProvider, IProvider { } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IFollowMesProvider.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IFollowMesProvider.cs index 657d68b..d762a2e 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IFollowMesProvider.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IFollowMesProvider.cs @@ -29,7 +29,7 @@ namespace MalikP.IVAO.Library.Providers { - public interface IFollowMesProvider : IProvider + public interface IFollowMesProvider : IClientsProvider, IProvider { } } diff --git a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IPilotsProvider.cs b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IPilotsProvider.cs index 37d3600..a682792 100644 --- a/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IPilotsProvider.cs +++ b/src/MalikP. IVAO Library/MalikP.IVAO.Library/Providers/IPilotsProvider.cs @@ -29,7 +29,7 @@ namespace MalikP.IVAO.Library.Providers { - public interface IPilotsProvider : IProvider + public interface IPilotsProvider : IClientsProvider, IProvider { } }