Skip to content

Commit

Permalink
Changed Get-PnPTenant to generic retrieval of properties and using nu…
Browse files Browse the repository at this point in the history
…llable types instead of using hardcoded defaults in the case of an exception
  • Loading branch information
KoenZomers committed Feb 3, 2025
1 parent 8360d2d commit f5b2a56
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 592 deletions.
2 changes: 1 addition & 1 deletion src/Commands/Admin/GetTenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override void ExecuteCmdlet()
AdminContext.Load(Tenant);
AdminContext.Load(Tenant, t => t.HideDefaultThemes);
AdminContext.ExecuteQueryRetry();
WriteObject(new SPOTenant(Tenant, AdminContext));
WriteObject(new SPOTenant(Tenant, AdminContext, this));
}
}
}
23 changes: 23 additions & 0 deletions src/Commands/Attributes/CsomToModelConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace PnP.PowerShell.Commands.Attributes
{
/// <summary>
/// Attribute to specify the name of the property in the model that should be used to convert the value from the CSOM object to the model object
/// </summary>
/// <param name="propertyName">Name of the property on the CSOM object</param>
/// <param name="skip">If set to true, the property will be skipped</param>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class CsomToModelConverter(string propertyName = null, bool skip = false) : Attribute
{
/// <summary>
/// Name of the property on the CSOM object
/// </summary>
public string PropertyName { get; set; } = propertyName;

/// <summary>
/// If set to true, the property will be skipped
/// </summary>
public bool Skip { get; set; } = skip;
}
}
Loading

0 comments on commit f5b2a56

Please sign in to comment.