-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
220 additions
and
13 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
src/JinianNet.JNTemplate.Test/JinianNet.JNTemplate.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/******************************************************************************** | ||
Copyright (c) jiniannet (http://www.jiniannet.com). All rights reserved. | ||
Licensed under the MIT license. See licence.txt file in the project root for full license information. | ||
********************************************************************************/ | ||
using System; | ||
|
||
namespace JinianNet.JNTemplate.Resources | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public interface IResourceReader : IReader | ||
{ | ||
|
||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/JinianNet.JNTemplate/Resources/ResourceChangedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/******************************************************************************** | ||
Copyright (c) jiniannet (http://www.jiniannet.com). All rights reserved. | ||
Licensed under the MIT license. See licence.txt file in the project root for full license information. | ||
********************************************************************************/ | ||
using System; | ||
|
||
namespace JinianNet.JNTemplate.Resources | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class ResourceChangedEventArgs : EventArgs | ||
{ | ||
/// <summary> | ||
/// the path of the resources | ||
/// </summary> | ||
public string FullPath { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************** | ||
Copyright (c) jiniannet (http://www.jiniannet.com). All rights reserved. | ||
Licensed under the MIT license. See licence.txt file in the project root for full license information. | ||
********************************************************************************/ | ||
using JinianNet.JNTemplate.Hosting; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace JinianNet.JNTemplate.Resources | ||
{ | ||
/// <summary> | ||
/// 表示资源管理器,其可在运行时提供对于模板资源的便利访问 | ||
/// </summary> | ||
public class ResourceManager : List<string>, ICollection<string>, IEnumerable<string> | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public bool EnableWatch { get; set; } | ||
//private List<string> resources; | ||
private IHostEnvironment environment; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="e"></param> | ||
public ResourceManager(IHostEnvironment e) | ||
{ | ||
environment = e; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/******************************************************************************** | ||
Copyright (c) jiniannet (http://www.jiniannet.com). All rights reserved. | ||
Licensed under the MIT license. See licence.txt file in the project root for full license information. | ||
********************************************************************************/ | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
#if !NF35 && !NF20 | ||
using System.Threading.Tasks; | ||
#endif | ||
|
||
namespace JinianNet.JNTemplate.Resources | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class TemplateReader : IResourceReader | ||
{ | ||
private string resourcePath; | ||
private string content; | ||
private bool isComplete; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="path"></param> | ||
public TemplateReader(string path) | ||
{ | ||
this.resourcePath = path; | ||
this.isComplete = false; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public string ReadToEnd(Context context) | ||
{ | ||
if (!isComplete) | ||
{ | ||
var res = context.Load(this.resourcePath); | ||
if (res != null) | ||
{ | ||
content = res.Content; | ||
} | ||
isComplete = true; | ||
} | ||
return content; | ||
} | ||
|
||
#region Task based Async APIs | ||
#if !NF40 && !NF35 && !NF20 | ||
/// <inheritdoc /> | ||
#if NF45 | ||
public Task<string> ReadToEndAsync(Context context) | ||
{ | ||
return Task.FromResult(ReadToEnd(context)); | ||
} | ||
#else | ||
public async Task<string> ReadToEndAsync(Context context) | ||
{ | ||
if (!isComplete) | ||
{ | ||
var res = await context.LoadAsync(this.resourcePath); | ||
if (res != null) | ||
{ | ||
content = res.Content; | ||
} | ||
isComplete = true; | ||
} | ||
return content; | ||
} | ||
#endif | ||
#endif | ||
#endregion | ||
|
||
|
||
/// <inheritdoc /> | ||
public override int GetHashCode() | ||
{ | ||
return resourcePath?.GetHashCode() ?? 0; | ||
} | ||
} | ||
} | ||
|