1- using System ;
1+ using NETworkManager . Settings ;
2+ using NETworkManager . Utilities ;
3+ using System ;
24using System . Collections . Generic ;
35using System . Collections . ObjectModel ;
46using System . IO ;
57using System . Linq ;
68using System . Security ;
79using System . Text ;
810using System . Xml . Serialization ;
9- using NETworkManager . Settings ;
10- using NETworkManager . Utilities ;
1111
1212namespace NETworkManager . Profiles ;
1313
@@ -482,7 +482,7 @@ public static void Save()
482482 // Only if the password provided earlier was valid...
483483 if ( LoadedProfileFile . IsPasswordValid )
484484 {
485- var decryptedBytes = SerializeToByteArray ( [ ..Groups ] ) ;
485+ var decryptedBytes = SerializeToByteArray ( [ .. Groups ] ) ;
486486 var encryptedBytes = CryptoHelper . Encrypt ( decryptedBytes ,
487487 SecureStringHelper . ConvertToString ( LoadedProfileFile . Password ) ,
488488 GlobalStaticConfiguration . Profile_EncryptionKeySize ,
@@ -493,7 +493,7 @@ public static void Save()
493493 }
494494 else
495495 {
496- SerializeToFile ( LoadedProfileFile . Path , [ ..Groups ] ) ;
496+ SerializeToFile ( LoadedProfileFile . Path , [ .. Groups ] ) ;
497497 }
498498
499499 ProfilesChanged = false ;
@@ -579,25 +579,25 @@ private static List<GroupInfoSerializable> SerializeGroup(List<GroupInfo> groups
579579 continue ;
580580
581581 var profilesSerializable = ( from profile in @group . Profiles
582- where ! profile . IsDynamic
583- select new ProfileInfoSerializable ( profile )
584- {
585- RemoteDesktop_Password = profile . RemoteDesktop_Password != null
586- ? SecureStringHelper . ConvertToString ( profile . RemoteDesktop_Password )
587- : string . Empty ,
588- RemoteDesktop_GatewayServerPassword = profile . RemoteDesktop_GatewayServerPassword != null
589- ? SecureStringHelper . ConvertToString ( profile . RemoteDesktop_GatewayServerPassword )
590- : string . Empty ,
591- SNMP_Community = profile . SNMP_Community != null
592- ? SecureStringHelper . ConvertToString ( profile . SNMP_Community )
593- : string . Empty ,
594- SNMP_Auth = profile . SNMP_Auth != null
595- ? SecureStringHelper . ConvertToString ( profile . SNMP_Auth )
596- : string . Empty ,
597- SNMP_Priv = profile . SNMP_Priv != null
598- ? SecureStringHelper . ConvertToString ( profile . SNMP_Priv )
599- : string . Empty
600- } ) . ToList ( ) ;
582+ where ! profile . IsDynamic
583+ select new ProfileInfoSerializable ( profile )
584+ {
585+ RemoteDesktop_Password = profile . RemoteDesktop_Password != null
586+ ? SecureStringHelper . ConvertToString ( profile . RemoteDesktop_Password )
587+ : string . Empty ,
588+ RemoteDesktop_GatewayServerPassword = profile . RemoteDesktop_GatewayServerPassword != null
589+ ? SecureStringHelper . ConvertToString ( profile . RemoteDesktop_GatewayServerPassword )
590+ : string . Empty ,
591+ SNMP_Community = profile . SNMP_Community != null
592+ ? SecureStringHelper . ConvertToString ( profile . SNMP_Community )
593+ : string . Empty ,
594+ SNMP_Auth = profile . SNMP_Auth != null
595+ ? SecureStringHelper . ConvertToString ( profile . SNMP_Auth )
596+ : string . Empty ,
597+ SNMP_Priv = profile . SNMP_Priv != null
598+ ? SecureStringHelper . ConvertToString ( profile . SNMP_Priv )
599+ : string . Empty
600+ } ) . ToList ( ) ;
601601
602602 groupsSerializable . Add ( new GroupInfoSerializable ( group )
603603 {
@@ -655,58 +655,58 @@ private static List<GroupInfo> DeserializeGroup(Stream stream)
655655 XmlSerializer xmlSerializer = new ( typeof ( List < GroupInfoSerializable > ) ) ;
656656
657657 return ( from groupSerializable in ( ( List < GroupInfoSerializable > ) xmlSerializer . Deserialize ( stream ) ) !
658- let profiles = groupSerializable . Profiles . Select ( profileSerializable => new ProfileInfo ( profileSerializable )
658+ let profiles = groupSerializable . Profiles . Select ( profileSerializable => new ProfileInfo ( profileSerializable )
659659 {
660660 // Migrate old data
661661 NetworkInterface_Subnetmask =
662- string . IsNullOrEmpty ( profileSerializable . NetworkInterface_Subnetmask ) &&
663- ! string . IsNullOrEmpty ( profileSerializable . NetworkInterface_SubnetmaskOrCidr )
664- ? profileSerializable . NetworkInterface_SubnetmaskOrCidr
665- : profileSerializable . NetworkInterface_Subnetmask ,
662+ string . IsNullOrEmpty ( profileSerializable . NetworkInterface_Subnetmask ) &&
663+ ! string . IsNullOrEmpty ( profileSerializable . NetworkInterface_SubnetmaskOrCidr )
664+ ? profileSerializable . NetworkInterface_SubnetmaskOrCidr
665+ : profileSerializable . NetworkInterface_Subnetmask ,
666666
667667 // Convert passwords to secure strings
668668 RemoteDesktop_Password = ! string . IsNullOrEmpty ( profileSerializable . RemoteDesktop_Password )
669- ? SecureStringHelper . ConvertToSecureString ( profileSerializable . RemoteDesktop_Password )
670- : null ,
671- RemoteDesktop_GatewayServerPassword =
672- ! string . IsNullOrEmpty ( profileSerializable . RemoteDesktop_GatewayServerPassword )
673- ? SecureStringHelper . ConvertToSecureString ( profileSerializable
674- . RemoteDesktop_GatewayServerPassword )
669+ ? SecureStringHelper . ConvertToSecureString ( profileSerializable . RemoteDesktop_Password )
675670 : null ,
671+ RemoteDesktop_GatewayServerPassword =
672+ ! string . IsNullOrEmpty ( profileSerializable . RemoteDesktop_GatewayServerPassword )
673+ ? SecureStringHelper . ConvertToSecureString ( profileSerializable
674+ . RemoteDesktop_GatewayServerPassword )
675+ : null ,
676676 SNMP_Community = ! string . IsNullOrEmpty ( profileSerializable . SNMP_Community )
677- ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Community )
678- : null ,
677+ ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Community )
678+ : null ,
679679 SNMP_Auth = ! string . IsNullOrEmpty ( profileSerializable . SNMP_Auth )
680- ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Auth )
681- : null ,
680+ ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Auth )
681+ : null ,
682682 SNMP_Priv = ! string . IsNullOrEmpty ( profileSerializable . SNMP_Priv )
683- ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Priv )
684- : null
683+ ? SecureStringHelper . ConvertToSecureString ( profileSerializable . SNMP_Priv )
684+ : null
685685 } )
686- . ToList ( )
687- select new GroupInfo ( groupSerializable )
688- {
689- Profiles = profiles ,
690-
691- // Convert passwords to secure strings
692- RemoteDesktop_Password = ! string . IsNullOrEmpty ( groupSerializable . RemoteDesktop_Password )
693- ? SecureStringHelper . ConvertToSecureString ( groupSerializable . RemoteDesktop_Password )
694- : null ,
695- RemoteDesktop_GatewayServerPassword =
696- ! string . IsNullOrEmpty ( groupSerializable . RemoteDesktop_GatewayServerPassword )
697- ? SecureStringHelper . ConvertToSecureString (
698- groupSerializable . RemoteDesktop_GatewayServerPassword )
686+ . ToList ( )
687+ select new GroupInfo ( groupSerializable )
688+ {
689+ Profiles = profiles ,
690+
691+ // Convert passwords to secure strings
692+ RemoteDesktop_Password = ! string . IsNullOrEmpty ( groupSerializable . RemoteDesktop_Password )
693+ ? SecureStringHelper . ConvertToSecureString ( groupSerializable . RemoteDesktop_Password )
699694 : null ,
700- SNMP_Community = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Community )
701- ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Community )
702- : null ,
703- SNMP_Auth = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Auth )
704- ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Auth )
705- : null ,
706- SNMP_Priv = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Priv )
707- ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Priv )
708- : null
709- } ) . ToList ( ) ;
695+ RemoteDesktop_GatewayServerPassword =
696+ ! string . IsNullOrEmpty ( groupSerializable . RemoteDesktop_GatewayServerPassword )
697+ ? SecureStringHelper . ConvertToSecureString (
698+ groupSerializable . RemoteDesktop_GatewayServerPassword )
699+ : null ,
700+ SNMP_Community = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Community )
701+ ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Community )
702+ : null ,
703+ SNMP_Auth = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Auth )
704+ ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Auth )
705+ : null ,
706+ SNMP_Priv = ! string . IsNullOrEmpty ( groupSerializable . SNMP_Priv )
707+ ? SecureStringHelper . ConvertToSecureString ( groupSerializable . SNMP_Priv )
708+ : null
709+ } ) . ToList ( ) ;
710710 }
711711
712712 #endregion
@@ -741,7 +741,7 @@ public static void AddGroup(GroupInfo group)
741741 /// </summary>
742742 /// <param name="name">Name of the group.</param>
743743 /// <returns>Group as <see cref="GroupInfo" />.</returns>
744- public static GroupInfo GetGroup ( string name )
744+ public static GroupInfo GetGroupByName ( string name )
745745 {
746746 return Groups . First ( x => x . Name . Equals ( name ) ) ;
747747 }
0 commit comments