Remove ServiceStack and related stuff

This commit is contained in:
Claus Vium
2020-09-02 12:22:14 +02:00
parent 506fc7cbae
commit e337756428
45 changed files with 91 additions and 4649 deletions

View File

@@ -1,65 +0,0 @@
#nullable disable
using System;
namespace MediaBrowser.Model.Services
{
/// <summary>
/// Identifies a single API endpoint.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public class ApiMemberAttribute : Attribute
{
/// <summary>
/// Gets or sets verb to which applies attribute. By default applies to all verbs.
/// </summary>
public string Verb { get; set; }
/// <summary>
/// Gets or sets parameter type: It can be only one of the following: path, query, body, form, or header.
/// </summary>
public string ParameterType { get; set; }
/// <summary>
/// Gets or sets unique name for the parameter. Each name must be unique, even if they are associated with different paramType values.
/// </summary>
/// <remarks>
/// <para>
/// Other notes on the name field:
/// If paramType is body, the name is used only for UI and codegeneration.
/// If paramType is path, the name field must correspond to the associated path segment from the path field in the api object.
/// If paramType is query, the name field corresponds to the query param name.
/// </para>
/// </remarks>
public string Name { get; set; }
/// <summary>
/// Gets or sets the human-readable description for the parameter.
/// </summary>
public string Description { get; set; }
/// <summary>
/// For path, query, and header paramTypes, this field must be a primitive. For body, this can be a complex or container datatype.
/// </summary>
public string DataType { get; set; }
/// <summary>
/// For path, this is always true. Otherwise, this field tells the client whether or not the field must be supplied.
/// </summary>
public bool IsRequired { get; set; }
/// <summary>
/// For query params, this specifies that a comma-separated list of values can be passed to the API. For path and body types, this field cannot be true.
/// </summary>
public bool AllowMultiple { get; set; }
/// <summary>
/// Gets or sets route to which applies attribute, matches using StartsWith. By default applies to all routes.
/// </summary>
public string Route { get; set; }
/// <summary>
/// Whether to exclude this property from being included in the ModelSchema.
/// </summary>
public bool ExcludeInSchema { get; set; }
}
}

View File

@@ -1,13 +0,0 @@
#pragma warning disable CS1591
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Model.Services
{
public interface IAsyncStreamWriter
{
Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken);
}
}

View File

@@ -1,11 +0,0 @@
#pragma warning disable CS1591
using System.Collections.Generic;
namespace MediaBrowser.Model.Services
{
public interface IHasHeaders
{
IDictionary<string, string> Headers { get; }
}
}

View File

@@ -1,24 +0,0 @@
#pragma warning disable CS1591
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Model.Services
{
public interface IHasRequestFilter
{
/// <summary>
/// Gets the order in which Request Filters are executed.
/// &lt;0 Executed before global request filters.
/// &gt;0 Executed after global request filters.
/// </summary>
int Priority { get; }
/// <summary>
/// The request filter is executed before the service.
/// </summary>
/// <param name="req">The http request wrapper.</param>
/// <param name="res">The http response wrapper.</param>
/// <param name="requestDto">The request DTO.</param>
void RequestFilter(IRequest req, HttpResponse res, object requestDto);
}
}

View File

@@ -1,17 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.Services
{
public interface IHttpRequest : IRequest
{
/// <summary>
/// Gets the HTTP Verb.
/// </summary>
string HttpMethod { get; }
/// <summary>
/// Gets the value of the Accept HTTP Request Header.
/// </summary>
string Accept { get; }
}
}

View File

@@ -1,35 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System.Net;
namespace MediaBrowser.Model.Services
{
public interface IHttpResult : IHasHeaders
{
/// <summary>
/// The HTTP Response Status.
/// </summary>
int Status { get; set; }
/// <summary>
/// The HTTP Response Status Code.
/// </summary>
HttpStatusCode StatusCode { get; set; }
/// <summary>
/// The HTTP Response ContentType.
/// </summary>
string ContentType { get; set; }
/// <summary>
/// Response DTO.
/// </summary>
object Response { get; set; }
/// <summary>
/// Holds the request call context.
/// </summary>
IRequest RequestContext { get; set; }
}
}

View File

@@ -1,93 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Model.Services
{
public interface IRequest
{
HttpResponse Response { get; }
/// <summary>
/// The name of the service being called (e.g. Request DTO Name)
/// </summary>
string OperationName { get; set; }
/// <summary>
/// The Verb / HttpMethod or Action for this request
/// </summary>
string Verb { get; }
/// <summary>
/// The request ContentType.
/// </summary>
string ContentType { get; }
bool IsLocal { get; }
string UserAgent { get; }
/// <summary>
/// The expected Response ContentType for this request.
/// </summary>
string ResponseContentType { get; set; }
/// <summary>
/// Attach any data to this request that all filters and services can access.
/// </summary>
Dictionary<string, object> Items { get; }
IHeaderDictionary Headers { get; }
IQueryCollection QueryString { get; }
string RawUrl { get; }
string AbsoluteUri { get; }
/// <summary>
/// The Remote Ip as reported by X-Forwarded-For, X-Real-IP or Request.UserHostAddress
/// </summary>
string RemoteIp { get; }
/// <summary>
/// The value of the Authorization Header used to send the Api Key, null if not available.
/// </summary>
string Authorization { get; }
string[] AcceptTypes { get; }
string PathInfo { get; }
Stream InputStream { get; }
long ContentLength { get; }
/// <summary>
/// The value of the Referrer, null if not available.
/// </summary>
Uri UrlReferrer { get; }
}
public interface IHttpFile
{
string Name { get; }
string FileName { get; }
long ContentLength { get; }
string ContentType { get; }
Stream InputStream { get; }
}
public interface IRequiresRequest
{
IRequest Request { get; set; }
}
}

View File

@@ -1,14 +0,0 @@
#pragma warning disable CS1591
using System.IO;
namespace MediaBrowser.Model.Services
{
public interface IRequiresRequestStream
{
/// <summary>
/// The raw Http Request Input Stream.
/// </summary>
Stream RequestStream { get; set; }
}
}

View File

@@ -1,15 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Model.Services
{
// marker interface
public interface IService
{
}
public interface IReturn { }
public interface IReturn<T> : IReturn { }
public interface IReturnVoid : IReturn { }
}

View File

@@ -1,11 +0,0 @@
#pragma warning disable CS1591
using System.IO;
namespace MediaBrowser.Model.Services
{
public interface IStreamWriter
{
void WriteTo(Stream responseStream);
}
}

View File

@@ -1,147 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Model.Services
{
// Remove this garbage class, it's just a bastard copy of NameValueCollection
public class QueryParamCollection : List<NameValuePair>
{
public QueryParamCollection()
{
}
private static StringComparison GetStringComparison()
{
return StringComparison.OrdinalIgnoreCase;
}
/// <summary>
/// Adds a new query parameter.
/// </summary>
public void Add(string key, string value)
{
Add(new NameValuePair(key, value));
}
private void Set(string key, string value)
{
if (string.IsNullOrEmpty(value))
{
var parameters = GetItems(key);
foreach (var p in parameters)
{
Remove(p);
}
return;
}
foreach (var pair in this)
{
var stringComparison = GetStringComparison();
if (string.Equals(key, pair.Name, stringComparison))
{
pair.Value = value;
return;
}
}
Add(key, value);
}
private string Get(string name)
{
var stringComparison = GetStringComparison();
foreach (var pair in this)
{
if (string.Equals(pair.Name, name, stringComparison))
{
return pair.Value;
}
}
return null;
}
private List<NameValuePair> GetItems(string name)
{
var stringComparison = GetStringComparison();
var list = new List<NameValuePair>();
foreach (var pair in this)
{
if (string.Equals(pair.Name, name, stringComparison))
{
list.Add(pair);
}
}
return list;
}
public virtual List<string> GetValues(string name)
{
var stringComparison = GetStringComparison();
var list = new List<string>();
foreach (var pair in this)
{
if (string.Equals(pair.Name, name, stringComparison))
{
list.Add(pair.Value);
}
}
return list;
}
public IEnumerable<string> Keys
{
get
{
var keys = new string[this.Count];
for (var i = 0; i < keys.Length; i++)
{
keys[i] = this[i].Name;
}
return keys;
}
}
/// <summary>
/// Gets or sets a query parameter value by name. A query may contain multiple values of the same name
/// (i.e. "x=1&amp;x=2"), in which case the value is an array, which works for both getting and setting.
/// </summary>
/// <param name="name">The query parameter name.</param>
/// <returns>The query parameter value or array of values.</returns>
public string this[string name]
{
get => Get(name);
set => Set(name, value);
}
private string GetQueryStringValue(NameValuePair pair)
{
return pair.Name + "=" + pair.Value;
}
public override string ToString()
{
var vals = this.Select(GetQueryStringValue).ToArray();
return string.Join("&", vals);
}
}
}

View File

@@ -1,163 +0,0 @@
#nullable disable
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Services
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RouteAttribute : Attribute
{
/// <summary>
/// <para>Initializes an instance of the <see cref="RouteAttribute"/> class.</para>
/// </summary>
/// <param name="path">
/// <para>The path template to map to the request. See
/// <see cref="Path">RouteAttribute.Path</see>
/// for details on the correct format.</para>
/// </param>
public RouteAttribute(string path)
: this(path, null)
{
}
/// <summary>
/// <para>Initializes an instance of the <see cref="RouteAttribute"/> class.</para>
/// </summary>
/// <param name="path">
/// <para>The path template to map to the request. See
/// <see cref="Path">RouteAttribute.Path</see>
/// for details on the correct format.</para>
/// </param>
/// <param name="verbs">A comma-delimited list of HTTP verbs supported by the
/// service. If unspecified, all verbs are assumed to be supported.</param>
public RouteAttribute(string path, string verbs)
{
Path = path;
Verbs = verbs;
}
/// <summary>
/// Gets or sets the path template to be mapped to the request.
/// </summary>
/// <value>
/// A <see cref="String"/> value providing the path mapped to
/// the request. Never <see langword="null"/>.
/// </value>
/// <remarks>
/// <para>Some examples of valid paths are:</para>
///
/// <list>
/// <item>"/Inventory"</item>
/// <item>"/Inventory/{Category}/{ItemId}"</item>
/// <item>"/Inventory/{ItemPath*}"</item>
/// </list>
///
/// <para>Variables are specified within "{}"
/// brackets. Each variable in the path is mapped to the same-named property
/// on the request DTO. At runtime, ServiceStack will parse the
/// request URL, extract the variable values, instantiate the request DTO,
/// and assign the variable values into the corresponding request properties,
/// prior to passing the request DTO to the service object for processing.</para>
///
/// <para>It is not necessary to specify all request properties as
/// variables in the path. For unspecified properties, callers may provide
/// values in the query string. For example: the URL
/// "http://services/Inventory?Category=Books&amp;ItemId=12345" causes the same
/// request DTO to be processed as "http://services/Inventory/Books/12345",
/// provided that the paths "/Inventory" (which supports the first URL) and
/// "/Inventory/{Category}/{ItemId}" (which supports the second URL)
/// are both mapped to the request DTO.</para>
///
/// <para>Please note that while it is possible to specify property values
/// in the query string, it is generally considered to be less RESTful and
/// less desirable than to specify them as variables in the path. Using the
/// query string to specify property values may also interfere with HTTP
/// caching.</para>
///
/// <para>The final variable in the path may contain a "*" suffix
/// to grab all remaining segments in the path portion of the request URL and assign
/// them to a single property on the request DTO.
/// For example, if the path "/Inventory/{ItemPath*}" is mapped to the request DTO,
/// then the request URL "http://services/Inventory/Books/12345" will result
/// in a request DTO whose ItemPath property contains "Books/12345".
/// You may only specify one such variable in the path, and it must be positioned at
/// the end of the path.</para>
/// </remarks>
public string Path { get; set; }
/// <summary>
/// Gets or sets short summary of what the route does.
/// </summary>
public string Summary { get; set; }
public string Description { get; set; }
public bool IsHidden { get; set; }
/// <summary>
/// Gets or sets longer text to explain the behaviour of the route.
/// </summary>
public string Notes { get; set; }
/// <summary>
/// Gets or sets a comma-delimited list of HTTP verbs supported by the service, such as
/// "GET,PUT,POST,DELETE".
/// </summary>
/// <value>
/// A <see cref="String"/> providing a comma-delimited list of HTTP verbs supported
/// by the service, <see langword="null"/> or empty if all verbs are supported.
/// </value>
public string Verbs { get; set; }
/// <summary>
/// Used to rank the precedences of route definitions in reverse routing.
/// i.e. Priorities below 0 are auto-generated have less precedence.
/// </summary>
public int Priority { get; set; }
protected bool Equals(RouteAttribute other)
{
return base.Equals(other)
&& string.Equals(Path, other.Path)
&& string.Equals(Summary, other.Summary)
&& string.Equals(Notes, other.Notes)
&& string.Equals(Verbs, other.Verbs)
&& Priority == other.Priority;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != this.GetType())
{
return false;
}
return Equals((RouteAttribute)obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Summary != null ? Summary.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Notes != null ? Notes.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Verbs != null ? Verbs.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Priority;
return hashCode;
}
}
}
}

View File

@@ -2,7 +2,6 @@
#pragma warning disable CS1591
using System;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Model.Session
{