Reformat JustAMan review pt3 changes

This commit is contained in:
Erwin de Haan 2019-01-18 16:48:01 +01:00
parent 38f96af079
commit c1f76eb8ab
20 changed files with 117 additions and 117 deletions

View File

@ -702,7 +702,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
default: default:
string readerName = reader.Name; string readerName = reader.Name;
if (_validProviderIds.TryGetValue(readerName, out var providerIdValue)) if (_validProviderIds.TryGetValue(readerName, out string providerIdValue))
{ {
var id = reader.ReadElementContentAsString(); var id = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))

View File

@ -1,4 +1,3 @@
namespace Mono.Nat namespace Mono.Nat
{ {
public enum NatProtocol public enum NatProtocol

View File

@ -85,10 +85,10 @@ namespace Mono.Nat
{ {
if (n.OperationalStatus != OperationalStatus.Up && n.OperationalStatus != OperationalStatus.Unknown) if (n.OperationalStatus != OperationalStatus.Up && n.OperationalStatus != OperationalStatus.Unknown)
continue; continue;
var properties = n.GetIPProperties(); IPInterfaceProperties properties = n.GetIPProperties();
var gatewayList = new List<IPEndPoint>(); var gatewayList = new List<IPEndPoint>();
foreach (var gateway in properties.GatewayAddresses) foreach (GatewayIPAddressInformation gateway in properties.GatewayAddresses)
{ {
if (gateway.Address.AddressFamily == AddressFamily.InterNetwork) if (gateway.Address.AddressFamily == AddressFamily.InterNetwork)
{ {
@ -105,7 +105,7 @@ namespace Mono.Nat
gatewayList.Add(new IPEndPoint(gw2, PmpConstants.ServerPort)); gatewayList.Add(new IPEndPoint(gw2, PmpConstants.ServerPort));
} }
} }
foreach (var unicast in properties.UnicastAddresses) foreach (UnicastIPAddressInformation unicast in properties.UnicastAddresses)
{ {
if (/*unicast.DuplicateAddressDetectionState == DuplicateAddressDetectionState.Preferred if (/*unicast.DuplicateAddressDetectionState == DuplicateAddressDetectionState.Preferred
&& unicast.AddressPreferredLifetime != UInt32.MaxValue && unicast.AddressPreferredLifetime != UInt32.MaxValue
@ -150,7 +150,7 @@ namespace Mono.Nat
public async void Search() public async void Search()
{ {
foreach (var s in sockets) foreach (UdpClient s in sockets)
{ {
try try
{ {
@ -181,7 +181,7 @@ namespace Mono.Nat
// The nat-pmp search message. Must be sent to GatewayIP:53531 // The nat-pmp search message. Must be sent to GatewayIP:53531
byte[] buffer = new byte[] { PmpConstants.Version, PmpConstants.OperationCode }; byte[] buffer = new byte[] { PmpConstants.Version, PmpConstants.OperationCode };
foreach (var gatewayEndpoint in gatewayLists[client]) foreach (IPEndPoint gatewayEndpoint in gatewayLists[client])
{ {
await client.SendAsync(buffer, buffer.Length, gatewayEndpoint).ConfigureAwait(false); await client.SendAsync(buffer, buffer.Length, gatewayEndpoint).ConfigureAwait(false);
} }

View File

@ -57,7 +57,7 @@ namespace Mono.Nat.Upnp
var culture = CultureInfo.InvariantCulture; var culture = CultureInfo.InvariantCulture;
var builder = new StringBuilder(256); var builder = new StringBuilder(256);
var writer = CreateWriter(builder); XmlWriter writer = CreateWriter(builder);
WriteFullElement(writer, "NewRemoteHost", string.Empty); WriteFullElement(writer, "NewRemoteHost", string.Empty);
WriteFullElement(writer, "NewExternalPort", this.mapping.PublicPort.ToString(culture)); WriteFullElement(writer, "NewExternalPort", this.mapping.PublicPort.ToString(culture));

View File

@ -146,7 +146,7 @@ namespace Mono.Nat.Upnp
var ns = new XmlNamespaceManager(xmldoc.NameTable); var ns = new XmlNamespaceManager(xmldoc.NameTable);
ns.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0"); ns.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0");
var nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns); XmlNodeList nodes = xmldoc.SelectNodes("//*/ns:serviceList", ns);
foreach (XmlNode node in nodes) foreach (XmlNode node in nodes)
{ {

View File

@ -79,7 +79,7 @@ namespace OpenSubtitlesHandler
{ {
var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
var re = new MethodResponseLogIn("Success", "Log in successful."); var re = new MethodResponseLogIn("Success", "Log in successful.");
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -128,7 +128,7 @@ namespace OpenSubtitlesHandler
{ {
var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
var re = new MethodResponseLogIn("Success", "Log in successful."); var re = new MethodResponseLogIn("Success", "Log in successful.");
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -233,7 +233,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseNoOperation(); var R = new MethodResponseNoOperation();
var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0]; var mainStruct = (XmlRpcValueStruct)calls[0].Parameters[0];
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -241,7 +241,7 @@ namespace OpenSubtitlesHandler
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(MEMBER.Name + "= " + MEMBER.Data.Data); break;
case "download_limits": case "download_limits":
var dlStruct = (XmlRpcValueStruct)MEMBER.Data; var dlStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dlmember in dlStruct.Members) foreach (XmlRpcStructMember dlmember in dlStruct.Members)
{ {
OSHConsole.WriteLine(" >" + dlmember.Name + "= " + dlmember.Data.Data.ToString()); OSHConsole.WriteLine(" >" + dlmember.Name + "= " + dlmember.Data.Data.ToString());
switch (dlmember.Name) switch (dlmember.Name)
@ -297,7 +297,7 @@ namespace OpenSubtitlesHandler
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs. // Add subtitle search parameters. Each one will be like 'array' of structs.
var array = new XmlRpcValueArray(); var array = new XmlRpcValueArray();
foreach (var param in parameters) foreach (SubtitleSearchParameters param in parameters)
{ {
var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>()); var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// sublanguageid member // sublanguageid member
@ -366,7 +366,7 @@ namespace OpenSubtitlesHandler
// Create the response, we'll need it later // Create the response, we'll need it later
var R = new MethodResponseSubtitleSearch(); var R = new MethodResponseSubtitleSearch();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -385,13 +385,13 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine("Search results: "); OSHConsole.WriteLine("Search results: ");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new SubtitleSearchResult(); var result = new SubtitleSearchResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -477,7 +477,7 @@ namespace OpenSubtitlesHandler
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
// Add subtitle search parameters. Each one will be like 'array' of structs. // Add subtitle search parameters. Each one will be like 'array' of structs.
var array = new XmlRpcValueArray(); var array = new XmlRpcValueArray();
foreach (var param in parameters) foreach (SubtitleSearchParameters param in parameters)
{ {
var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>()); var strct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
// sublanguageid member // sublanguageid member
@ -546,7 +546,7 @@ namespace OpenSubtitlesHandler
// Create the response, we'll need it later // Create the response, we'll need it later
var R = new MethodResponseSubtitleSearch(); var R = new MethodResponseSubtitleSearch();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -565,13 +565,13 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine("Search results: "); OSHConsole.WriteLine("Search results: ");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new SubtitleSearchResult(); var result = new SubtitleSearchResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -690,7 +690,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseSubtitleDownload(); var R = new MethodResponseSubtitleDownload();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -708,13 +708,13 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine("Download results:"); OSHConsole.WriteLine("Download results:");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new SubtitleDownloadResult(); var result = new SubtitleDownloadResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -800,7 +800,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseSubtitleDownload(); var R = new MethodResponseSubtitleDownload();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -818,13 +818,13 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine("Download results:"); OSHConsole.WriteLine("Download results:");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new SubtitleDownloadResult(); var result = new SubtitleDownloadResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -904,7 +904,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseGetComments(); var R = new MethodResponseGetComments();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -922,13 +922,13 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine("Comments results:"); OSHConsole.WriteLine("Comments results:");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var commentStruct in rarray.Values) foreach (IXmlRpcValue commentStruct in rarray.Values)
{ {
if (commentStruct == null) continue; if (commentStruct == null) continue;
if (!(commentStruct is XmlRpcValueStruct)) continue; if (!(commentStruct is XmlRpcValueStruct)) continue;
var result = new GetCommentsResult(); var result = new GetCommentsResult();
foreach (var commentmember in ((XmlRpcValueStruct)commentStruct).Members) foreach (XmlRpcStructMember commentmember in ((XmlRpcValueStruct)commentStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (commentmember.Name) switch (commentmember.Name)
@ -984,7 +984,7 @@ namespace OpenSubtitlesHandler
parms.Add(a); parms.Add(a);
// Array of video parameters // Array of video parameters
a = new XmlRpcValueArray(); a = new XmlRpcValueArray();
foreach (var p in movies) foreach (SearchToMailMovieParameter p in movies)
{ {
var str = new XmlRpcValueStruct(new List<XmlRpcStructMember>()); var str = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
str.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); str.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash)));
@ -1010,7 +1010,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseSearchToMail(); var R = new MethodResponseSearchToMail();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1067,7 +1067,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseMovieSearch(); var R = new MethodResponseMovieSearch();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -1085,13 +1085,13 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine("Search results:"); OSHConsole.WriteLine("Search results:");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new MovieSearchResult(); var result = new MovieSearchResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -1158,7 +1158,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseMovieDetails(); var R = new MethodResponseMovieDetails();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -1177,7 +1177,7 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine("Details result:"); OSHConsole.WriteLine("Details result:");
var detailsStruct = (XmlRpcValueStruct)MEMBER.Data; var detailsStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dmem in detailsStruct.Members) foreach (XmlRpcStructMember dmem in detailsStruct.Members)
{ {
switch (dmem.Name) switch (dmem.Name)
{ {
@ -1194,7 +1194,7 @@ namespace OpenSubtitlesHandler
// this is another struct with cast members... // this is another struct with cast members...
OSHConsole.WriteLine(">" + dmem.Name + "= "); OSHConsole.WriteLine(">" + dmem.Name + "= ");
var castStruct = (XmlRpcValueStruct)dmem.Data; var castStruct = (XmlRpcValueStruct)dmem.Data;
foreach (var castMemeber in castStruct.Members) foreach (XmlRpcStructMember castMemeber in castStruct.Members)
{ {
R.Cast.Add(castMemeber.Data.Data.ToString()); R.Cast.Add(castMemeber.Data.Data.ToString());
OSHConsole.WriteLine(" >" + castMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + castMemeber.Data.Data.ToString());
@ -1204,7 +1204,7 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine(">" + dmem.Name + "= "); OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is another struct with directors members... // this is another struct with directors members...
var directorsStruct = (XmlRpcValueStruct)dmem.Data; var directorsStruct = (XmlRpcValueStruct)dmem.Data;
foreach (var directorsMember in directorsStruct.Members) foreach (XmlRpcStructMember directorsMember in directorsStruct.Members)
{ {
R.Directors.Add(directorsMember.Data.Data.ToString()); R.Directors.Add(directorsMember.Data.Data.ToString());
OSHConsole.WriteLine(" >" + directorsMember.Data.Data.ToString()); OSHConsole.WriteLine(" >" + directorsMember.Data.Data.ToString());
@ -1214,7 +1214,7 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine(">" + dmem.Name + "= "); OSHConsole.WriteLine(">" + dmem.Name + "= ");
// this is another struct with writers members... // this is another struct with writers members...
var writersStruct = (XmlRpcValueStruct)dmem.Data; var writersStruct = (XmlRpcValueStruct)dmem.Data;
foreach (var writersMember in writersStruct.Members) foreach (XmlRpcStructMember writersMember in writersStruct.Members)
{ {
R.Writers.Add(writersMember.Data.Data.ToString()); R.Writers.Add(writersMember.Data.Data.ToString());
OSHConsole.WriteLine("+->" + writersMember.Data.Data.ToString()); OSHConsole.WriteLine("+->" + writersMember.Data.Data.ToString());
@ -1330,7 +1330,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseInsertMovie(); var R = new MethodResponseInsertMovie();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
if (MEMBER.Name == "status") if (MEMBER.Name == "status")
{ {
@ -1375,7 +1375,7 @@ namespace OpenSubtitlesHandler
// Method call .. // Method call ..
var parms = new List<IXmlRpcValue>(); var parms = new List<IXmlRpcValue>();
parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String)); parms.Add(new XmlRpcValueBasic(TOKEN, XmlRpcBasicValueType.String));
foreach (var p in parameters) foreach (InsertMovieHashParameters p in parameters)
{ {
var pstruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>()); var pstruct = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
pstruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash))); pstruct.Members.Add(new XmlRpcStructMember("moviehash", new XmlRpcValueBasic(p.moviehash)));
@ -1404,7 +1404,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseInsertMovieHash(); var R = new MethodResponseInsertMovieHash();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1418,13 +1418,13 @@ namespace OpenSubtitlesHandler
break; break;
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
switch (dataMember.Name) switch (dataMember.Name)
{ {
case "accepted_moviehashes": case "accepted_moviehashes":
var mh = (XmlRpcValueArray)dataMember.Data; var mh = (XmlRpcValueArray)dataMember.Data;
foreach (var val in mh.Values) foreach (IXmlRpcValue val in mh.Values)
{ {
if (val is XmlRpcValueBasic) if (val is XmlRpcValueBasic)
{ {
@ -1434,7 +1434,7 @@ namespace OpenSubtitlesHandler
break; break;
case "new_imdbs": case "new_imdbs":
var mi = (XmlRpcValueArray)dataMember.Data; var mi = (XmlRpcValueArray)dataMember.Data;
foreach (var val in mi.Values) foreach (IXmlRpcValue val in mi.Values)
{ {
if (val is XmlRpcValueBasic) if (val is XmlRpcValueBasic)
{ {
@ -1493,7 +1493,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseServerInfo(); var R = new MethodResponseServerInfo();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1569,7 +1569,7 @@ namespace OpenSubtitlesHandler
//R.total_subtitles_languages = (string)MEMBER.Data.Data; //R.total_subtitles_languages = (string)MEMBER.Data.Data;
OSHConsole.WriteLine(">" + MEMBER.Name + ":"); OSHConsole.WriteLine(">" + MEMBER.Name + ":");
var luStruct = (XmlRpcValueStruct)MEMBER.Data; var luStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var luMemeber in luStruct.Members) foreach (XmlRpcStructMember luMemeber in luStruct.Members)
{ {
R.last_update_strings.Add(luMemeber.Name + " [" + luMemeber.Data.Data.ToString() + "]"); R.last_update_strings.Add(luMemeber.Name + " [" + luMemeber.Data.Data.ToString() + "]");
OSHConsole.WriteLine(" >" + luMemeber.Name + "= " + luMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + luMemeber.Name + "= " + luMemeber.Data.Data.ToString());
@ -1623,7 +1623,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseReportWrongMovieHash(); var R = new MethodResponseReportWrongMovieHash();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1691,7 +1691,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseAddComment(); var R = new MethodResponseAddComment();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1749,7 +1749,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseSubtitlesVote(); var R = new MethodResponseSubtitlesVote();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1757,7 +1757,7 @@ namespace OpenSubtitlesHandler
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dataMemeber in dataStruct.Members) foreach (XmlRpcStructMember dataMemeber in dataStruct.Members)
{ {
OSHConsole.WriteLine(" >" + dataMemeber.Name + "= " + dataMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + dataMemeber.Name + "= " + dataMemeber.Data.Data.ToString());
switch (dataMemeber.Name) switch (dataMemeber.Name)
@ -1882,7 +1882,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseAddRequest(); var R = new MethodResponseAddRequest();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1890,7 +1890,7 @@ namespace OpenSubtitlesHandler
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dataMemeber in dataStruct.Members) foreach (XmlRpcStructMember dataMemeber in dataStruct.Members)
{ {
switch (dataMemeber.Name) switch (dataMemeber.Name)
{ {
@ -1947,7 +1947,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseGetSubLanguages(); var R = new MethodResponseGetSubLanguages();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -1955,14 +1955,14 @@ namespace OpenSubtitlesHandler
case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break; case "seconds": R.Seconds = (double)MEMBER.Data.Data; OSHConsole.WriteLine(">" + MEMBER.Name + "= " + MEMBER.Data.Data.ToString()); break;
case "data":// array of structs case "data":// array of structs
var array = (XmlRpcValueArray)MEMBER.Data; var array = (XmlRpcValueArray)MEMBER.Data;
foreach (var value in array.Values) foreach (IXmlRpcValue value in array.Values)
{ {
if (value is XmlRpcValueStruct) if (value is XmlRpcValueStruct)
{ {
var valueStruct = (XmlRpcValueStruct)value; var valueStruct = (XmlRpcValueStruct)value;
var lang = new SubtitleLanguage(); var lang = new SubtitleLanguage();
OSHConsole.WriteLine(">SubLanguage:"); OSHConsole.WriteLine(">SubLanguage:");
foreach (var langMemeber in valueStruct.Members) foreach (XmlRpcStructMember langMemeber in valueStruct.Members)
{ {
OSHConsole.WriteLine(" >" + langMemeber.Name + "= " + langMemeber.Data.Data.ToString()); OSHConsole.WriteLine(" >" + langMemeber.Name + "= " + langMemeber.Data.Data.ToString());
switch (langMemeber.Name) switch (langMemeber.Name)
@ -2043,7 +2043,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseDetectLanguage(); var R = new MethodResponseDetectLanguage();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2054,7 +2054,7 @@ namespace OpenSubtitlesHandler
{ {
OSHConsole.WriteLine(">Languages:"); OSHConsole.WriteLine(">Languages:");
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
var lang = new DetectLanguageResult(); var lang = new DetectLanguageResult();
lang.InputSample = dataMember.Name; lang.InputSample = dataMember.Name;
@ -2116,7 +2116,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseGetAvailableTranslations(); var R = new MethodResponseGetAvailableTranslations();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2125,7 +2125,7 @@ namespace OpenSubtitlesHandler
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">data:"); OSHConsole.WriteLine(">data:");
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
if (dataMember.Data is XmlRpcValueStruct) if (dataMember.Data is XmlRpcValueStruct)
{ {
@ -2133,7 +2133,7 @@ namespace OpenSubtitlesHandler
var res = new GetAvailableTranslationsResult(); var res = new GetAvailableTranslationsResult();
res.LanguageID = dataMember.Name; res.LanguageID = dataMember.Name;
OSHConsole.WriteLine(" >LanguageID: " + dataMember.Name); OSHConsole.WriteLine(" >LanguageID: " + dataMember.Name);
foreach (var resMember in resStruct.Members) foreach (XmlRpcStructMember resMember in resStruct.Members)
{ {
switch (resMember.Name) switch (resMember.Name)
{ {
@ -2202,7 +2202,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseGetTranslation(); var R = new MethodResponseGetTranslation();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2258,7 +2258,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseAutoUpdate(); var R = new MethodResponseAutoUpdate();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2317,7 +2317,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseCheckMovieHash(); var R = new MethodResponseCheckMovieHash();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2326,13 +2326,13 @@ namespace OpenSubtitlesHandler
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">Data:"); OSHConsole.WriteLine(">Data:");
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
var res = new CheckMovieHashResult(); var res = new CheckMovieHashResult();
res.Name = dataMember.Name; res.Name = dataMember.Name;
OSHConsole.WriteLine(" >" + res.Name + ":"); OSHConsole.WriteLine(" >" + res.Name + ":");
var movieStruct = (XmlRpcValueStruct)dataMember.Data; var movieStruct = (XmlRpcValueStruct)dataMember.Data;
foreach (var movieMember in movieStruct.Members) foreach (XmlRpcStructMember movieMember in movieStruct.Members)
{ {
switch (movieMember.Name) switch (movieMember.Name)
{ {
@ -2394,7 +2394,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseCheckMovieHash2(); var R = new MethodResponseCheckMovieHash2();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2403,7 +2403,7 @@ namespace OpenSubtitlesHandler
case "data": case "data":
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
OSHConsole.WriteLine(">Data:"); OSHConsole.WriteLine(">Data:");
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
var res = new CheckMovieHash2Result(); var res = new CheckMovieHash2Result();
res.Name = dataMember.Name; res.Name = dataMember.Name;
@ -2413,7 +2413,7 @@ namespace OpenSubtitlesHandler
foreach (XmlRpcValueStruct movieStruct in dataArray.Values) foreach (XmlRpcValueStruct movieStruct in dataArray.Values)
{ {
var d = new CheckMovieHash2Data(); var d = new CheckMovieHash2Data();
foreach (var movieMember in movieStruct.Members) foreach (XmlRpcStructMember movieMember in movieStruct.Members)
{ {
switch (movieMember.Name) switch (movieMember.Name)
{ {
@ -2480,7 +2480,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseCheckSubHash(); var R = new MethodResponseCheckSubHash();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2489,7 +2489,7 @@ namespace OpenSubtitlesHandler
case "data": case "data":
OSHConsole.WriteLine(">Data:"); OSHConsole.WriteLine(">Data:");
var dataStruct = (XmlRpcValueStruct)MEMBER.Data; var dataStruct = (XmlRpcValueStruct)MEMBER.Data;
foreach (var dataMember in dataStruct.Members) foreach (XmlRpcStructMember dataMember in dataStruct.Members)
{ {
OSHConsole.WriteLine(" >" + dataMember.Name + "= " + dataMember.Data.Data.ToString()); OSHConsole.WriteLine(" >" + dataMember.Name + "= " + dataMember.Data.Data.ToString());
var r = new CheckSubHashResult(); var r = new CheckSubHashResult();
@ -2565,7 +2565,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseTryUploadSubtitles(); var R = new MethodResponseTryUploadSubtitles();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {
@ -2578,13 +2578,13 @@ namespace OpenSubtitlesHandler
OSHConsole.WriteLine("Results: "); OSHConsole.WriteLine("Results: ");
var rarray = (XmlRpcValueArray)MEMBER.Data; var rarray = (XmlRpcValueArray)MEMBER.Data;
foreach (var subStruct in rarray.Values) foreach (IXmlRpcValue subStruct in rarray.Values)
{ {
if (subStruct == null) continue; if (subStruct == null) continue;
if (!(subStruct is XmlRpcValueStruct)) continue; if (!(subStruct is XmlRpcValueStruct)) continue;
var result = new SubtitleSearchResult(); var result = new SubtitleSearchResult();
foreach (var submember in ((XmlRpcValueStruct)subStruct).Members) foreach (XmlRpcStructMember submember in ((XmlRpcValueStruct)subStruct).Members)
{ {
// To avoid errors of arranged info or missing ones, let's do it with switch.. // To avoid errors of arranged info or missing ones, let's do it with switch..
switch (submember.Name) switch (submember.Name)
@ -2679,7 +2679,7 @@ namespace OpenSubtitlesHandler
// CDS members // CDS members
int i = 1; int i = 1;
foreach (var cd in info.CDS) foreach (UploadSubtitleParameters cd in info.CDS)
{ {
var member2 = new XmlRpcStructMember("cd" + i, null); var member2 = new XmlRpcStructMember("cd" + i, null);
var memberStruct2 = new XmlRpcValueStruct(new List<XmlRpcStructMember>()); var memberStruct2 = new XmlRpcValueStruct(new List<XmlRpcStructMember>());
@ -2718,7 +2718,7 @@ namespace OpenSubtitlesHandler
var R = new MethodResponseUploadSubtitles(); var R = new MethodResponseUploadSubtitles();
// To make sure response is not currepted by server, do it in loop // To make sure response is not currepted by server, do it in loop
foreach (var MEMBER in mainStruct.Members) foreach (XmlRpcStructMember MEMBER in mainStruct.Members)
{ {
switch (MEMBER.Name) switch (MEMBER.Name)
{ {

View File

@ -60,7 +60,7 @@ namespace XmlRpcHandler
using (var XMLwrt = XmlWriter.Create(ms, sett)) using (var XMLwrt = XmlWriter.Create(ms, sett))
{ {
// Let's write the methods // Let's write the methods
foreach (var method in methods) foreach (XmlRpcMethodCall method in methods)
{ {
XMLwrt.WriteStartElement("methodCall");//methodCall XMLwrt.WriteStartElement("methodCall");//methodCall
XMLwrt.WriteStartElement("methodName");//methodName XMLwrt.WriteStartElement("methodName");//methodName
@ -68,7 +68,7 @@ namespace XmlRpcHandler
XMLwrt.WriteEndElement();//methodName XMLwrt.WriteEndElement();//methodName
XMLwrt.WriteStartElement("params");//params XMLwrt.WriteStartElement("params");//params
// Write values // Write values
foreach (var p in method.Parameters) foreach (IXmlRpcValue p in method.Parameters)
{ {
XMLwrt.WriteStartElement("param");//param XMLwrt.WriteStartElement("param");//param
if (p is XmlRpcValueBasic) if (p is XmlRpcValueBasic)
@ -124,7 +124,7 @@ namespace XmlRpcHandler
{ {
if (XMLread.Name == "param" && XMLread.IsStartElement()) if (XMLread.Name == "param" && XMLread.IsStartElement())
{ {
var val = ReadValue(XMLread); IXmlRpcValue val = ReadValue(XMLread);
if (val != null) if (val != null)
call.Parameters.Add(val); call.Parameters.Add(val);
} }
@ -190,7 +190,7 @@ namespace XmlRpcHandler
{ {
XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("value");//value
XMLwrt.WriteStartElement("struct");//struct XMLwrt.WriteStartElement("struct");//struct
foreach (var member in val.Members) foreach (XmlRpcStructMember member in val.Members)
{ {
XMLwrt.WriteStartElement("member");//member XMLwrt.WriteStartElement("member");//member
@ -221,7 +221,7 @@ namespace XmlRpcHandler
XMLwrt.WriteStartElement("value");//value XMLwrt.WriteStartElement("value");//value
XMLwrt.WriteStartElement("array");//array XMLwrt.WriteStartElement("array");//array
XMLwrt.WriteStartElement("data");//data XMLwrt.WriteStartElement("data");//data
foreach (var o in val.Values) foreach (IXmlRpcValue o in val.Values)
{ {
if (o is XmlRpcValueBasic) if (o is XmlRpcValueBasic)
{ {
@ -303,7 +303,7 @@ namespace XmlRpcHandler
xmlReader.Read();// read name xmlReader.Read();// read name
member.Name = ReadString(xmlReader); member.Name = ReadString(xmlReader);
var val = ReadValue(xmlReader, true); IXmlRpcValue val = ReadValue(xmlReader, true);
if (val != null) if (val != null)
{ {
member.Data = val; member.Data = val;
@ -329,7 +329,7 @@ namespace XmlRpcHandler
} }
else else
{ {
var val = ReadValue(xmlReader); IXmlRpcValue val = ReadValue(xmlReader);
if (val != null) if (val != null)
array.Values.Add(val); array.Values.Add(val);
} }

View File

@ -161,7 +161,7 @@ namespace SocketHttpListener
internal static bool Contains<T>(this IEnumerable<T> source, Func<T, bool> condition) internal static bool Contains<T>(this IEnumerable<T> source, Func<T, bool> condition)
{ {
foreach (var elm in source) foreach (T elm in source)
if (condition(elm)) if (condition(elm))
return true; return true;

View File

@ -73,7 +73,7 @@ namespace SocketHttpListener.Net
protected override int ReadCore(byte[] buffer, int offset, int count) protected override int ReadCore(byte[] buffer, int offset, int count)
{ {
var ares = BeginReadCore(buffer, offset, count, null, null); IAsyncResult ares = BeginReadCore(buffer, offset, count, null, null);
return EndRead(ares); return EndRead(ares);
} }
@ -115,7 +115,7 @@ namespace SocketHttpListener.Net
private void OnRead(IAsyncResult base_ares) private void OnRead(IAsyncResult base_ares)
{ {
var rb = (ReadBufferState)base_ares.AsyncState; ReadBufferState rb = (ReadBufferState)base_ares.AsyncState;
var ares = rb.Ares; var ares = rb.Ares;
try try
{ {

View File

@ -269,7 +269,7 @@ namespace SocketHttpListener.Net
Close(true); Close(true);
return; return;
} }
var listener = _epl.Listener; HttpListener listener = _epl.Listener;
if (_lastListener != listener) if (_lastListener != listener)
{ {
RemoveConnection(); RemoveConnection();
@ -417,7 +417,7 @@ namespace SocketHttpListener.Net
{ {
try try
{ {
var response = _context.Response; HttpListenerResponse response = _context.Response;
response.StatusCode = status; response.StatusCode = status;
response.ContentType = "text/html"; response.ContentType = "text/html";
string description = HttpStatusDescription.Get(status); string description = HttpStatusDescription.Get(status);
@ -509,7 +509,7 @@ namespace SocketHttpListener.Net
return; return;
} }
var s = _socket; Socket s = _socket;
_socket = null; _socket = null;
try try
{ {

View File

@ -277,7 +277,7 @@ namespace SocketHttpListener.Net
public bool BindContext(HttpListenerContext context) public bool BindContext(HttpListenerContext context)
{ {
var req = context.Request; var req = context.Request;
var listener = SearchListener(req.Url, out var prefix); HttpListener listener = SearchListener(req.Url, out var prefix);
if (listener == null) if (listener == null)
return false; return false;
@ -309,7 +309,7 @@ namespace SocketHttpListener.Net
if (host != null && host != "") if (host != null && host != "")
{ {
var localPrefixes = _prefixes; Dictionary<ListenerPrefix, HttpListener> localPrefixes = _prefixes;
foreach (var p in localPrefixes.Keys) foreach (var p in localPrefixes.Keys)
{ {
string ppath = p.Path; string ppath = p.Path;
@ -330,7 +330,7 @@ namespace SocketHttpListener.Net
return bestMatch; return bestMatch;
} }
var list = _unhandledPrefixes; List<ListenerPrefix> list = _unhandledPrefixes;
bestMatch = MatchFromList(host, path, list, out prefix); bestMatch = MatchFromList(host, path, list, out prefix);
if (path != pathSlash && bestMatch == null) if (path != pathSlash && bestMatch == null)
@ -360,7 +360,7 @@ namespace SocketHttpListener.Net
HttpListener bestMatch = null; HttpListener bestMatch = null;
int bestLength = -1; int bestLength = -1;
foreach (var p in list) foreach (ListenerPrefix p in list)
{ {
string ppath = p.Path; string ppath = p.Path;
if (ppath.Length < bestLength) if (ppath.Length < bestLength)
@ -382,7 +382,7 @@ namespace SocketHttpListener.Net
if (list == null) if (list == null)
return; return;
foreach (var p in list) foreach (ListenerPrefix p in list)
{ {
if (p.Path == prefix.Path) if (p.Path == prefix.Path)
throw new Exception("net_listener_already"); throw new Exception("net_listener_already");
@ -398,7 +398,7 @@ namespace SocketHttpListener.Net
int c = list.Count; int c = list.Count;
for (int i = 0; i < c; i++) for (int i = 0; i < c; i++)
{ {
var p = list[i]; ListenerPrefix p = list[i];
if (p.Path == prefix.Path) if (p.Path == prefix.Path)
{ {
list.RemoveAt(i); list.RemoveAt(i);
@ -413,7 +413,7 @@ namespace SocketHttpListener.Net
if (_prefixes.Count > 0) if (_prefixes.Count > 0)
return; return;
var list = _unhandledPrefixes; List<ListenerPrefix> list = _unhandledPrefixes;
if (list != null && list.Count > 0) if (list != null && list.Count > 0)
return; return;
@ -433,7 +433,7 @@ namespace SocketHttpListener.Net
// Clone the list because RemoveConnection can be called from Close // Clone the list because RemoveConnection can be called from Close
var connections = new List<HttpConnection>(_unregisteredConnections.Keys); var connections = new List<HttpConnection>(_unregisteredConnections.Keys);
foreach (var c in connections) foreach (HttpConnection c in connections)
c.Close(true); c.Close(true);
_unregisteredConnections.Clear(); _unregisteredConnections.Clear();
} }

View File

@ -74,7 +74,7 @@ namespace SocketHttpListener.Net
throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_path"); throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_path");
// listens on all the interfaces if host name cannot be parsed by IPAddress. // listens on all the interfaces if host name cannot be parsed by IPAddress.
var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure);
epl.AddPrefix(lp, listener); epl.AddPrefix(lp, listener);
} }
@ -185,7 +185,7 @@ namespace SocketHttpListener.Net
if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1) if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1)
return; return;
var epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure); HttpEndPointListener epl = GetEPListener(logger, lp.Host, lp.Port, listener, lp.Secure);
epl.RemovePrefix(lp, listener); epl.RemovePrefix(lp, listener);
} }
} }

View File

@ -44,7 +44,7 @@ namespace SocketHttpListener.Net
} }
internal IPrincipal ParseBasicAuthentication(string authData) => internal IPrincipal ParseBasicAuthentication(string authData) =>
TryParseBasicAuth(authData, out var errorCode, out string username, out string password) ? TryParseBasicAuth(authData, out HttpStatusCode errorCode, out string username, out string password) ?
new GenericPrincipal(new HttpListenerBasicIdentity(username, password), Array.Empty<string>()) : new GenericPrincipal(new HttpListenerBasicIdentity(username, password), Array.Empty<string>()) :
null; null;

View File

@ -180,7 +180,7 @@ namespace SocketHttpListener.Net
if (string.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0) if (string.Compare(Headers[HttpKnownHeaderNames.Expect], "100-continue", StringComparison.OrdinalIgnoreCase) == 0)
{ {
var output = _context.Connection.GetResponseStream(); HttpResponseStream output = _context.Connection.GetResponseStream();
output.InternalWrite(s_100continue, 0, s_100continue.Length); output.InternalWrite(s_100continue, 0, s_100continue.Length);
} }
} }
@ -256,7 +256,7 @@ namespace SocketHttpListener.Net
{ {
try try
{ {
var ares = InputStream.BeginRead(bytes, 0, length, null, null); IAsyncResult ares = InputStream.BeginRead(bytes, 0, length, null, null);
if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne(1000)) if (!ares.IsCompleted && !ares.AsyncWaitHandle.WaitOne(1000))
return false; return false;
if (InputStream.EndRead(ares) <= 0) if (InputStream.EndRead(ares) <= 0)

View File

@ -94,10 +94,10 @@ namespace SocketHttpListener.Net
// Try to check the raw path using first the primary encoding (according to http.sys settings); // Try to check the raw path using first the primary encoding (according to http.sys settings);
// if it fails try the secondary encoding. // if it fails try the secondary encoding.
var result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary)); ParsingResult result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary));
if (result == ParsingResult.EncodingError) if (result == ParsingResult.EncodingError)
{ {
var secondaryEncoding = GetEncoding(EncodingType.Secondary); Encoding secondaryEncoding = GetEncoding(EncodingType.Secondary);
result = BuildRequestUriUsingRawPath(secondaryEncoding); result = BuildRequestUriUsingRawPath(secondaryEncoding);
} }
isValid = (result == ParsingResult.Success) ? true : false; isValid = (result == ParsingResult.Success) ? true : false;
@ -136,7 +136,7 @@ namespace SocketHttpListener.Net
_requestUriString.Append(Uri.SchemeDelimiter); _requestUriString.Append(Uri.SchemeDelimiter);
_requestUriString.Append(_cookedUriHost); _requestUriString.Append(_cookedUriHost);
var result = ParseRawPath(encoding); ParsingResult result = ParseRawPath(encoding);
if (result == ParsingResult.Success) if (result == ParsingResult.Success)
{ {
_requestUriString.Append(_cookedUriQuery); _requestUriString.Append(_cookedUriQuery);
@ -263,7 +263,7 @@ namespace SocketHttpListener.Net
private bool AddPercentEncodedOctetToRawOctetsList(Encoding encoding, string escapedCharacter) private bool AddPercentEncodedOctetToRawOctetsList(Encoding encoding, string escapedCharacter)
{ {
if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out var encodedValue)) if (!byte.TryParse(escapedCharacter, NumberStyles.HexNumber, null, out byte encodedValue))
{ {
//if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, escapedCharacter)); //if (NetEventSource.IsEnabled) NetEventSource.Error(this, SR.Format(SR.net_log_listener_cant_convert_percent_value, escapedCharacter));
return false; return false;

View File

@ -70,7 +70,7 @@ namespace SocketHttpListener.Net
private void DisposeCore() private void DisposeCore()
{ {
byte[] bytes = null; byte[] bytes = null;
var ms = GetHeaders(true); MemoryStream ms = GetHeaders(true);
bool chunked = _response.SendChunked; bool chunked = _response.SendChunked;
if (_stream.CanWrite) if (_stream.CanWrite)
{ {
@ -110,7 +110,7 @@ namespace SocketHttpListener.Net
if (_stream.CanWrite) if (_stream.CanWrite)
{ {
var ms = GetHeaders(closing: false, isWebSocketHandshake: true); MemoryStream ms = GetHeaders(closing: false, isWebSocketHandshake: true);
bool chunked = _response.SendChunked; bool chunked = _response.SendChunked;
long start = ms.Position; long start = ms.Position;
@ -146,7 +146,7 @@ namespace SocketHttpListener.Net
return null; return null;
} }
var ms = new MemoryStream(); MemoryStream ms = new MemoryStream();
_response.SendHeaders(closing, ms, isWebSocketHandshake); _response.SendHeaders(closing, ms, isWebSocketHandshake);
return ms; return ms;
} }
@ -190,7 +190,7 @@ namespace SocketHttpListener.Net
return; return;
byte[] bytes = null; byte[] bytes = null;
var ms = GetHeaders(false); MemoryStream ms = GetHeaders(false);
bool chunked = _response.SendChunked; bool chunked = _response.SendChunked;
if (ms != null) if (ms != null)
{ {
@ -234,7 +234,7 @@ namespace SocketHttpListener.Net
} }
byte[] bytes = null; byte[] bytes = null;
var ms = GetHeaders(false); MemoryStream ms = GetHeaders(false);
bool chunked = _response.SendChunked; bool chunked = _response.SendChunked;
if (ms != null) if (ms != null)
{ {

View File

@ -208,7 +208,7 @@ namespace SocketHttpListener.Net
if (!IsHeaderName(headerName)) if (!IsHeaderName(headerName))
throw new ArgumentException("Invalid character in header"); throw new ArgumentException("Invalid character in header");
if (!headers.TryGetValue(headerName, out var info)) if (!headers.TryGetValue(headerName, out HeaderInfo info))
return false; return false;
var flag = response ? HeaderInfo.Response : HeaderInfo.Request; var flag = response ? HeaderInfo.Response : HeaderInfo.Request;
@ -312,7 +312,7 @@ namespace SocketHttpListener.Net
if (headerName == null) if (headerName == null)
return false; return false;
return headers.TryGetValue(headerName, out var info) && (info & HeaderInfo.MultiValue) != 0; return headers.TryGetValue(headerName, out HeaderInfo info) && (info & HeaderInfo.MultiValue) != 0;
} }
internal static bool IsHeaderValue(string value) internal static bool IsHeaderValue(string value)

View File

@ -16,8 +16,8 @@ namespace SocketHttpListener.Net.WebSockets
ValidateOptions(subProtocol, receiveBufferSize, MinSendBufferSize, keepAliveInterval); ValidateOptions(subProtocol, receiveBufferSize, MinSendBufferSize, keepAliveInterval);
// get property will create a new response if one doesn't exist. // get property will create a new response if one doesn't exist.
var response = context.Response; HttpListenerResponse response = context.Response;
var request = context.Request; HttpListenerRequest request = context.Request;
ValidateWebSocketHeaders(context); ValidateWebSocketHeaders(context);
string secWebSocketVersion = request.Headers[HttpKnownHeaderNames.SecWebSocketVersion]; string secWebSocketVersion = request.Headers[HttpKnownHeaderNames.SecWebSocketVersion];

View File

@ -20,7 +20,7 @@ namespace SocketHttpListener.Net.WebSockets
if (validStates != null && validStates.Length > 0) if (validStates != null && validStates.Length > 0)
{ {
foreach (var validState in validStates) foreach (WebSocketState validState in validStates)
{ {
if (currentState == validState) if (currentState == validState)
{ {

View File

@ -78,6 +78,7 @@ namespace SocketHttpListener
init(); init();
} }
// In the .NET Framework, this pulls the value from a P/Invoke. Here we just hardcode it to a reasonable default.
public static TimeSpan DefaultKeepAliveInterval => TimeSpan.FromSeconds(30); public static TimeSpan DefaultKeepAliveInterval => TimeSpan.FromSeconds(30);
#endregion #endregion