-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/WireMock.Net/Transformers/Scriban/WireMockListAccessor.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,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Scriban; | ||
using Scriban.Parsing; | ||
using Scriban.Runtime; | ||
|
||
namespace WireMock.Transformers.Scriban | ||
{ | ||
internal class WireMockListAccessor : IListAccessor, IObjectAccessor | ||
{ | ||
#region IListAccessor | ||
public int GetLength(TemplateContext context, SourceSpan span, object target) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public object GetValue(TemplateContext context, SourceSpan span, object target, int index) | ||
{ | ||
return target.ToString(); | ||
} | ||
|
||
public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
#endregion | ||
|
||
#region IObjectAccessor | ||
public int GetMemberCount(TemplateContext context, SourceSpan span, object target) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IEnumerable<string> GetMembers(TemplateContext context, SourceSpan span, object target) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool HasMember(TemplateContext context, SourceSpan span, object target, string member) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool TryGetValue(TemplateContext context, SourceSpan span, object target, string member, out object value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool TrySetValue(TemplateContext context, SourceSpan span, object target, string member, object value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
#endregion | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/WireMock.Net/Transformers/Scriban/WireMockTemplateContext.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 @@ | ||
using Scriban; | ||
using Scriban.Runtime; | ||
using WireMock.Types; | ||
|
||
namespace WireMock.Transformers.Scriban | ||
{ | ||
internal class WireMockTemplateContext: TemplateContext | ||
{ | ||
protected override IObjectAccessor GetMemberAccessorImpl(object target) | ||
{ | ||
if (target?.GetType().GetGenericTypeDefinition() == typeof(WireMockList<>)) | ||
{ | ||
return new WireMockListAccessor(); | ||
} | ||
|
||
return base.GetMemberAccessorImpl(target); | ||
} | ||
} | ||
} |
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