Skip to content

Commit e4b7dbd

Browse files
author
DmitryFillo
committed
methods renames
1 parent ee57b78 commit e4b7dbd

9 files changed

Lines changed: 36 additions & 39 deletions

File tree

README.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ URI path scanf
55
.. image:: https://travis-ci.com/DmitryFillo/UriPathScanf.svg?branch=master
66
:target: https://travis-ci.com/DmitryFillo/UriPathScanf
77

8-
TBD: scan -> scanAll; scanDict -> scan; tryCast -> tryCastToDict
9-
TBD: nuget pkg rc
10-
TBD: logo
11-
TBD: nuget pkg release
8+
TBD: nuget pkg rc, logo, nuget pkg release
129

1310
Reversed String.Format for URI path.
1411

@@ -43,13 +40,13 @@ Usage
4340
var uriPathScanf = new UriPathScanf(descriptors);
4441
4542
// scan some URI path
46-
var result = uriPathScanf.ScanDict("/path/some/xxx?a=1");
43+
var result = uriPathScanf.Scan("/path/some/xxx?a=1");
4744
4845
// result.UriType == "firstType"
4946
// result.Meta is Dictionary<string, string> with "varOne" == "xxx" and "qs__a" = "1"
5047
5148
// scan some URI path
52-
result = uriPathScanf.ScanDict("/path/some/xxx/123y////?a=1");
49+
result = uriPathScanf.Scan("/path/some/xxx/123y////?a=1");
5350
5451
// result.UriType == "secondType"
5552
// result.Meta is Dictionary<string, string> with "someVar" == "xxx", "someVar2" == "123y" and "qs__a" = "1"
@@ -138,7 +135,7 @@ Diffrenently typed descriptors:
138135
// result.UriType == "secondType"
139136
// result.Meta.X == null
140137
141-
result = uriPathScanf.Scan("/some/path/x=x");
138+
result = uriPathScanf.ScanAll("/some/path/x=x");
142139
143140
// result.UriType == "secondType"
144141
// result.Meta is object
@@ -177,7 +174,7 @@ Typed and non-typed descriptors:
177174
178175
var uriPathScanf = new UriPathScanf(descriptors);
179176
180-
var result = uriPathScanf.Scan("/path/some/1/2");
177+
var result = uriPathScanf.ScanAll("/path/some/1/2");
181178
182179
// result.UriType == "someType"
183180
// result.Meta is object
@@ -193,16 +190,16 @@ Typed and non-typed descriptors:
193190
// resultCastedToMeta.SomeVar = "1"
194191
// resultCastedToMeta.SomeVar2 = "2"
195192
196-
result.TryCast(out var resultCastedToDict)
193+
result.TryCastToDict(out var resultCastedToDict)
197194
198195
// resultCastedToDict == null
199196
200-
result = uriPathScanf.Scan("/some/path/?x=3&m=n");
197+
result = uriPathScanf.ScanAll("/some/path/?x=3&m=n");
201198
202199
// result.UriType == "someType"
203200
// result.Meta is object
204201
205-
result.TryCast(out resultCastedToDict)
202+
result.TryCastToDict(out resultCastedToDict)
206203
207204
// resultCastedToDict is Dictionary<string, string> with keys "qs__x" and "qs__m"
208205

UriPathScanf.Example/Example1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void Go()
2626
"/path/some/12314/xxx/?x=123"
2727
})
2828
{
29-
var result = uriPathScanf.Scan(u);
29+
var result = uriPathScanf.ScanAll(u);
3030

3131
// pattern matching
3232
switch (result.Meta)
@@ -41,7 +41,7 @@ public static void Go()
4141

4242
// casting
4343
if (result.TryCast<Meta>(out var resultMeta)) Assert(result, resultMeta);
44-
if (result.TryCast(out var resultDict)) Assert(result, resultDict);
44+
if (result.TryCastToDict(out var resultDict)) Assert(result, resultDict);
4545
}
4646
}
4747

UriPathScanf.Example/Example2.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace UriPathScanf.Example
66
internal static class Example2
77
{
88
/// <summary>
9-
/// Example using <see cref="UriPathScanf.Scan"/>, <see cref="UriPathScanf.Scan{T}"/> and <see cref="UriPathScanf.ScanDict"/>
9+
/// Example using <see cref="UriPathScanf.ScanAll"/>, <see cref="UriPathScanf.ScanAll{T}"/> and <see cref="UriPathScanf.Scan"/>
1010
/// </summary>
1111
public static void Go()
1212
{
@@ -38,11 +38,11 @@ public static void Go()
3838
Debug.Assert(resultNonMeta == null);
3939

4040
// dict scan and found
41-
var resultMetaDict = uriPathScanf.ScanDict("/path/some/3");
41+
var resultMetaDict = uriPathScanf.Scan("/path/some/3");
4242
Debug.Assert(resultMetaDict.Meta["varOne"] == "3");
4343

4444
// dict scan and not found
45-
var resultNotDict = uriPathScanf.ScanDict("/path/some/3/4");
45+
var resultNotDict = uriPathScanf.Scan("/path/some/3/4");
4646
Debug.Assert(resultNotDict == null);
4747
}
4848

UriPathScanf.Tests/UriMetadataTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Cast_ToDictionary_Success()
1616
var metadata = new UriMetadata("someType", new Dictionary<string, string>());
1717

1818
// Act
19-
var resultCast = metadata.TryCast(out var result);
19+
var resultCast = metadata.TryCastToDict(out var result);
2020

2121
// Assert
2222
result.Should().NotBeNull();
@@ -30,7 +30,7 @@ public void Cast_ToDictionary_NonSuccess()
3030
var metadata = new UriMetadata("someType", new object());
3131

3232
// Act
33-
var resultCast = metadata.TryCast(out var result);
33+
var resultCast = metadata.TryCastToDict(out var result);
3434

3535
// Assert
3636
result.Should().BeNull();

UriPathScanf.Tests/UriPathScanfTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ public void NonTypedMetaTest(IEnumerable<UriPathDescriptor> linkDescriptors, str
1717
var urlParser = new UriPathScanf(linkDescriptors);
1818

1919
// Act
20-
var result = urlParser.Scan(url);
21-
var resultTyped = urlParser.ScanDict(url);
20+
var result = urlParser.ScanAll(url);
21+
var resultTyped = urlParser.Scan(url);
2222

2323
// Assert
2424
if (expectedResult != null)
2525
{
2626
result.UriType.Should().BeEquivalentTo(expectedResult.UriType);
2727
result.Type.Should().Be(expectedResult.Type);
2828

29-
result.TryCast(out var resultCasted);
29+
result.TryCastToDict(out var resultCasted);
3030
resultCasted.Should().BeEquivalentTo(expectedResult.Meta);
3131

3232
resultTyped.Meta.Should().BeEquivalentTo(expectedResult.Meta);
@@ -46,7 +46,7 @@ public void TypedMetaTest(IEnumerable<UriPathDescriptor> linkDescriptors, string
4646
var urlParser = new UriPathScanf(linkDescriptors);
4747

4848
// Act
49-
var result = urlParser.Scan(url);
49+
var result = urlParser.ScanAll(url);
5050
var resultTyped = urlParser.Scan<UriPathScanfTestSource.TestTypedMetadata>(url);
5151

5252
// Assert
@@ -80,7 +80,7 @@ public void NonScanTypeTest()
8080

8181
// Act
8282
var resultTyped = urlParser.Scan<UriPathScanfTestSource.TestTypedMetadataFake>(uri);
83-
var resultDictTyped = urlParser.ScanDict(uri);
83+
var resultDictTyped = urlParser.Scan(uri);
8484

8585
// Assert
8686
resultTyped.Should().BeNull();

UriPathScanf/IUriPathScanf.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ namespace UriPathScanf
88
public interface IUriPathScanf
99
{
1010
/// <summary>
11-
/// Gets meta by URI path
11+
/// Gets meta by URI path (all descriptors)
1212
/// </summary>
1313
/// <param name="uriPath">URI path (w/o domain and proto)</param>
1414
/// <returns></returns>
15-
UriMetadata Scan(string uriPath);
15+
UriMetadata ScanAll(string uriPath);
1616

1717
/// <summary>
18-
/// Gets meta by URI path
18+
/// Gets meta by URI path (only typed descriptors)
1919
/// </summary>
2020
/// <typeparam name="T"></typeparam>
2121
/// <param name="uriPath"></param>
2222
/// <returns></returns>
2323
UriMetadata<T> Scan<T>(string uriPath) where T : class, IUriPathMetaModel;
2424

2525
/// <summary>
26-
/// Gets meta by URI path
26+
/// Gets meta by URI path (only non-typed descriptors)
2727
/// </summary>
2828
/// <param name="uriPath"></param>
2929
/// <returns></returns>
30-
UriMetadata<IDictionary<string, string>> ScanDict(string uriPath);
30+
UriMetadata<IDictionary<string, string>> Scan(string uriPath);
3131
}
3232
}

UriPathScanf/UriMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class UriMetadata : UriMetadata<object>
105105
/// If it's typed meta then null will be returned
106106
/// </summary>
107107
/// <returns></returns>
108-
public bool TryCast(out IDictionary<string, string> result)
108+
public bool TryCastToDict(out IDictionary<string, string> result)
109109
{
110110
if (!(Meta is IDictionary<string, string> casted))
111111
{

UriPathScanf/UriPathScanf.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ public UriPathScanf(IEnumerable<UriPathDescriptor> descriptors)
7373

7474
/// <inheritdoc />
7575
/// <summary>
76-
/// Get URI path metadata
76+
/// Get URI path metadata (all descriptors)
7777
/// </summary>
7878
/// <param name="uriPath">URI path</param>
7979
/// <returns></returns>
80-
public UriMetadata Scan(string uriPath)
80+
public UriMetadata ScanAll(string uriPath)
8181
{
8282
var match = FindMatch(uriPath);
8383

@@ -90,7 +90,7 @@ public UriMetadata Scan(string uriPath)
9090

9191
/// <inheritdoc />
9292
/// <summary>
93-
/// Get URI path metadata
93+
/// Get URI path metadata (only typed descriptors)
9494
/// </summary>
9595
/// <param name="uriPath">URI path</param>
9696
/// <returns></returns>
@@ -107,11 +107,11 @@ public UriMetadata<T> Scan<T>(string uriPath) where T: class, IUriPathMetaModel
107107

108108
/// <inheritdoc />
109109
/// <summary>
110-
/// Get URI path metadata
110+
/// Get URI path metadata (only non-typed descriptors)
111111
/// </summary>
112112
/// <param name="uriPath">URI path</param>
113113
/// <returns></returns>
114-
public UriMetadata<IDictionary<string, string>> ScanDict(string uriPath)
114+
public UriMetadata<IDictionary<string, string>> Scan(string uriPath)
115115
{
116116
var match = FindMatch(uriPath);
117117

UriPathScanf/UriPathScanf.xml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)