Skip to content

Commit

Permalink
Update references.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcean committed Oct 30, 2024
1 parent b5b0306 commit d9bb8a6
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Trivial" Version="9.0.0-preview3" />
<PackageReference Include="Trivial" Version="9.0.0-preview4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net481' OR '$(TargetFramework)' == 'net48' OR '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net461'">
Expand Down
5 changes: 2 additions & 3 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240802000" />
<!--<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240829007" Condition="'$(TargetFramework)' != 'net8.0-windows10.0.17763.0' and '$(TargetFramework)' != 'net8.0-windows10.0.19041.0'" />-->
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Common/UI/LocalWebAppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,10 +1313,10 @@ public static LocalWebAppResponseMessage GetMessageHandlers(Dictionary<string, I

public static string GetPath(IJsonValueNode node, LocalWebAppHost host)
{
if (node is IJsonStringNode s)
if (node is IJsonValueNode<string> s)
{
if (host != null) return host.GetLocalPath(s.StringValue, true);
return s.StringValue.StartsWith("%") ? FileSystemInfoUtility.GetLocalPath(s.StringValue) : s.StringValue;
if (host != null) return host.GetLocalPath(s.Value, true);
return s.Value.StartsWith("%") ? FileSystemInfoUtility.GetLocalPath(s.Value) : s.Value;
}

if (node is not JsonObjectNode json) return null;
Expand Down
4 changes: 2 additions & 2 deletions Common/UI/VisualUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ private static void CreateTextInlines(List<Inline> arr, JsonArrayNode json, Json
arr.Add(CreateRun(']', style.PunctuationForeground));
}

private static void CreateTextInlines(List<Inline> arr, IJsonDataNode json, JsonTextStyle style, int intend)
private static void CreateTextInlines(List<Inline> arr, IJsonValueNode json, JsonTextStyle style, int intend)
{
switch (json.ValueKind)
{
Expand Down Expand Up @@ -1559,7 +1559,7 @@ private static void CreateTextViewModels(TextViewModelFactory arr, JsonArrayNode
arr.AppendToBuffer(']', style.PunctuationForeground);
}

private static void CreateTextViewModels(TextViewModelFactory arr, IJsonDataNode json, JsonTextStyle style, int intend)
private static void CreateTextViewModels(TextViewModelFactory arr, IJsonValueNode json, JsonTextStyle style, int intend)
{
switch (json.ValueKind)
{
Expand Down
93 changes: 92 additions & 1 deletion Console/CommandLine/Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1720,5 +1720,96 @@ public static void MoveCursorTo(int x, int y)
/// </summary>
/// <param name="area">The area to remove.</param>
public static void Clear(StyleConsole.RelativeAreas area)
=> StyleConsole.Default.Clear(area);
=> StyleConsole.Default.Clear(area);

// ToDo: Need remove following helper methods.

internal static void Write(this StyleConsole console, Color foreground, string s, params object[] args)
{
if (s == null) return;
console.Write(new ConsoleText(args == null || args.Length == 0 ? s : string.Format(s, args), foreground));
}

internal static void Write(this StyleConsole console, Color foreground, Color background, string s, params object[] args)
{
if (s == null) return;
console.Write(new ConsoleText(args == null || args.Length == 0 ? s : string.Format(s, args), foreground, background));
}

internal static void Write(this StyleConsole console, Color foreground, StringBuilder s)
{
if (s == null) return;
console.Write(new ConsoleText(s, foreground));
}

internal static void Write(this StyleConsole console, Color foreground, Color background, StringBuilder s)
{
if (s == null) return;
console.Write(new ConsoleText(s, foreground, background));
}

internal static void Write(this StyleConsole console, double number, string format)
{
console.Write(new ConsoleText(number.ToString(format)));
}

internal static void Write(this StyleConsole console, ConsoleTextStyle style, int number, string format)
{
console.Write(new ConsoleText(number.ToString(format), style));
}

internal static void Write(this StyleConsole console, ConsoleColor foreground, int number, string format)
{
console.Write(new ConsoleText(number.ToString(format), foreground));
}

internal static void Write(this StyleConsole console, ConsoleTextStyle style, double number, string format)
{
console.Write(new ConsoleText(number.ToString(format), style));
}

internal static void Write(this StyleConsole console, ConsoleColor foreground, double number, string format)
{
console.Write(new ConsoleText(number.ToString(format), foreground));
}

internal static void Write(this StyleConsole console, ConsoleColor? foreground, ConsoleColor? background, double number, string format)
{
console.Write(new ConsoleText(number.ToString(format), foreground, background));
}

internal static void Write(this StyleConsole console, IConsoleTextPrettier style, char[] value, int start = 0, int? count = null)
{
if (style == null)
{
console.Write(value, start, count);
return;
}

var list = style.CreateTextCollection(ToString(value, start, count));
if (list == null) return;
console.Write(list);
}

internal static void Write(this StyleConsole console, IConsoleTextPrettier style, char value, int repeatCount = 1)
{
if (style == null || repeatCount < 1)
{
console.Write(value, repeatCount);
return;
}

var list = style.CreateTextCollection(new string(value, repeatCount));
if (list == null) return;
console.Write(list);
}

private static string ToString(char[] value, int start = 0, int? count = null)
{
if (start == 0 && count == null)
return new string(value);
var list = value.Skip(start);
if (count.HasValue) list = list.Take(count.Value);
return new string(list.ToArray());
}
}
3 changes: 2 additions & 1 deletion Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.19041.48</WindowsSdkPackageVersion>
<AssemblyName>Trivial.WindowsKit.Demo</AssemblyName>
<PackageId>Trivial.WindowsKit.Demo</PackageId>
<RootNamespace>Trivial.Demo</RootNamespace>
Expand Down Expand Up @@ -55,7 +56,7 @@

<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240802000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
11 changes: 5 additions & 6 deletions Web/Web/ControllerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace Trivial.Web;
/// </summary>
public static class ControllerExtensions
{
private const string NullString = "null";
private static MethodInfo method;

/// <summary>
Expand Down Expand Up @@ -490,7 +489,7 @@ public static ContentResult ToActionResult(this JsonObjectNode value)
{
ContentType = WebFormat.JsonMIME,
StatusCode = 200,
Content = value?.ToString() ?? NullString
Content = value?.ToString() ?? JsonValues.NullString
};

/// <summary>
Expand All @@ -503,7 +502,7 @@ public static ContentResult ToActionResult(this JsonArrayNode value)
{
ContentType = WebFormat.JsonMIME,
StatusCode = 200,
Content = value?.ToString() ?? NullString
Content = value?.ToString() ?? JsonValues.NullString
};

/// <summary>
Expand All @@ -516,7 +515,7 @@ public static ContentResult ToActionResult(this IJsonObjectHost value)
{
ContentType = WebFormat.JsonMIME,
StatusCode = 200,
Content = value?.ToJson()?.ToString() ?? NullString
Content = value?.ToJson()?.ToString() ?? JsonValues.NullString
};

/// <summary>
Expand All @@ -529,7 +528,7 @@ public static ContentResult ToActionResult(System.Text.Json.Nodes.JsonObject val
{
ContentType = WebFormat.JsonMIME,
StatusCode = 200,
Content = value?.ToJsonString() ?? NullString
Content = value?.ToJsonString() ?? JsonValues.NullString
};

/// <summary>
Expand All @@ -542,7 +541,7 @@ public static ContentResult ToActionResult(System.Text.Json.Nodes.JsonArray valu
{
ContentType = WebFormat.JsonMIME,
StatusCode = 200,
Content = value?.ToJsonString() ?? NullString
Content = value?.ToJsonString() ?? JsonValues.NullString
};

/// <summary>
Expand Down

0 comments on commit d9bb8a6

Please sign in to comment.