@@ -71,7 +71,6 @@ public static async void EnsureCacheLatest()
71
71
}
72
72
73
73
private string _cachedDocumentation = string . Empty ;
74
- private string _cachedPath = string . Empty ;
75
74
76
75
internal static async Task < Sample > FindAsync ( string category , string name )
77
76
{
@@ -149,8 +148,21 @@ public string CodeUrl
149
148
150
149
public string XamlCode { get ; private set ; }
151
150
151
+ /// <summary>
152
+ /// Gets or sets the path set in the samples.json pointing to the doc for the sample.
153
+ /// </summary>
152
154
public string DocumentationUrl { get ; set ; }
153
155
156
+ /// <summary>
157
+ /// Gets or sets the absolute local doc path for cached file in app.
158
+ /// </summary>
159
+ public string LocalDocumentationFilePath { get ; set ; }
160
+
161
+ /// <summary>
162
+ /// Gets or sets the base path segment to the current document location.
163
+ /// </summary>
164
+ public string RemoteDocumentationPath { get ; set ; }
165
+
154
166
public string Icon { get ; set ; }
155
167
156
168
public string BadgeUpdateVersionRequired { get ; set ; }
@@ -191,32 +203,29 @@ public async Task<string> GetCSharpSourceAsync()
191
203
}
192
204
}
193
205
194
- #pragma warning disable SA1009 // Doesn't like ValueTuples.
195
- public async Task < ( string contents , string path ) > GetDocumentationAsync ( )
196
- #pragma warning restore SA1009 // Doesn't like ValueTuples.
206
+ public async Task < string > GetDocumentationAsync ( )
197
207
{
198
208
if ( ! string . IsNullOrWhiteSpace ( _cachedDocumentation ) )
199
209
{
200
- return ( _cachedDocumentation , _cachedPath ) ;
210
+ return _cachedDocumentation ;
201
211
}
202
212
203
213
var filepath = string . Empty ;
204
214
var filename = string . Empty ;
205
- var localPath = string . Empty ;
215
+ LocalDocumentationFilePath = string . Empty ;
206
216
207
217
var docRegex = new Regex ( "^" + _docsOnlineRoot + "(?<branch>.+?)/docs/(?<file>.+)" ) ;
208
218
var docMatch = docRegex . Match ( DocumentationUrl ) ;
209
219
if ( docMatch . Success )
210
220
{
211
221
filepath = docMatch . Groups [ "file" ] . Value ;
212
- filename = Path . GetFileName ( filepath ) ;
213
- localPath = $ "ms-appx:///docs/{ Path . GetDirectoryName ( filepath ) } /";
222
+ filename = Path . GetFileName ( RemoteDocumentationPath ) ;
223
+ RemoteDocumentationPath = Path . GetDirectoryName ( filepath ) ;
224
+ LocalDocumentationFilePath = $ "ms-appx:///docs/{ RemoteDocumentationPath } /";
214
225
}
215
226
216
227
#if ! DEBUG // use the docs repo in release mode
217
- string modifiedDocumentationUrl = $ "{ _docsOnlineRoot } master/docs/{ filepath } ";
218
-
219
- _cachedPath = modifiedDocumentationUrl . Replace ( filename , string . Empty ) ;
228
+ string modifiedDocumentationUrl = $ "{ _docsOnlineRoot } live/docs/{ filepath } ";
220
229
221
230
// Read from Cache if available.
222
231
try
@@ -264,15 +273,14 @@ public async Task<string> GetCSharpSourceAsync()
264
273
{
265
274
var result = await localDocsStream . ReadTextAsync ( Encoding . UTF8 ) ;
266
275
_cachedDocumentation = ProcessDocs ( result ) ;
267
- _cachedPath = localPath ;
268
276
}
269
277
}
270
278
catch ( Exception )
271
279
{
272
280
}
273
281
}
274
282
275
- return ( _cachedDocumentation , _cachedPath ) ;
283
+ return _cachedDocumentation ;
276
284
}
277
285
278
286
/// <summary>
0 commit comments