Skip to content

Commit

Permalink
added new Microsoft.PowerPlatform.PowerApps.Persistence project (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizrael authored Jan 24, 2024
1 parent 35f11d0 commit fc5b0e1
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

internal static class BuiltInTemplatesUris
{
public static readonly Uri Screen = new("http://microsoft.com/appmagic/screen#screen");
public static readonly Uri Button = new("http://microsoft.com/appmagic/button#button");
public static readonly Uri Label = new("http://microsoft.com/appmagic/label#label");
}
14 changes: 14 additions & 0 deletions src/Microsoft.PowerPlatform.PowerApps.Persistence/Models/Button.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

[FirstClass(Template)]
internal record Button : Control
{
internal const string Template = "Button";
public Button()
{
ControlUri = BuiltInTemplatesUris.Button;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

//TODO: abstract?
internal record Control
{
// TODO: rename to "Control" in yaml
// TODO: make this a string and handle parsing/matchin later
/// <summary>
/// template uri of the control.
/// </summary>
public Uri? ControlUri { get; init; }

/// <summary>
/// the control's name.
/// </summary>
public string? Name { get; init; }

/// <summary>
/// key/value pairs of Control properties. Mapped to/from Control rules.
/// </summary>
public IReadOnlyDictionary<string, string>? Properties { get; init; }

/// <summary>
/// list of child controls nested under this control.
/// </summary>
public Control[]? Controls { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

// TODO
//internal sealed record ControlProperty
//{
// public string Name { get; init; }

// public string? Value { get; init; }

// public bool IsFormula { get; init; }
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

internal record CustomControl : Control;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
internal class FirstClassAttribute : Attribute
{
public FirstClassAttribute(string? nodeName = null)
{
NodeName = nodeName ?? string.Empty;
}
public string NodeName { get; }
}
14 changes: 14 additions & 0 deletions src/Microsoft.PowerPlatform.PowerApps.Persistence/Models/Label.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

[FirstClass(Template)]
internal record Label : Control
{
internal const string Template = "Label";
public Label()
{
ControlUri = BuiltInTemplatesUris.Label;
}
}
14 changes: 14 additions & 0 deletions src/Microsoft.PowerPlatform.PowerApps.Persistence/Models/Screen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.Models;

[FirstClass(Template)]
internal record Screen : Control
{
internal const string Template = "Screen";
public Screen()
{
ControlUri = BuiltInTemplatesUris.Screen;
}
}
6 changes: 6 additions & 0 deletions src/PASopa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerPlatform.PowerApps.Persistence", "Microsoft.PowerPlatform.PowerApps.Persistence\Microsoft.PowerPlatform.PowerApps.Persistence.csproj", "{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,6 +36,10 @@ Global
{8AD94CC0-7330-4880-A8E0-177B37CDB27B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8AD94CC0-7330-4880-A8E0-177B37CDB27B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8AD94CC0-7330-4880-A8E0-177B37CDB27B}.Release|Any CPU.Build.0 = Release|Any CPU
{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}.Debug|Any CPU.Build.0 = Debug|Any CPU
{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}.Release|Any CPU.ActiveCfg = Release|Any CPU
{906B4EA5-F287-4D0E-A511-0D89B2DD9C14}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit fc5b0e1

Please sign in to comment.