Skip to content

Commit

Permalink
Rename Template1.sbn to DataverseEntity.sbn
Browse files Browse the repository at this point in the history
  • Loading branch information
rezanid committed Mar 3, 2024
1 parent a0f6819 commit 01d3d55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/PSDataverse.Tests/ConvertToCustomTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ProcessRecord_NoOutputFile_ProvidesExpectedResult()
.AddCommand("Get-Content").AddParameter("Path", Path.Combine(Directory.GetCurrentDirectory(), "samples", "account-Definition.json"))
.AddCommand("ConvertFrom-Json")
.AddCommand("ConvertTo-CustomText")
.AddParameter("Template", Path.Combine(Directory.GetCurrentDirectory(), "samples", "Template1.sbn"));
.AddParameter("Template", Path.Combine(Directory.GetCurrentDirectory(), "samples", "DataverseEntity.sbn"));

// Act
var results = powershell.Invoke();
Expand Down
2 changes: 1 addition & 1 deletion tests/PSDataverse.Tests/PSDataverse.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<None Update="samples\Template0.sbn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="samples\Template1.sbn">
<None Update="samples/DataverseEntity.sbn">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using System;
public class {{ classname }} : Entity
{
#region Local OptionSets
{{ unique_enums = [] }}
{{~ unique_enums = [] ~}}
{{~ for attribute in StatusAttributes | array.filter @isLocal~}}
{{ name = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize}}
{{~ if !array.contains unique_enums name ~}}
Expand All @@ -27,7 +27,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in PickListAttributes | array.filter @isLocal~}}
{{ name = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize}}
{{~ name = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize ~}}
{{~ if !array.contains unique_enums name ~}}
{{~ unique_enums = unique_enums | array.add name ~}}
public enum {{ name }}
Expand All @@ -38,7 +38,6 @@ public class {{ classname }} : Entity
}
{{~ end ~}}
{{~ end ~}}

#endregion

public {{classname}}() : base("{{ EntityDefinition.LogicalName }}") { }
Expand Down Expand Up @@ -81,9 +80,8 @@ public class {{ classname }} : Entity
}

{{~ for attribute in StatusAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize}}

{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
{{~ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize ~}}
public virtual {{enumName}}? {{propertyName}}
{
get => ({{attribute.OptionSet.Name}}?)GetAttributeValue<OptionSetValue>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -94,8 +92,8 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in PicklistAttributes ~}}
{{ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize ~}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual {{enumName}}? {{propertyName}}
{
get => ({{attribute.OptionSet.Name}}?)GetAttributeValue<OptionSetValue>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -106,8 +104,8 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in MultiSelectPicklistAttributes ~}}
{{ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ enumName = attribute.OptionSet.DisplayName.LocalizedLabels[0]?.Label ?? attribute.OptionSet.Name | tokenize ~}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual {{enumName}}? {{propertyName}}
{
get
Expand All @@ -126,29 +124,29 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in MoneyAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual decimal? {{propertyName}}
{
get => ({{decimal}}?)GetAttributeValue<Money>("{{ attribute.LogicalName }}")?.Value;
get => (decimal?)GetAttributeValue<Money>("{{ attribute.LogicalName }}")?.Value;
{{~ if attribute.IsValidForUpdate == "True" ~}}
set => this["{{ attribute.LogicalName }}"] = value.HasValue ? new Money(value) : null;
{{~ end ~}}
}
{{~ end ~}}

{{~ for attribute in DecimalAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual decimal? {{propertyName}}
{
get => GetAttributeValue<Decimal>("{{ attribute.LogicalName }}")?.Value;
get => GetAttributeValue<decimal?>("{{ attribute.LogicalName }}")?.Value;
{{~ if attribute.IsValidForUpdate == "True" ~}}
set => this["{{ attribute.LogicalName }}"] = value.HasValue ? value : null;
{{~ end ~}}
}
{{~ end ~}}

{{~ for attribute in BigIntAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual BigInteger? {{propertyName}}
{
get => GetAttributeValue<BigInteger>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -159,7 +157,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in IntegerAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual int? {{propertyName}}
{
get => GetAttributeValue<int>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -170,7 +168,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in DoubleAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual double? {{propertyName}}
{
get => GetAttributeValue<double>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -181,7 +179,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in DateTimeAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual DateTime? {{propertyName}}
{
get => GetAttributeValue<DateTime>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -192,7 +190,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in BooleanAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual bool? {{propertyName}}
{
get => GetAttributeValue<bool>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -203,7 +201,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in UniqueIdentifierAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual Guid? {{propertyName}}
{
get => GetAttributeValue<Guid>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -214,7 +212,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in StringAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual string {{propertyName}}
{
get => GetAttributeValue<string>("{{ attribute.LogicalName }}")?.Value;
Expand All @@ -225,7 +223,7 @@ public class {{ classname }} : Entity
{{~ end ~}}

{{~ for attribute in MemoAttributes ~}}
{{ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize}}
{{~ propertyName = attribute.DisplayName.LocalizedLabels[0]?.Label ?? attribute.SchemaName | tokenize ~}}
public virtual string {{propertyName}}
{
get => GetAttributeValue<string>("{{ attribute.LogicalName }}")?.Value;
Expand Down

0 comments on commit 01d3d55

Please sign in to comment.