Skip to content

Commit

Permalink
Source code not displaying (#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
williambohrmann3 authored and arcgis-maps-sdk-bot committed Jul 29, 2024
1 parent 1d2eadb commit 8819950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/MAUI/Maui.Samples/ArcGIS.Samples.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<MauiAsset Include="Converters\*.cs" />
<MauiImage Include="Samples\**\*.jpg" />
<MauiAsset Include="Samples\**\*.cs" />
<MauiAsset Include="Samples\**\*.xaml" />
<EmbeddedResource Include="SyntaxHighlighting\highlight.js" />
</ItemGroup>
<ItemGroup>
Expand Down
20 changes: 6 additions & 14 deletions src/MAUI/Maui.Samples/Views/SamplePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,22 +628,14 @@ private async Task LoadContent()
{
string baseContent = SourceCode = string.Empty;
var assembly = Assembly.GetExecutingAssembly();
#if __ANDROID__
if (_path.EndsWith(".xaml"))
{
var fileName = _path.Split('/').Last();
var xamlPath = assembly.GetManifestResourceNames().Single(n => n.EndsWith($"{fileName}"));
SourceCode = baseContent = await new StreamReader(assembly.GetManifestResourceStream(xamlPath)).ReadToEndAsync();
}
else
{
using Stream fileStream = await FileSystem.Current.OpenAppPackageFileAsync(_path).ConfigureAwait(false);
SourceCode = baseContent = await new StreamReader(fileStream).ReadToEndAsync();
}
#else

// Account for case sensitivity in file paths.
_path = _path.Replace("Networkanalysis", "NetworkAnalysis");
_path = _path.Replace("Utilitynetwork", "UtilityNetwork");

using Stream fileStream = await FileSystem.Current.OpenAppPackageFileAsync(_path).ConfigureAwait(false);
SourceCode = baseContent = await new StreamReader(fileStream).ReadToEndAsync();
#endif

// For xaml files, search for dynamic resource styles, taking into account any whitespace.
if (_path.EndsWith(".xaml") && String.Concat(baseContent.Where(c => !Char.IsWhiteSpace(c)))
.Contains("Style=\"{DynamicResource"))
Expand Down

0 comments on commit 8819950

Please sign in to comment.