Reformat JustAMan review pt3 changes

pull/1154/head
Erwin de Haan 6 years ago
parent 38f96af079
commit c1f76eb8ab

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

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

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

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

@ -146,7 +146,7 @@ namespace Mono.Nat.Upnp
var ns = new XmlNamespaceManager(xmldoc.NameTable);
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)
{

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

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

@ -161,7 +161,7 @@ namespace SocketHttpListener
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))
return true;

@ -73,7 +73,7 @@ namespace SocketHttpListener.Net
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);
}
@ -115,7 +115,7 @@ namespace SocketHttpListener.Net
private void OnRead(IAsyncResult base_ares)
{
var rb = (ReadBufferState)base_ares.AsyncState;
ReadBufferState rb = (ReadBufferState)base_ares.AsyncState;
var ares = rb.Ares;
try
{

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

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

@ -74,7 +74,7 @@ namespace SocketHttpListener.Net
throw new HttpListenerException((int)HttpStatusCode.BadRequest, "net_invalid_path");
// 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);
}
@ -185,7 +185,7 @@ namespace SocketHttpListener.Net
if (lp.Path.IndexOf("//", StringComparison.Ordinal) != -1)
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);
}
}

@ -44,7 +44,7 @@ namespace SocketHttpListener.Net
}
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>()) :
null;

@ -180,7 +180,7 @@ namespace SocketHttpListener.Net
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);
}
}
@ -256,7 +256,7 @@ namespace SocketHttpListener.Net
{
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))
return false;
if (InputStream.EndRead(ares) <= 0)

@ -94,10 +94,10 @@ namespace SocketHttpListener.Net
// Try to check the raw path using first the primary encoding (according to http.sys settings);
// if it fails try the secondary encoding.
var result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary));
ParsingResult result = BuildRequestUriUsingRawPath(GetEncoding(EncodingType.Primary));
if (result == ParsingResult.EncodingError)
{
var secondaryEncoding = GetEncoding(EncodingType.Secondary);
Encoding secondaryEncoding = GetEncoding(EncodingType.Secondary);
result = BuildRequestUriUsingRawPath(secondaryEncoding);
}
isValid = (result == ParsingResult.Success) ? true : false;
@ -136,7 +136,7 @@ namespace SocketHttpListener.Net
_requestUriString.Append(Uri.SchemeDelimiter);
_requestUriString.Append(_cookedUriHost);
var result = ParseRawPath(encoding);
ParsingResult result = ParseRawPath(encoding);
if (result == ParsingResult.Success)
{
_requestUriString.Append(_cookedUriQuery);
@ -263,7 +263,7 @@ namespace SocketHttpListener.Net
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));
return false;

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

@ -208,7 +208,7 @@ namespace SocketHttpListener.Net
if (!IsHeaderName(headerName))
throw new ArgumentException("Invalid character in header");
if (!headers.TryGetValue(headerName, out var info))
if (!headers.TryGetValue(headerName, out HeaderInfo info))
return false;
var flag = response ? HeaderInfo.Response : HeaderInfo.Request;
@ -312,7 +312,7 @@ namespace SocketHttpListener.Net
if (headerName == null)
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)

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

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

@ -78,6 +78,7 @@ namespace SocketHttpListener
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);
#endregion

Loading…
Cancel
Save