@@ -181,6 +181,11 @@ public sealed class Dependency
181181
182182 #region Constructor
183183
184+ /// <summary>
185+ /// Parameterless constructor needed for XmlSerializer
186+ /// </summary>
187+ public Dependency ( ) { }
188+
184189 /// <summary>
185190 /// Constructor
186191 ///
@@ -230,34 +235,51 @@ public PSCommandResourceInfo(string name, PSResourceInfo parentResource)
230235
231236 #region PSResourceInfo
232237
238+ [ Serializable ]
239+ [ XmlRoot ( ElementName = "properties" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" ) ]
233240 public sealed class PSResourceInfo
234241 {
235242 #region Properties
236243
244+ [ XmlIgnoreAttribute ]
237245 public Dictionary < string , string > AdditionalMetadata { get ; }
238- public string Author { get ; }
239- public string CompanyName { get ; internal set ; }
240- public string Copyright { get ; internal set ; }
241- public Dependency [ ] Dependencies { get ; }
242- public string Description { get ; }
243- public Uri IconUri { get ; }
246+ [ XmlElement ( "Authors" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
247+ public string Author { get ; set ; }
248+ [ XmlElement ( "CompanyName" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
249+ public string CompanyName { get ; set ; }
250+ [ XmlElement ( "Copyright" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
251+ public string Copyright { get ; set ; }
252+ [ XmlElement ( "Dependencies" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
253+ public Dependency [ ] Dependencies { get ; set ; }
254+ [ XmlElement ( "Description" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
255+ public string Description { get ; set ; }
256+ [ XmlElement ( "IconUrl" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
257+ public Uri IconUri { get ; set ; }
244258 public ResourceIncludes Includes { get ; }
245- public DateTime ? InstalledDate { get ; internal set ; }
246- public string InstalledLocation { get ; internal set ; }
247- public bool IsPrerelease { get ; }
248- public Uri LicenseUri { get ; }
249- public string Name { get ; }
259+ public DateTime ? InstalledDate { get ; set ; }
260+ public string InstalledLocation { get ; set ; }
261+ [ XmlElement ( "IsPrerelease" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
262+ public bool IsPrerelease { get ; set ; }
263+ [ XmlElement ( "LicenseUrl" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
264+ public Uri LicenseUri { get ; set ; }
265+ [ XmlElement ( "Id" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
266+ public string Name { get ; set ; }
250267 public string PackageManagementProvider { get ; }
251268 public string PowerShellGetFormatVersion { get ; }
252269 public string Prerelease { get ; }
253- public Uri ProjectUri { get ; }
254- public DateTime ? PublishedDate { get ; }
255- public string ReleaseNotes { get ; internal set ; }
256- public string Repository { get ; }
257- public string RepositorySourceLocation { get ; internal set ; }
258- public string [ ] Tags { get ; }
270+ [ XmlElement ( "ProjectUrl" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
271+ public Uri ProjectUri { get ; set ; }
272+ [ XmlElement ( "Published" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
273+ public DateTime ? PublishedDate { get ; set ; }
274+ [ XmlElement ( "ReleaseNotes" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
275+ public string ReleaseNotes { get ; set ; }
276+ public string Repository { get ; set ; }
277+ public string RepositorySourceLocation { get ; set ; }
278+ [ XmlElement ( "Tags" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
279+ public string [ ] Tags { get ; set ; }
259280 public ResourceType Type { get ; }
260281 public DateTime ? UpdatedDate { get ; }
282+ [ XmlElement ( "Version" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
261283 public Version Version { get ; }
262284
263285 #endregion
@@ -565,8 +587,8 @@ public static bool TryConvert(
565587 // TODO: in progress
566588 // write a serializer
567589 public static bool TryConvertFromXml (
568- XmlNode entry , // XmlDocument doc that is already loaded
569- out PSResourceInfo2 psGetInfo ,
590+ XmlNode entry ,
591+ out PSResourceInfo psGetInfo ,
570592 string repositoryName ,
571593 ResourceType ? type ,
572594 out string errorMsg )
@@ -583,8 +605,8 @@ public static bool TryConvertFromXml(
583605 try
584606 {
585607 var xNodeReader = new XmlNodeReader ( entry ) ;
586- var xmlSerializer = new XmlSerializer ( typeof ( PSResourceInfo2 ) ) ;
587- psGetInfo = xmlSerializer . Deserialize ( xNodeReader ) as PSResourceInfo2 ;
608+ var xmlSerializer = new XmlSerializer ( typeof ( PSResourceInfo ) ) ;
609+ psGetInfo = xmlSerializer . Deserialize ( xNodeReader ) as PSResourceInfo ;
588610
589611 // Note: still need to add some info to the psGetInfo obj,
590612 return true ;
@@ -988,99 +1010,6 @@ private PSObject ConvertToCustomObject()
9881010
9891011 #endregion
9901012
991- // TODO: tmp class for testing/debugging
992- #region PSResourceInfo2
993-
994- [ Serializable ]
995- [ XmlRoot ( ElementName = "properties" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" ) ]
996- public sealed class PSResourceInfo2
997- {
998- #region Properties
999-
1000-
1001- public string Author { get ; set ; }
1002- public string Copyright { get ; set ; }
1003- public string Description { get ; set ; }
1004- public string IconUri { get ; set ; }
1005- public ResourceIncludes Includes { get ; set ; }
1006- public DateTime ? InstalledDate { get ; set ; }
1007- public string InstalledLocation { get ; set ; }
1008- public bool IsPrerelease { get ; set ; }
1009- public string LicenseUri { get ; set ; }
1010-
1011- [ XmlElement ( "Id" , Namespace = "http://schemas.microsoft.com/ado/2007/08/dataservices" ) ]
1012- public string Name { get ; set ; }
1013- public string PackageManagementProvider { get ; set ; }
1014- public string PowerShellGetFormatVersion { get ; set ; }
1015- public string Prerelease { get ; set ; }
1016- public string ProjectUri { get ; set ; }
1017- public DateTime ? PublishedDate { get ; set ; }
1018- public string ReleaseNotes { get ; set ; }
1019- public string Repository { get ; set ; }
1020- public string RepositorySourceLocation { get ; set ; }
1021- public string [ ] Tags { get ; set ; }
1022- public ResourceType Type { get ; set ; }
1023- public DateTime ? UpdatedDate { get ; set ; }
1024- public Version Version { get ; set ; }
1025-
1026- #endregion
1027-
1028- #region Constructors
1029-
1030- private PSResourceInfo2 ( ) { }
1031-
1032- private PSResourceInfo2 (
1033- string author ,
1034- string copyright ,
1035- string description ,
1036- string iconUri ,
1037- ResourceIncludes includes ,
1038- DateTime ? installedDate ,
1039- string installedLocation ,
1040- bool isPrelease ,
1041- string licenseUri ,
1042- string name ,
1043- string packageManagementProvider ,
1044- string powershellGetFormatVersion ,
1045- string prerelease ,
1046- string projectUri ,
1047- DateTime ? publishedDate ,
1048- string releaseNotes ,
1049- string repository ,
1050- string repositorySourceLocation ,
1051- string [ ] tags ,
1052- ResourceType type ,
1053- DateTime ? updatedDate ,
1054- Version version )
1055- {
1056- Author = author ?? string . Empty ;
1057- Copyright = copyright ?? string . Empty ;
1058- Description = description ?? string . Empty ;
1059- IconUri = iconUri ;
1060- Includes = includes ?? new ResourceIncludes ( ) ;
1061- InstalledDate = installedDate ;
1062- InstalledLocation = installedLocation ?? string . Empty ;
1063- IsPrerelease = isPrelease ;
1064- LicenseUri = licenseUri ;
1065- Name = name ?? string . Empty ;
1066- PackageManagementProvider = packageManagementProvider ?? string . Empty ;
1067- PowerShellGetFormatVersion = powershellGetFormatVersion ?? string . Empty ;
1068- Prerelease = prerelease ?? string . Empty ;
1069- ProjectUri = projectUri ;
1070- PublishedDate = publishedDate ;
1071- ReleaseNotes = releaseNotes ?? string . Empty ;
1072- Repository = repository ?? string . Empty ;
1073- RepositorySourceLocation = repositorySourceLocation ?? string . Empty ;
1074- Tags = tags ?? Utils . EmptyStrArray ;
1075- Type = type ;
1076- UpdatedDate = updatedDate ;
1077- Version = version ?? new Version ( ) ;
1078- }
1079- #endregion
1080-
1081- }
1082- #endregion
1083-
10841013 #region Test Hooks
10851014
10861015 public static class TestHooks
0 commit comments