mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-07-03 03:21:48 +02:00
Make some classes internal + chnage some files to file-scoped namespaces
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
namespace WireMock.Exceptions;
|
||||||
|
|
||||||
namespace WireMock.Exceptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WireMockException
|
/// WireMockException
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -32,4 +32,3 @@ namespace WireMock.Exceptions
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -3,8 +3,8 @@ using System.IO;
|
|||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
|
|
||||||
namespace WireMock.Handlers
|
namespace WireMock.Handlers;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default implementation for a handler to interact with the local file system to read and write static mapping files.
|
/// Default implementation for a handler to interact with the local file system to read and write static mapping files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,7 +34,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.FolderExists"/>
|
/// <inheritdoc cref="IFileSystemHandler.FolderExists"/>
|
||||||
public virtual bool FolderExists(string path)
|
public virtual bool FolderExists(string path)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
|
|
||||||
return Directory.Exists(path);
|
return Directory.Exists(path);
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.CreateFolder"/>
|
/// <inheritdoc cref="IFileSystemHandler.CreateFolder"/>
|
||||||
public virtual void CreateFolder(string path)
|
public virtual void CreateFolder(string path)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
|
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.EnumerateFiles"/>
|
/// <inheritdoc cref="IFileSystemHandler.EnumerateFiles"/>
|
||||||
public virtual IEnumerable<string> EnumerateFiles(string path, bool includeSubdirectories)
|
public virtual IEnumerable<string> EnumerateFiles(string path, bool includeSubdirectories)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
|
|
||||||
return includeSubdirectories ? Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) : Directory.EnumerateFiles(path);
|
return includeSubdirectories ? Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) : Directory.EnumerateFiles(path);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.ReadMappingFile"/>
|
/// <inheritdoc cref="IFileSystemHandler.ReadMappingFile"/>
|
||||||
public virtual string ReadMappingFile(string path)
|
public virtual string ReadMappingFile(string path)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
|
|
||||||
return File.ReadAllText(path);
|
return File.ReadAllText(path);
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsFile"/>
|
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsFile"/>
|
||||||
public virtual byte[] ReadResponseBodyAsFile(string path)
|
public virtual byte[] ReadResponseBodyAsFile(string path)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
path = PathUtils.CleanPath(path);
|
path = PathUtils.CleanPath(path);
|
||||||
// If the file exists at the given path relative to the MappingsFolder, then return that.
|
// If the file exists at the given path relative to the MappingsFolder, then return that.
|
||||||
// Else the path will just be as-is.
|
// Else the path will just be as-is.
|
||||||
@@ -91,7 +91,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
|
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
|
||||||
public virtual string ReadResponseBodyAsString(string path)
|
public virtual string ReadResponseBodyAsString(string path)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(path, nameof(path));
|
Guard.NotNullOrEmpty(path);
|
||||||
path = PathUtils.CleanPath(path);
|
path = PathUtils.CleanPath(path);
|
||||||
// In case the path is a filename, the path will be adjusted to the MappingFolder.
|
// In case the path is a filename, the path will be adjusted to the MappingFolder.
|
||||||
// Else the path will just be as-is.
|
// Else the path will just be as-is.
|
||||||
@@ -101,7 +101,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
|
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
|
||||||
public virtual bool FileExists(string filename)
|
public virtual bool FileExists(string filename)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(filename, nameof(filename));
|
Guard.NotNullOrEmpty(filename);
|
||||||
|
|
||||||
return File.Exists(AdjustPathForMappingFolder(filename));
|
return File.Exists(AdjustPathForMappingFolder(filename));
|
||||||
}
|
}
|
||||||
@@ -109,8 +109,8 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void WriteFile(string filename, byte[] bytes)
|
public virtual void WriteFile(string filename, byte[] bytes)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(filename, nameof(filename));
|
Guard.NotNullOrEmpty(filename);
|
||||||
Guard.NotNull(bytes, nameof(bytes));
|
Guard.NotNull(bytes);
|
||||||
|
|
||||||
File.WriteAllBytes(AdjustPathForMappingFolder(filename), bytes);
|
File.WriteAllBytes(AdjustPathForMappingFolder(filename), bytes);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.DeleteFile"/>
|
/// <inheritdoc cref="IFileSystemHandler.DeleteFile"/>
|
||||||
public virtual void DeleteFile(string filename)
|
public virtual void DeleteFile(string filename)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(filename, nameof(filename));
|
Guard.NotNullOrEmpty(filename);
|
||||||
|
|
||||||
File.Delete(AdjustPathForMappingFolder(filename));
|
File.Delete(AdjustPathForMappingFolder(filename));
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.ReadFile"/>
|
/// <inheritdoc cref="IFileSystemHandler.ReadFile"/>
|
||||||
public virtual byte[] ReadFile(string filename)
|
public virtual byte[] ReadFile(string filename)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(filename, nameof(filename));
|
Guard.NotNullOrEmpty(filename);
|
||||||
|
|
||||||
return File.ReadAllBytes(AdjustPathForMappingFolder(filename));
|
return File.ReadAllBytes(AdjustPathForMappingFolder(filename));
|
||||||
}
|
}
|
||||||
@@ -156,8 +156,8 @@ namespace WireMock.Handlers
|
|||||||
/// <inheritdoc cref="IFileSystemHandler.WriteUnmatchedRequest"/>
|
/// <inheritdoc cref="IFileSystemHandler.WriteUnmatchedRequest"/>
|
||||||
public virtual void WriteUnmatchedRequest(string filename, string text)
|
public virtual void WriteUnmatchedRequest(string filename, string text)
|
||||||
{
|
{
|
||||||
Guard.NotNullOrEmpty(filename, nameof(filename));
|
Guard.NotNullOrEmpty(filename);
|
||||||
Guard.NotNull(text, nameof(text));
|
Guard.NotNull(text);
|
||||||
|
|
||||||
var folder = GetUnmatchedRequestsFolder();
|
var folder = GetUnmatchedRequestsFolder();
|
||||||
if (!FolderExists(folder))
|
if (!FolderExists(folder))
|
||||||
@@ -178,4 +178,3 @@ namespace WireMock.Handlers
|
|||||||
return Path.Combine(GetMappingFolder(), filename);
|
return Path.Combine(GetMappingFolder(), filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using AnyOfTypes;
|
using AnyOfTypes;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using WireMock.Models;
|
using WireMock.Models;
|
||||||
|
|
||||||
namespace WireMock.Matchers;
|
namespace WireMock.Matchers;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace WireMock.Models
|
namespace WireMock.Models;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TimeSettingsModel: Start, End and TTL
|
/// TimeSettingsModel: Start, End and TTL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -16,4 +16,3 @@ namespace WireMock.Models
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int? TTL { get; set; }
|
public int? TTL { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ namespace WireMock.Util;
|
|||||||
/// http://www.unicode.org/versions/corrigendum1.html
|
/// http://www.unicode.org/versions/corrigendum1.html
|
||||||
/// http://www.ietf.org/rfc/rfc2279.txt
|
/// http://www.ietf.org/rfc/rfc2279.txt
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class BytesEncodingUtils
|
internal static class BytesEncodingUtils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries the get the Encoding from an array of bytes.
|
/// Tries the get the Encoding from an array of bytes.
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace WireMock.Util
|
namespace WireMock.Util;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe.
|
/// A special Collection that overrides methods of <see cref="ObservableCollection{T}"/> to make them thread safe.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -83,4 +83,3 @@ namespace WireMock.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -4,8 +4,8 @@ using System.IO;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
|
|
||||||
namespace WireMock.Util
|
namespace WireMock.Util;
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
|
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -251,4 +251,3 @@ namespace WireMock.Util
|
|||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ namespace WireMock.Util;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Port Utility class
|
/// Port Utility class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class PortUtils
|
internal static class PortUtils
|
||||||
{
|
{
|
||||||
private static readonly Regex UrlDetailsRegex = new(@"^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$", RegexOptions.Compiled);
|
private static readonly Regex UrlDetailsRegex = new(@"^((?<proto>\w+)://)(?<host>[^/]+?):(?<port>\d+)\/?$", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user