Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Essentials AppInfo API Docs #11374

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 0 additions & 145 deletions src/Essentials/docs/Microsoft.Maui.Essentials/AppInfo.xml

This file was deleted.

69 changes: 0 additions & 69 deletions src/Essentials/docs/Microsoft.Maui.Essentials/AppTheme.xml

This file was deleted.

1 change: 0 additions & 1 deletion src/Essentials/src/AppInfo/AppInfo.netstandard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Microsoft.Maui.ApplicationModel
{
/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="Type[@FullName='Microsoft.Maui.Essentials.AppInfo']/Docs/*" />
class AppInfoImplementation : IAppInfo
{
public string PackageName => throw ExceptionUtils.NotSupportedOrImplementedException;
Expand Down
83 changes: 75 additions & 8 deletions src/Essentials/src/AppInfo/AppInfo.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,134 @@

namespace Microsoft.Maui.ApplicationModel
{
/// <summary>
/// Represents information about the application.
/// </summary>
public interface IAppInfo
{
/// <summary>
/// Gets the application package name or identifier.
/// </summary>
/// <remarks>On Android and iOS, this is the application package name. On Windows, this is the application GUID.</remarks>
string PackageName { get; }

/// <summary>
/// Gets the application name.
/// </summary>
string Name { get; }

/// <summary>
/// Gets the application version as a string representation.
/// </summary>
string VersionString { get; }

/// <summary>
/// Gets the application version as a <see cref="Version"/> object.
/// </summary>
Version Version { get; }

/// <summary>
/// Gets the application build number.
/// </summary>
string BuildString { get; }

/// <summary>
/// Open the settings menu or page for this application.
/// </summary>
void ShowSettingsUI();

/// <summary>
/// Gets the detected theme of the system or application.
/// </summary>
/// <remarks>For platforms or platform versions which do not support themes, <see cref="AppTheme.Unspecified"/> is returned.</remarks>
AppTheme RequestedTheme { get; }

/// <summary>
/// Gets the packaging model of this application.
/// </summary>
/// <remarks>On other platforms than Windows, this will always return <see cref="AppPackagingModel.Packaged"/>.</remarks>
AppPackagingModel PackagingModel { get; }

/// <summary>
/// Gets the requested layout direction of the system or application.
/// </summary>
LayoutDirection RequestedLayoutDirection { get; }
}

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="Type[@FullName='Microsoft.Maui.Essentials.AppInfo']/Docs/*" />
/// <summary>
/// Represents information about the application.
/// </summary>
public static class AppInfo
{
/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='PackageName']/Docs/*" />
/// <summary>
/// Gets the application package name or identifier.
/// </summary>
/// <remarks>On Android and iOS, this is the application package name. On Windows, this is the application GUID.</remarks>
public static string PackageName => Current.PackageName;

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='Name']/Docs/*" />
/// <summary>
/// Gets the application name.
/// </summary>
public static string Name => Current.Name;

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='VersionString']/Docs/*" />
/// <summary>
/// Gets the application version as a string representation.
/// </summary>
public static string VersionString => Current.VersionString;

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='Version']/Docs/*" />
/// <summary>
/// Gets the application version as a <see cref="Version"/> object.
/// </summary>
public static Version Version => Current.Version;

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='BuildString']/Docs/*" />
/// <summary>
/// Gets the application build number.
/// </summary>
public static string BuildString => Current.BuildString;

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='ShowSettingsUI']/Docs/*" />
/// <summary>
/// Open the settings menu or page for this application.
/// </summary>
public static void ShowSettingsUI() => Current.ShowSettingsUI();

/// <include file="../../docs/Microsoft.Maui.Essentials/AppInfo.xml" path="//Member[@MemberName='RequestedTheme']/Docs/*" />
/// <summary>
/// Gets the detected theme of the system or application.
/// </summary>
/// <remarks>For platforms or platform versions which do not support themes, <see cref="AppTheme.Unspecified"/> is returned.</remarks>
public static AppTheme RequestedTheme => Current.RequestedTheme;

/// <summary>
/// Gets the packaging model of this application.
/// </summary>
/// <remarks>On other platforms than Windows, this will always return <see cref="AppPackagingModel.Packaged"/>.</remarks>
public static AppPackagingModel PackagingModel => Current.PackagingModel;

/// <summary>
/// Gets the requested layout direction of the system or application.
/// </summary>
public static LayoutDirection RequestedLayoutDirection => Current.RequestedLayoutDirection;

static IAppInfo? currentImplementation;

/// <summary>
/// Provides the default implementation for static usage of this API.
/// </summary>
public static IAppInfo Current =>
currentImplementation ??= new AppInfoImplementation();

internal static void SetCurrent(IAppInfo? implementation) =>
currentImplementation = implementation;
}

/// <summary>
/// Describes packaging options for a Windows app.
/// </summary>
public enum AppPackagingModel
{
/// <summary>The app is packaged and can be distributed through an MSIX or the store.</summary>
Packaged,

/// <summary>The app is unpcakged and can be distributed as a collection of executable files.</summary>
Unpackaged,
}
}
Loading