ReSharper conform to 'var' settings

pull/1154/head
Erwin de Haan 5 years ago
parent a36658f6f0
commit 65bd052f3e

@ -164,7 +164,7 @@ namespace BDInfo
if (DirectoryPLAYLIST != null)
{
FileSystemMetadata[] files = GetFiles(DirectoryPLAYLIST.FullName, ".mpls").ToArray();
foreach (FileSystemMetadata file in files)
foreach (var file in files)
{
PlaylistFiles.Add(
file.Name.ToUpper(), new TSPlaylistFile(this, file, _fileSystem, textEncoding));
@ -174,7 +174,7 @@ namespace BDInfo
if (DirectorySTREAM != null)
{
FileSystemMetadata[] files = GetFiles(DirectorySTREAM.FullName, ".m2ts").ToArray();
foreach (FileSystemMetadata file in files)
foreach (var file in files)
{
StreamFiles.Add(
file.Name.ToUpper(), new TSStreamFile(file, _fileSystem));
@ -184,7 +184,7 @@ namespace BDInfo
if (DirectoryCLIPINF != null)
{
FileSystemMetadata[] files = GetFiles(DirectoryCLIPINF.FullName, ".clpi").ToArray();
foreach (FileSystemMetadata file in files)
foreach (var file in files)
{
StreamClipFiles.Add(
file.Name.ToUpper(), new TSStreamClipFile(file, _fileSystem, textEncoding));
@ -194,7 +194,7 @@ namespace BDInfo
if (DirectorySSIF != null)
{
FileSystemMetadata[] files = GetFiles(DirectorySSIF.FullName, ".ssif").ToArray();
foreach (FileSystemMetadata file in files)
foreach (var file in files)
{
InterleavedFiles.Add(
file.Name.ToUpper(), new TSInterleavedFile(file));
@ -214,8 +214,8 @@ namespace BDInfo
public void Scan()
{
List<TSStreamClipFile> errorStreamClipFiles = new List<TSStreamClipFile>();
foreach (TSStreamClipFile streamClipFile in StreamClipFiles.Values)
var errorStreamClipFiles = new List<TSStreamClipFile>();
foreach (var streamClipFile in StreamClipFiles.Values)
{
try
{
@ -239,7 +239,7 @@ namespace BDInfo
}
}
foreach (TSStreamFile streamFile in StreamFiles.Values)
foreach (var streamFile in StreamFiles.Values)
{
string ssifName = Path.GetFileNameWithoutExtension(streamFile.Name) + ".SSIF";
if (InterleavedFiles.ContainsKey(ssifName))
@ -252,8 +252,8 @@ namespace BDInfo
StreamFiles.Values.CopyTo(streamFiles, 0);
Array.Sort(streamFiles, CompareStreamFiles);
List<TSPlaylistFile> errorPlaylistFiles = new List<TSPlaylistFile>();
foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values)
var errorPlaylistFiles = new List<TSPlaylistFile>();
foreach (var playlistFile in PlaylistFiles.Values)
{
try
{
@ -277,15 +277,15 @@ namespace BDInfo
}
}
List<TSStreamFile> errorStreamFiles = new List<TSStreamFile>();
foreach (TSStreamFile streamFile in streamFiles)
var errorStreamFiles = new List<TSStreamFile>();
foreach (var streamFile in streamFiles)
{
try
{
List<TSPlaylistFile> playlists = new List<TSPlaylistFile>();
foreach (TSPlaylistFile playlist in PlaylistFiles.Values)
var playlists = new List<TSPlaylistFile>();
foreach (var playlist in PlaylistFiles.Values)
{
foreach (TSStreamClip streamClip in playlist.StreamClips)
foreach (var streamClip in playlist.StreamClips)
{
if (streamClip.Name == streamFile.Name)
{
@ -314,12 +314,12 @@ namespace BDInfo
}
}
foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values)
foreach (var playlistFile in PlaylistFiles.Values)
{
playlistFile.Initialize();
if (!Is50Hz)
{
foreach (TSVideoStream videoStream in playlistFile.VideoStreams)
foreach (var videoStream in playlistFile.VideoStreams)
{
if (videoStream.FrameRate == TSFrameRate.FRAMERATE_25 ||
videoStream.FrameRate == TSFrameRate.FRAMERATE_50)
@ -339,7 +339,7 @@ namespace BDInfo
throw new ArgumentNullException(nameof(path));
}
FileSystemMetadata dir = _fileSystem.GetDirectoryInfo(path);
var dir = _fileSystem.GetDirectoryInfo(path);
while (dir != null)
{
@ -369,7 +369,7 @@ namespace BDInfo
if (dir != null)
{
FileSystemMetadata[] children = _fileSystem.GetDirectories(dir.FullName).ToArray();
foreach (FileSystemMetadata child in children)
foreach (var child in children)
{
if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase))
{
@ -378,7 +378,7 @@ namespace BDInfo
}
if (searchDepth > 0)
{
foreach (FileSystemMetadata child in children)
foreach (var child in children)
{
GetDirectory(
name, child, searchDepth - 1);
@ -395,7 +395,7 @@ namespace BDInfo
//if (!ExcludeDirs.Contains(directoryInfo.Name.ToUpper())) // TODO: Keep?
{
FileSystemMetadata[] pathFiles = _fileSystem.GetFiles(directoryInfo.FullName).ToArray();
foreach (FileSystemMetadata pathFile in pathFiles)
foreach (var pathFile in pathFiles)
{
if (pathFile.Extension.ToUpper() == ".SSIF")
{
@ -405,7 +405,7 @@ namespace BDInfo
}
FileSystemMetadata[] pathChildren = _fileSystem.GetDirectories(directoryInfo.FullName).ToArray();
foreach (FileSystemMetadata pathChild in pathChildren)
foreach (var pathChild in pathChildren)
{
size += GetDirectorySize(pathChild);
}

@ -211,7 +211,7 @@ namespace BDInfo
// TODO
if (stream.CoreStream != null)
{
TSAudioStream coreStream = (TSAudioStream)stream.CoreStream;
var coreStream = (TSAudioStream)stream.CoreStream;
if (coreStream.AudioMode == TSAudioMode.Extended &&
stream.ChannelCount == 5)
{

@ -85,9 +85,9 @@ namespace BDInfo
_fileSystem = fileSystem;
_textEncoding = textEncoding;
IsCustom = true;
foreach (TSStreamClip clip in clips)
foreach (var clip in clips)
{
TSStreamClip newClip = new TSStreamClip(
var newClip = new TSStreamClip(
clip.StreamFile, clip.StreamClipFile);
newClip.Name = clip.Name;
@ -123,7 +123,7 @@ namespace BDInfo
get
{
ulong size = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
size += clip.InterleavedFileSize;
}
@ -135,7 +135,7 @@ namespace BDInfo
get
{
ulong size = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
size += clip.FileSize;
}
@ -147,7 +147,7 @@ namespace BDInfo
get
{
double length = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
if (clip.AngleIndex == 0)
{
@ -163,7 +163,7 @@ namespace BDInfo
get
{
double length = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
length += clip.Length;
}
@ -176,7 +176,7 @@ namespace BDInfo
get
{
ulong size = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
if (clip.AngleIndex == 0)
{
@ -192,7 +192,7 @@ namespace BDInfo
get
{
ulong size = 0;
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
size += clip.PacketSize;
}
@ -263,7 +263,7 @@ namespace BDInfo
int itemCount = ReadInt16(data, ref pos);
int subitemCount = ReadInt16(data, ref pos);
List<TSStreamClip> chapterClips = new List<TSStreamClip>();
var chapterClips = new List<TSStreamClip>();
for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
{
int itemStart = pos;
@ -310,7 +310,7 @@ namespace BDInfo
if (outTime < 0) outTime &= 0x7FFFFFFF;
double timeOut = (double)outTime / 45000;
TSStreamClip streamClip = new TSStreamClip(
var streamClip = new TSStreamClip(
streamFile, streamClipFile);
streamClip.Name = streamFileName; //TODO
@ -361,7 +361,7 @@ namespace BDInfo
FileInfo.Name, angleClipFileName));
}
TSStreamClip angleClip =
var angleClip =
new TSStreamClip(angleFile, angleClipFile);
angleClip.AngleIndex = angle + 1;
angleClip.TimeIn = streamClip.TimeIn;
@ -394,33 +394,33 @@ namespace BDInfo
for (int i = 0; i < streamCountVideo; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
}
for (int i = 0; i < streamCountAudio; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
}
for (int i = 0; i < streamCountPG; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
}
for (int i = 0; i < streamCountIG; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
}
for (int i = 0; i < streamCountSecondaryAudio; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
pos += 2;
}
for (int i = 0; i < streamCountSecondaryVideo; i++)
{
TSStream stream = CreatePlaylistStream(data, ref pos);
var stream = CreatePlaylistStream(data, ref pos);
if (stream != null) PlaylistStreams[stream.PID] = stream;
pos += 6;
}
@ -458,7 +458,7 @@ namespace BDInfo
((long)data[pos + 6] << 8) +
((long)data[pos + 7]);
TSStreamClip streamClip = chapterClips[streamFileIndex];
var streamClip = chapterClips[streamFileIndex];
double chapterSeconds = (double)chapterTime / 45000;
@ -498,8 +498,8 @@ namespace BDInfo
{
LoadStreamClips();
Dictionary<string, List<double>> clipTimes = new Dictionary<string, List<double>>();
foreach (TSStreamClip clip in StreamClips)
var clipTimes = new Dictionary<string, List<double>>();
foreach (var clip in StreamClips)
{
if (clip.AngleIndex == 0)
{
@ -567,7 +567,7 @@ namespace BDInfo
int streamLength = data[pos++];
int streamPos = pos;
TSStreamType streamType = (TSStreamType)data[pos++];
var streamType = (TSStreamType)data[pos++];
switch (streamType)
{
case TSStreamType.MVC_VIDEO:
@ -579,11 +579,11 @@ namespace BDInfo
case TSStreamType.MPEG2_VIDEO:
case TSStreamType.VC1_VIDEO:
TSVideoFormat videoFormat = (TSVideoFormat)
var videoFormat = (TSVideoFormat)
(data[pos] >> 4);
TSFrameRate frameRate = (TSFrameRate)
var frameRate = (TSFrameRate)
(data[pos] & 0xF);
TSAspectRatio aspectRatio = (TSAspectRatio)
var aspectRatio = (TSAspectRatio)
(data[pos + 1] >> 4);
stream = new TSVideoStream();
@ -617,9 +617,9 @@ namespace BDInfo
int audioFormat = ReadByte(data, ref pos);
TSChannelLayout channelLayout = (TSChannelLayout)
var channelLayout = (TSChannelLayout)
(audioFormat >> 4);
TSSampleRate sampleRate = (TSSampleRate)
var sampleRate = (TSSampleRate)
(audioFormat & 0xF);
string audioLanguage = ReadString(data, 3, ref pos);
@ -712,7 +712,7 @@ namespace BDInfo
{
referenceClip = StreamClips[0];
}
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
if (clip.StreamClipFile.Streams.Count > referenceClip.StreamClipFile.Streams.Count)
{
@ -738,12 +738,12 @@ namespace BDInfo
}
}
foreach (TSStream clipStream
foreach (var clipStream
in referenceClip.StreamClipFile.Streams.Values)
{
if (!Streams.ContainsKey(clipStream.PID))
{
TSStream stream = clipStream.Clone();
var stream = clipStream.Clone();
Streams[clipStream.PID] = stream;
if (!IsCustom && !PlaylistStreams.ContainsKey(stream.PID))
@ -779,7 +779,7 @@ namespace BDInfo
referenceClip.StreamFile.Streams.ContainsKey(4114) &&
!Streams.ContainsKey(4114))
{
TSStream stream = referenceClip.StreamFile.Streams[4114].Clone();
var stream = referenceClip.StreamFile.Streams[4114].Clone();
Streams[4114] = stream;
if (stream.IsVideoStream)
{
@ -787,12 +787,12 @@ namespace BDInfo
}
}
foreach (TSStream clipStream
foreach (var clipStream
in referenceClip.StreamFile.Streams.Values)
{
if (Streams.ContainsKey(clipStream.PID))
{
TSStream stream = Streams[clipStream.PID];
var stream = Streams[clipStream.PID];
if (stream.StreamType != clipStream.StreamType) continue;
@ -811,8 +811,8 @@ namespace BDInfo
else if (stream.IsAudioStream &&
clipStream.IsAudioStream)
{
TSAudioStream audioStream = (TSAudioStream)stream;
TSAudioStream clipAudioStream = (TSAudioStream)clipStream;
var audioStream = (TSAudioStream)stream;
var clipAudioStream = (TSAudioStream)clipStream;
if (clipAudioStream.ChannelCount > audioStream.ChannelCount)
{
@ -863,7 +863,7 @@ namespace BDInfo
SortedStreams.Add(stream);
for (int i = 0; i < AngleCount; i++)
{
TSStream angleStream = stream.Clone();
var angleStream = stream.Clone();
angleStream.AngleIndex = i + 1;
AngleStreams[i][angleStream.PID] = angleStream;
SortedStreams.Add(angleStream);
@ -900,7 +900,7 @@ namespace BDInfo
public void ClearBitrates()
{
foreach (TSStreamClip clip in StreamClips)
foreach (var clip in StreamClips)
{
clip.PayloadBytes = 0;
clip.PacketCount = 0;
@ -908,7 +908,7 @@ namespace BDInfo
if (clip.StreamFile != null)
{
foreach (TSStream stream in clip.StreamFile.Streams.Values)
foreach (var stream in clip.StreamFile.Streams.Values)
{
stream.PayloadBytes = 0;
stream.PacketCount = 0;
@ -923,7 +923,7 @@ namespace BDInfo
}
}
foreach (TSStream stream in SortedStreams)
foreach (var stream in SortedStreams)
{
stream.PayloadBytes = 0;
stream.PacketCount = 0;

@ -109,7 +109,7 @@ namespace BDInfo
public TSDescriptor Clone()
{
TSDescriptor descriptor =
var descriptor =
new TSDescriptor(Name, (byte)Value.Length);
Value.CopyTo(descriptor.Value, 0);
return descriptor;
@ -404,7 +404,7 @@ namespace BDInfo
if (Descriptors != null)
{
stream.Descriptors = new List<TSDescriptor>();
foreach (TSDescriptor descriptor in Descriptors)
foreach (var descriptor in Descriptors)
{
stream.Descriptors.Add(descriptor.Clone());
}
@ -553,7 +553,7 @@ namespace BDInfo
public override TSStream Clone()
{
TSVideoStream stream = new TSVideoStream();
var stream = new TSVideoStream();
CopyTo(stream);
stream.VideoFormat = _VideoFormat;
@ -727,7 +727,7 @@ namespace BDInfo
public override TSStream Clone()
{
TSAudioStream stream = new TSAudioStream();
var stream = new TSAudioStream();
CopyTo(stream);
stream.SampleRate = SampleRate;
@ -756,7 +756,7 @@ namespace BDInfo
public override TSStream Clone()
{
TSGraphicsStream stream = new TSGraphicsStream();
var stream = new TSGraphicsStream();
CopyTo(stream);
return stream;
}
@ -772,7 +772,7 @@ namespace BDInfo
public override TSStream Clone()
{
TSTextStream stream = new TSTextStream();
var stream = new TSTextStream();
CopyTo(stream);
return stream;
}

@ -111,7 +111,7 @@ namespace BDInfo
data += (Stream.ReadByte() << shift);
shift -= 8;
}
BitVector32 vector = new BitVector32(data);
var vector = new BitVector32(data);
int value = 0;
for (int i = SkipBits; i < SkipBits + bits; i++)

@ -90,11 +90,11 @@ namespace BDInfo
public bool IsCompatible(TSStreamClip clip)
{
foreach (TSStream stream1 in StreamFile.Streams.Values)
foreach (var stream1 in StreamFile.Streams.Values)
{
if (clip.StreamFile.Streams.ContainsKey(stream1.PID))
{
TSStream stream2 = clip.StreamFile.Streams[stream1.PID];
var stream2 = clip.StreamFile.Streams[stream1.PID];
if (stream1.StreamType != stream2.StreamType)
{
return false;

@ -114,7 +114,7 @@ namespace BDInfo
streamOffset += 2;
TSStreamType streamType = (TSStreamType)
var streamType = (TSStreamType)
clipData[streamOffset + 1];
switch (streamType)
{
@ -127,11 +127,11 @@ namespace BDInfo
case TSStreamType.MPEG2_VIDEO:
case TSStreamType.VC1_VIDEO:
{
TSVideoFormat videoFormat = (TSVideoFormat)
var videoFormat = (TSVideoFormat)
(clipData[streamOffset + 2] >> 4);
TSFrameRate frameRate = (TSFrameRate)
var frameRate = (TSFrameRate)
(clipData[streamOffset + 2] & 0xF);
TSAspectRatio aspectRatio = (TSAspectRatio)
var aspectRatio = (TSAspectRatio)
(clipData[streamOffset + 3] >> 4);
stream = new TSVideoStream();
@ -168,9 +168,9 @@ namespace BDInfo
string languageCode =
_textEncoding.GetASCIIEncoding().GetString(languageBytes, 0, languageBytes.Length);
TSChannelLayout channelLayout = (TSChannelLayout)
var channelLayout = (TSChannelLayout)
(clipData[streamOffset + 2] >> 4);
TSSampleRate sampleRate = (TSSampleRate)
var sampleRate = (TSSampleRate)
(clipData[streamOffset + 2] & 0xF);
stream = new TSAudioStream();

@ -283,7 +283,7 @@ namespace BDInfo
bool isAVC = false;
bool isMVC = false;
foreach (TSStream finishedStream in Streams.Values)
foreach (var finishedStream in Streams.Values)
{
if (!finishedStream.IsInitialized)
{
@ -327,10 +327,10 @@ namespace BDInfo
UpdateStreamBitrate(PID, PTSPID, PTS, PTSDiff);
}
foreach (TSPlaylistFile playlist in Playlists)
foreach (var playlist in Playlists)
{
double packetSeconds = 0;
foreach (TSStreamClip clip in playlist.StreamClips)
foreach (var clip in playlist.StreamClips)
{
if (clip.AngleIndex == 0)
{
@ -339,7 +339,7 @@ namespace BDInfo
}
if (packetSeconds > 0)
{
foreach (TSStream playlistStream in playlist.SortedStreams)
foreach (var playlistStream in playlist.SortedStreams)
{
if (playlistStream.IsVBR)
{
@ -366,14 +366,14 @@ namespace BDInfo
{
if (Playlists == null) return;
TSStreamState streamState = StreamStates[PID];
var streamState = StreamStates[PID];
double streamTime = (double)PTS / 90000;
double streamInterval = (double)PTSDiff / 90000;
double streamOffset = streamTime + streamInterval;
foreach (TSPlaylistFile playlist in Playlists)
foreach (var playlist in Playlists)
{
foreach (TSStreamClip clip in playlist.StreamClips)
foreach (var clip in playlist.StreamClips)
{
if (clip.Name != this.Name) continue;
@ -390,7 +390,7 @@ namespace BDInfo
clip.PacketSeconds = streamOffset - clip.TimeIn;
}
Dictionary<ushort, TSStream> playlistStreams = playlist.Streams;
var playlistStreams = playlist.Streams;
if (clip.AngleIndex > 0 &&
clip.AngleIndex < playlist.AngleStreams.Count + 1)
{
@ -398,7 +398,7 @@ namespace BDInfo
}
if (playlistStreams.ContainsKey(PID))
{
TSStream stream = playlistStreams[PID];
var stream = playlistStreams[PID];
stream.PayloadBytes += streamState.WindowBytes;
stream.PacketCount += streamState.WindowPackets;
@ -425,13 +425,13 @@ namespace BDInfo
if (Streams.ContainsKey(PID))
{
TSStream stream = Streams[PID];
var stream = Streams[PID];
stream.PayloadBytes += streamState.WindowBytes;
stream.PacketCount += streamState.WindowPackets;
if (stream.IsVideoStream)
{
TSStreamDiagnostics diag = new TSStreamDiagnostics();
var diag = new TSStreamDiagnostics();
diag.Marker = (double)PTS / 90000;
diag.Interval = (double)PTSDiff / 90000;
diag.Bytes = streamState.WindowBytes;
@ -482,7 +482,7 @@ namespace BDInfo
StreamStates.Clear();
StreamDiagnostics.Clear();
TSPacketParser parser =
var parser =
new TSPacketParser();
long fileLength = (uint)fileStream.Length;
@ -839,7 +839,7 @@ namespace BDInfo
if (!Streams.ContainsKey(streamPID))
{
List<TSDescriptor> streamDescriptors =
var streamDescriptors =
new List<TSDescriptor>();
/*
@ -996,7 +996,7 @@ namespace BDInfo
{
--parser.PMTProgramDescriptorLength;
TSDescriptor descriptor = parser.PMTProgramDescriptors[
var descriptor = parser.PMTProgramDescriptors[
parser.PMTProgramDescriptors.Count - 1];
int valueIndex =
@ -1026,8 +1026,8 @@ namespace BDInfo
parser.StreamState != null &&
parser.TransportScramblingControl == 0)
{
TSStream stream = parser.Stream;
TSStreamState streamState = parser.StreamState;
var stream = parser.Stream;
var streamState = parser.StreamState;
streamState.Parse =
(streamState.Parse << 8) + buffer[i];
@ -1461,7 +1461,7 @@ namespace BDInfo
ulong PTSLast = 0;
ulong PTSDiff = 0;
foreach (TSStream stream in Streams.Values)
foreach (var stream in Streams.Values)
{
if (!stream.IsVideoStream) continue;

@ -45,7 +45,7 @@ namespace DvdLib.Ifo
{
using (var vmgFs = _fileSystem.GetFileStream(vmgPath.FullName, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
{
using (BigEndianBinaryReader vmgRead = new BigEndianBinaryReader(vmgFs))
using (var vmgRead = new BigEndianBinaryReader(vmgFs))
{
vmgFs.Seek(0x3E, SeekOrigin.Begin);
_titleSetCount = vmgRead.ReadUInt16();
@ -71,7 +71,7 @@ namespace DvdLib.Ifo
read.BaseStream.Seek(6, SeekOrigin.Current);
for (uint titleNum = 1; titleNum <= _titleCount; titleNum++)
{
Title t = new Title(titleNum);
var t = new Title(titleNum);
t.ParseTT_SRPT(read);
Titles.Add(t);
}
@ -98,7 +98,7 @@ namespace DvdLib.Ifo
using (var vtsFs = _fileSystem.GetFileStream(vtsPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read))
{
using (BigEndianBinaryReader vtsRead = new BigEndianBinaryReader(vtsFs))
using (var vtsRead = new BigEndianBinaryReader(vtsFs))
{
// Read VTS_PTT_SRPT
vtsFs.Seek(0xC8, SeekOrigin.Begin);
@ -119,7 +119,7 @@ namespace DvdLib.Ifo
{
uint chapNum = 1;
vtsFs.Seek(baseAddr + offsets[titleNum], SeekOrigin.Begin);
Title t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum + 1));
var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum + 1));
if (t == null) continue;
do
@ -149,7 +149,7 @@ namespace DvdLib.Ifo
vtsFs.Seek(3, SeekOrigin.Current);
uint vtsPgcOffset = vtsRead.ReadUInt32();
Title t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum));
var t = Titles.FirstOrDefault(vtst => vtst.IsVTSTitle(vtsNum, titleNum));
if (t != null) t.AddPgc(vtsRead, startByte + vtsPgcOffset, entryPgc, pgcNum);
}
}

@ -87,7 +87,7 @@ namespace DvdLib.Ifo
br.BaseStream.Seek(startPos + _cellPositionOffset, SeekOrigin.Begin);
for (int cellNum = 0; cellNum < _cellCount; cellNum++)
{
Cell c = new Cell();
var c = new Cell();
c.ParsePosition(br);
Cells.Add(c);
}
@ -99,7 +99,7 @@ namespace DvdLib.Ifo
}
br.BaseStream.Seek(startPos + _programMapOffset, SeekOrigin.Begin);
List<int> cellNumbers = new List<int>();
var cellNumbers = new List<int>();
for (int progNum = 0; progNum < _programCount; progNum++) cellNumbers.Add(br.ReadByte() - 1);
for (int i = 0; i < cellNumbers.Count; i++)

@ -50,7 +50,7 @@ namespace DvdLib.Ifo
long curPos = br.BaseStream.Position;
br.BaseStream.Seek(startByte, SeekOrigin.Begin);
ProgramChain pgc = new ProgramChain(pgcNum);
var pgc = new ProgramChain(pgcNum);
pgc.ParseHeader(br);
ProgramChains.Add(pgc);
if (entryPgc) EntryProgramChain = pgc;

@ -241,7 +241,7 @@ namespace Emby.Dlna.Api
var cacheLength = TimeSpan.FromDays(365);
var cacheKey = Request.RawUrl.GetMD5();
return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult<Stream>(_dlnaManager.GetIcon(request.Filename).Stream));
return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult(_dlnaManager.GetIcon(request.Filename).Stream));
}
public object Subscribe(ProcessContentDirectoryEventRequest request)

@ -242,7 +242,7 @@ namespace Emby.Dlna.ContentDirectory
var dlnaOptions = _config.GetDlnaConfiguration();
using (XmlWriter writer = XmlWriter.Create(builder, settings))
using (var writer = XmlWriter.Create(builder, settings))
{
//writer.WriteStartDocument();
@ -358,7 +358,7 @@ namespace Emby.Dlna.ContentDirectory
int totalCount = 0;
int provided = 0;
using (XmlWriter writer = XmlWriter.Create(builder, settings))
using (var writer = XmlWriter.Create(builder, settings))
{
//writer.WriteStartDocument();

@ -78,7 +78,7 @@ namespace Emby.Dlna.Didl
using (StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8))
{
using (XmlWriter writer = XmlWriter.Create(builder, settings))
using (var writer = XmlWriter.Create(builder, settings))
{
//writer.WriteStartDocument();

@ -854,7 +854,7 @@ namespace Emby.Dlna.PlayTo
if (index == -1) return request;
var query = url.Substring(index + 1);
QueryParamCollection values = MyHttpUtility.ParseQueryString(query);
var values = MyHttpUtility.ParseQueryString(query);
request.DeviceProfileId = values.Get("DeviceProfileId");
request.DeviceId = values.Get("DeviceId");

@ -85,7 +85,7 @@ namespace Emby.Dlna.Service
StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8);
using (XmlWriter writer = XmlWriter.Create(builder, settings))
using (var writer = XmlWriter.Create(builder, settings))
{
writer.WriteStartDocument(true);

@ -20,7 +20,7 @@ namespace Emby.Dlna.Service
StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8);
using (XmlWriter writer = XmlWriter.Create(builder, settings))
using (var writer = XmlWriter.Create(builder, settings))
{
writer.WriteStartDocument(true);

@ -164,7 +164,7 @@ namespace Emby.Drawing.Skia
private SKBitmap GetNextValidImage(string[] paths, int currentIndex, out int newIndex)
{
Dictionary<int, int> imagesTested = new Dictionary<int, int>();
var imagesTested = new Dictionary<int, int>();
SKBitmap bitmap = null;
while (imagesTested.Count < paths.Length)
@ -174,7 +174,7 @@ namespace Emby.Drawing.Skia
currentIndex = 0;
}
bitmap = SkiaEncoder.Decode(paths[currentIndex], false, _fileSystem, null, out SKEncodedOrigin origin);
bitmap = SkiaEncoder.Decode(paths[currentIndex], false, _fileSystem, null, out var origin);
imagesTested[currentIndex] = 0;

@ -73,7 +73,7 @@ namespace Emby.Drawing.Common
/// </summary>
/// <param name="binaryReader">The binary reader.</param>
/// <returns>Size.</returns>
/// <exception cref="System.ArgumentException">binaryReader</exception>
/// <exception cref="ArgumentException">binaryReader</exception>
/// <exception cref="ArgumentException">The image was of an unrecognized format.</exception>
private static ImageSize GetDimensions(BinaryReader binaryReader)
{
@ -200,7 +200,7 @@ namespace Emby.Drawing.Common
/// </summary>
/// <param name="binaryReader">The binary reader.</param>
/// <returns>Size.</returns>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentException"></exception>
private static ImageSize DecodeJfif(BinaryReader binaryReader)
{
// A JPEG image consists of a sequence of segments,

@ -491,7 +491,7 @@ namespace Emby.Drawing
/// <param name="item">The item.</param>
/// <param name="image">The image.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public string GetImageCacheTag(BaseItem item, ItemImageInfo image)
{
var supportedEnhancers = GetSupportedEnhancers(item, image.Type);
@ -523,7 +523,7 @@ namespace Emby.Drawing
/// <param name="image">The image.</param>
/// <param name="imageEnhancers">The image enhancers.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public string GetImageCacheTag(BaseItem item, ItemImageInfo image, IImageEnhancer[] imageEnhancers)
{
var originalImagePath = image.Path;
@ -744,7 +744,7 @@ namespace Emby.Drawing
/// <param name="uniqueName">Name of the unique.</param>
/// <param name="fileExtension">The file extension.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// path
/// or
/// uniqueName
@ -778,7 +778,7 @@ namespace Emby.Drawing
/// <param name="path">The path.</param>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// path
/// or
/// filename

@ -141,7 +141,7 @@ namespace IsoMounter
public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken)
{
if (MountISO(isoPath, out LinuxMount mountedISO))
if (MountISO(isoPath, out var mountedISO))
{
return Task.FromResult<IIsoMount>(mountedISO);
}

@ -16,7 +16,7 @@ namespace Emby.Naming.AudioBook
public AudioBookFilePathParserResult Parse(string path, bool IsDirectory)
{
AudioBookFilePathParserResult result = Parse(path);
var result = Parse(path);
return !result.Success ? new AudioBookFilePathParserResult() : result;
}

@ -133,7 +133,7 @@ namespace Emby.Naming.TV
result.EpisodeNumber = num;
}
Group endingNumberGroup = match.Groups["endingepnumber"];
var endingNumberGroup = match.Groups["endingepnumber"];
if (endingNumberGroup.Success)
{
// Will only set EndingEpsiodeNumber if the captured number is not followed by additional numbers

@ -40,7 +40,7 @@ namespace Emby.Naming.Video
/// <param name="path">The path.</param>
/// <param name="IsDirectory">if set to <c>true</c> [is folder].</param>
/// <returns>VideoFileInfo.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="ArgumentNullException">path</exception>
public VideoFileInfo Resolve(string path, bool IsDirectory, bool parseName = true)
{
if (string.IsNullOrEmpty(path))

@ -527,7 +527,7 @@ namespace Emby.Server.Implementations.Activity
const int DaysInMonth = 30;
// Get each non-zero value from TimeSpan component
List<string> values = new List<string>();
var values = new List<string>();
// Number of years
int days = span.Days;
@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.Activity
values.Add(CreateValueString(span.Seconds, "second"));
// Combine values into string
StringBuilder builder = new StringBuilder();
var builder = new StringBuilder();
for (int i = 0; i < values.Count; i++)
{
if (builder.Length > 0)

@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the configuration.
/// </summary>
/// <param name="newConfiguration">The new configuration.</param>
/// <exception cref="System.ArgumentNullException">newConfiguration</exception>
/// <exception cref="ArgumentNullException">newConfiguration</exception>
public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
{
if (newConfiguration == null)
@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the cache path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
private void ValidateCachePath(BaseApplicationConfiguration newConfig)
{
var newPath = newConfig.CachePath;

@ -822,7 +822,7 @@ namespace Emby.Server.Implementations
RegisterSingleInstance(ServerConfigurationManager);
IAssemblyInfo assemblyInfo = new AssemblyInfo();
RegisterSingleInstance<IAssemblyInfo>(assemblyInfo);
RegisterSingleInstance(assemblyInfo);
LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory.CreateLogger("LocalizationManager"), assemblyInfo, new TextLocalizer());
StringExtensions.LocalizationManager = LocalizationManager;
@ -920,7 +920,7 @@ namespace Emby.Server.Implementations
RegisterSingleInstance(CollectionManager);
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory.CreateLogger("PlaylistManager"), UserManager, ProviderManager);
RegisterSingleInstance<IPlaylistManager>(PlaylistManager);
RegisterSingleInstance(PlaylistManager);
LiveTvManager = new LiveTvManager(this, HttpClient, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, SecurityManager, () => ChannelManager);
RegisterSingleInstance(LiveTvManager);
@ -938,7 +938,7 @@ namespace Emby.Server.Implementations
RegisterMediaEncoder(assemblyInfo);
EncodingManager = new Emby.Server.Implementations.MediaEncoder.EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager);
RegisterSingleInstance(EncodingManager);
var activityLogRepo = GetActivityLogRepository();
@ -950,7 +950,7 @@ namespace Emby.Server.Implementations
RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, SessionManager, NetworkManager);
RegisterSingleInstance<IAuthService>(AuthService);
RegisterSingleInstance(AuthService);
SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory.CreateLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory, TextEncoding);
RegisterSingleInstance(SubtitleEncoder);
@ -1023,7 +1023,7 @@ namespace Emby.Server.Implementations
{
var arr = str.ToCharArray();
arr = Array.FindAll<char>(arr, (c => (char.IsLetterOrDigit(c)
arr = Array.FindAll(arr, (c => (char.IsLetterOrDigit(c)
|| char.IsWhiteSpace(c))));
var result = new string(arr);
@ -1057,7 +1057,7 @@ namespace Emby.Server.Implementations
// Don't use an empty string password
var password = string.IsNullOrWhiteSpace(info.Password) ? null : info.Password;
X509Certificate2 localCert = new X509Certificate2(certificateLocation, password);
var localCert = new X509Certificate2(certificateLocation, password);
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
if (!localCert.HasPrivateKey)
{

@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Configuration
/// Replaces the configuration.
/// </summary>
/// <param name="newConfiguration">The new configuration.</param>
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
public override void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
{
var newConfig = (ServerConfiguration)newConfiguration;
@ -137,7 +137,7 @@ namespace Emby.Server.Implementations.Configuration
/// Validates the SSL certificate.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
private void ValidateSslCertificate(BaseApplicationConfiguration newConfig)
{
var serverConfig = (ServerConfiguration)newConfig;
@ -159,7 +159,7 @@ namespace Emby.Server.Implementations.Configuration
/// Validates the metadata path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
private void ValidateMetadataPath(ServerConfiguration newConfig)
{
var newPath = newConfig.MetadataPath;

@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Data
public T RunInTransaction<T>(Func<IDatabaseConnection, T> action, TransactionMode mode)
{
return db.RunInTransaction<T>(action, mode);
return db.RunInTransaction(action, mode);
}
public IEnumerable<IReadOnlyList<IResultSetValue>> Query(string sql)

@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="client">The client.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken)
{
if (displayPreferences == null)
@ -131,7 +131,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="userId">The user id.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, CancellationToken cancellationToken)
{
if (displayPreferences == null)
@ -163,7 +163,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="userId">The user id.</param>
/// <param name="client">The client.</param>
/// <returns>Task{DisplayPreferences}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, Guid userId, string client)
{
if (string.IsNullOrEmpty(displayPreferencesId))
@ -202,7 +202,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="userId">The user id.</param>
/// <returns>Task{DisplayPreferences}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public IEnumerable<DisplayPreferences> GetAllDisplayPreferences(Guid userId)
{
var list = new List<DisplayPreferences>();

@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Data
/// Serializes to bytes.
/// </summary>
/// <returns>System.Byte[][].</returns>
/// <exception cref="System.ArgumentNullException">obj</exception>
/// <exception cref="ArgumentNullException">obj</exception>
public static byte[] SerializeToBytes(this IJsonSerializer json, object obj)
{
if (obj == null)

@ -531,7 +531,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public void SaveItem(BaseItem item, CancellationToken cancellationToken)
{
if (item == null)
@ -574,7 +574,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="items">The items.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// items
/// or
/// cancellationToken
@ -1198,8 +1198,8 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="id">The id.</param>
/// <returns>BaseItem.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">id</exception>
/// <exception cref="ArgumentException"></exception>
public BaseItem RetrieveItem(Guid id)
{
if (id.Equals(Guid.Empty))
@ -1945,7 +1945,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="item">The item.</param>
/// <returns>IEnumerable{ChapterInfo}.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
/// <exception cref="ArgumentNullException">id</exception>
public List<ChapterInfo> GetChapters(BaseItem item)
{
CheckDisposed();
@ -1977,7 +1977,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="item">The item.</param>
/// <param name="index">The index.</param>
/// <returns>ChapterInfo.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
/// <exception cref="ArgumentNullException">id</exception>
public ChapterInfo GetChapter(BaseItem item, int index)
{
CheckDisposed();

@ -110,7 +110,7 @@ namespace Emby.Server.Implementations.Data
private List<Guid> GetAllUserIdsWithUserData(IDatabaseConnection db)
{
List<Guid> list = new List<Guid>();
var list = new List<Guid>();
using (var statement = PrepareStatement(db, "select DISTINCT UserId from UserData where UserId not null"))
{
@ -271,7 +271,7 @@ namespace Emby.Server.Implementations.Data
/// <param name="internalUserId">The user id.</param>
/// <param name="key">The key.</param>
/// <returns>Task{UserItemData}.</returns>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// userId
/// or
/// key

@ -200,7 +200,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="ArgumentNullException">user</exception>
public void DeleteUser(User user)
{
if (user == null)

@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Data
/// </summary>
/// <param name="typeName">Name of the type.</param>
/// <returns>Type.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="ArgumentNullException"></exception>
public Type GetType(string typeName)
{
if (string.IsNullOrEmpty(typeName))

@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.Dto
/// <param name="user">The user.</param>
/// <param name="owner">The owner.</param>
/// <returns>Task{DtoBaseItem}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public BaseItemDto GetBaseItemDto(BaseItem item, ItemFields[] fields, User user = null, BaseItem owner = null)
{
var options = new DtoOptions
@ -463,7 +463,7 @@ namespace Emby.Server.Implementations.Dto
/// </summary>
/// <param name="item">The item.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
public string GetDtoId(BaseItem item)
{
return item.Id.ToString("N");

@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.EntryPoints
try
{
await _sessionManager.SendMessageToUserSessions<TimerEventInfo>(users, name, info, CancellationToken.None);
await _sessionManager.SendMessageToUserSessions(users, name, info, CancellationToken.None);
}
catch (ObjectDisposedException)
{

@ -82,7 +82,7 @@ namespace Emby.Server.Implementations.HttpClientManager
/// <param name="host">The host.</param>
/// <param name="enableHttpCompression">if set to <c>true</c> [enable HTTP compression].</param>
/// <returns>HttpClient.</returns>
/// <exception cref="System.ArgumentNullException">host</exception>
/// <exception cref="ArgumentNullException">host</exception>
private HttpClientInfo GetHttpClient(string host, bool enableHttpCompression)
{
if (string.IsNullOrEmpty(host))
@ -125,7 +125,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
string url = options.Url;
Uri uriAddress = new Uri(url);
var uriAddress = new Uri(url);
string userInfo = uriAddress.UserInfo;
if (!string.IsNullOrWhiteSpace(userInfo))
{
@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.HttpClientManager
url = url.Replace(userInfo + "@", string.Empty);
}
WebRequest request = CreateWebRequest(url);
var request = CreateWebRequest(url);
if (request is HttpWebRequest httpWebRequest)
{
@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.HttpClientManager
private static CredentialCache GetCredential(string url, string username, string password)
{
//ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
CredentialCache credentialCache = new CredentialCache();
var credentialCache = new CredentialCache();
credentialCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
return credentialCache;
}
@ -807,7 +807,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
var taskCompletion = new TaskCompletionSource<WebResponse>();
Task<WebResponse> asyncTask = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
var asyncTask = Task.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null);
ThreadPool.RegisterWaitForSingleObject((asyncTask as IAsyncResult).AsyncWaitHandle, TimeoutCallback, request, timeout, true);
var callback = new TaskCallback { taskCompletion = taskCompletion };
@ -823,7 +823,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
if (timedOut && state != null)
{
WebRequest request = (WebRequest)state;
var request = (WebRequest)state;
request.Abort();
}
}

@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <param name="remoteEndPoint">The remote end point.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
/// <exception cref="ArgumentNullException">socket</exception>
public WebSocketConnection(IWebSocket socket, string remoteEndPoint, IJsonSerializer jsonSerializer, ILogger logger, ITextEncoding textEncoding)
{
if (socket == null)
@ -215,7 +215,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <param name="message">The message.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">message</exception>
/// <exception cref="ArgumentNullException">message</exception>
public Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
{
if (message == null)

@ -23,8 +23,8 @@ namespace Emby.Server.Implementations.IO
/// <param name="isoPath">The iso path.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>IsoMount.</returns>
/// <exception cref="System.ArgumentNullException">isoPath</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">isoPath</exception>
/// <exception cref="ArgumentException"></exception>
public Task<IIsoMount> Mount(string isoPath, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(isoPath))

@ -263,7 +263,7 @@ namespace Emby.Server.Implementations.IO
/// <param name="lst">The LST.</param>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [contains parent folder] [the specified LST]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="ArgumentNullException">path</exception>
private static bool ContainsParentFolder(IEnumerable<string> lst, string path)
{
if (string.IsNullOrEmpty(path))

@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">filename</exception>
/// <exception cref="ArgumentNullException">filename</exception>
public virtual bool IsShortcut(string filename)
{
if (string.IsNullOrEmpty(filename))
@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">filename</exception>
/// <exception cref="ArgumentNullException">filename</exception>
public virtual string ResolveShortcut(string filename)
{
if (string.IsNullOrEmpty(filename))
@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="shortcutPath">The shortcut path.</param>
/// <param name="target">The target.</param>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// shortcutPath
/// or
/// target
@ -344,7 +344,7 @@ namespace Emby.Server.Implementations.IO
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">filename</exception>
/// <exception cref="ArgumentNullException">filename</exception>
public string GetValidFilename(string filename)
{
var builder = new StringBuilder(filename);
@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.IO
}
else
{
FileAttributes attributes = File.GetAttributes(path);
var attributes = File.GetAttributes(path);
attributes = RemoveAttribute(attributes, FileAttributes.Hidden);
File.SetAttributes(path, attributes);
}
@ -550,7 +550,7 @@ namespace Emby.Server.Implementations.IO
}
else
{
FileAttributes attributes = File.GetAttributes(path);
var attributes = File.GetAttributes(path);
attributes = RemoveAttribute(attributes, FileAttributes.ReadOnly);
File.SetAttributes(path, attributes);
}

@ -711,7 +711,7 @@ namespace Emby.Server.Implementations.Library
/// Creates the root media folder
/// </summary>
/// <returns>AggregateFolder.</returns>
/// <exception cref="System.InvalidOperationException">Cannot create the root folder until plugins have loaded</exception>
/// <exception cref="InvalidOperationException">Cannot create the root folder until plugins have loaded</exception>
public AggregateFolder CreateRootFolder()
{
var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath;
@ -905,7 +905,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="value">The value.</param>
/// <returns>Task{Year}.</returns>
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public Year GetYear(int value)
{
if (value <= 0)
@ -1233,7 +1233,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="id">The id.</param>
/// <returns>BaseItem.</returns>
/// <exception cref="System.ArgumentNullException">id</exception>
/// <exception cref="ArgumentNullException">id</exception>
public BaseItem GetItemById(Guid id)
{
if (id.Equals(Guid.Empty))
@ -2075,7 +2075,7 @@ namespace Emby.Server.Implementations.Library
public string GetConfiguredContentType(BaseItem item, bool inheritConfiguredPath)
{
ICollectionFolder collectionFolder = item as ICollectionFolder;
var collectionFolder = item as ICollectionFolder;
if (collectionFolder != null)
{
return collectionFolder.CollectionType;
@ -2417,11 +2417,11 @@ namespace Emby.Server.Implementations.Library
var episodeInfo = episode.IsFileProtocol ?
resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) :
new Emby.Naming.TV.EpisodeInfo();
new Naming.TV.EpisodeInfo();
if (episodeInfo == null)
{
episodeInfo = new Emby.Naming.TV.EpisodeInfo();
episodeInfo = new Naming.TV.EpisodeInfo();
}
var changed = false;

@ -127,7 +127,7 @@ namespace Emby.Server.Implementations.Library
if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio || i.Type == MediaStreamType.Video))
{
await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem))
await item.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem))
{
EnableRemoteContentProbe = true,
MetadataRefreshMode = MediaBrowser.Controller.Providers.MetadataRefreshMode.FullRefresh

@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="str">The STR.</param>
/// <param name="attrib">The attrib.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">attrib</exception>
/// <exception cref="ArgumentNullException">attrib</exception>
public static string GetAttributeValue(this string str, string attrib)
{
if (string.IsNullOrEmpty(str))

@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="fileSystem">The file system.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="directoryService">The directory service.</param>
/// <exception cref="System.ArgumentException">Item must have a path</exception>
/// <exception cref="ArgumentException">Item must have a path</exception>
public static void SetInitialItemValues(BaseItem item, Folder parent, IFileSystem fileSystem, ILibraryManager libraryManager, IDirectoryService directoryService)
{
// This version of the below method has no ItemResolveArgs, so we have to require the path already being set

@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions();
// If the path is a file check for a matching extensions
var parser = new Emby.Naming.Video.VideoResolver(namingOptions);
var parser = new VideoResolver(namingOptions);
if (args.IsDirectory)
{

@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
if (!season.IndexNumber.HasValue || !seasonParserResult.IsSeasonFolder)
{
var resolver = new Emby.Naming.TV.EpisodeResolver(namingOptions);
var resolver = new Naming.TV.EpisodeResolver(namingOptions);
var folderName = System.IO.Path.GetFileName(path);
var testPath = "\\\\test\\" + folderName;

@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions();
var episodeResolver = new Emby.Naming.TV.EpisodeResolver(namingOptions);
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions);
bool? isNamed = null;
bool? isOptimistic = null;
@ -179,7 +179,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="ArgumentNullException">path</exception>
private static bool IsVideoPlaceHolder(string path)
{
if (string.IsNullOrEmpty(path))

@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="query">The query.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{SearchHintResult}.</returns>
/// <exception cref="System.ArgumentNullException">searchTerm</exception>
/// <exception cref="ArgumentNullException">searchTerm</exception>
private List<SearchHintInfo> GetSearchHints(SearchQuery query, User user)
{
var searchTerm = query.SearchTerm;

@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="data">The data.</param>
/// <returns>DtoUserItemData.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="ArgumentNullException"></exception>
private UserItemDataDto GetUserItemDataDto(UserItemData data)
{
if (data == null)

@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="id">The id.</param>
/// <returns>User.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="ArgumentNullException"></exception>
public User GetUserById(Guid id)
{
if (id.Equals(Guid.Empty))
@ -619,8 +619,8 @@ namespace Emby.Server.Implementations.Library
/// <param name="user">The user.</param>
/// <param name="newName">The new name.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">user</exception>
/// <exception cref="ArgumentException"></exception>
public async Task RenameUser(User user, string newName)
{
if (user == null)
@ -652,8 +652,8 @@ namespace Emby.Server.Implementations.Library
/// Updates the user.
/// </summary>
/// <param name="user">The user.</param>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">user</exception>
/// <exception cref="ArgumentException"></exception>
public void UpdateUser(User user)
{
if (user == null)
@ -683,8 +683,8 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="name">The name.</param>
/// <returns>User.</returns>
/// <exception cref="System.ArgumentNullException">name</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">name</exception>
/// <exception cref="ArgumentException"></exception>
public async Task<User> CreateUser(string name)
{
if (string.IsNullOrWhiteSpace(name))
@ -731,8 +731,8 @@ namespace Emby.Server.Implementations.Library
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentNullException">user</exception>
/// <exception cref="ArgumentException"></exception>
public async Task DeleteUser(User user)
{
if (user == null)

@ -478,7 +478,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private static string GetMappedChannel(string channelId, NameValuePair[] mappings)
{
foreach (NameValuePair mapping in mappings)
foreach (var mapping in mappings)
{
if (StringHelper.EqualsIgnoreCase(mapping.Name, channelId))
{
@ -2002,7 +2002,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
CloseOutput = false
};
using (XmlWriter writer = XmlWriter.Create(stream, settings))
using (var writer = XmlWriter.Create(stream, settings))
{
writer.WriteStartDocument(true);
writer.WriteStartElement("tvshow");
@ -2069,7 +2069,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var isSeriesEpisode = timer.IsProgramSeries;
using (XmlWriter writer = XmlWriter.Create(stream, settings))
using (var writer = XmlWriter.Create(stream, settings))
{
writer.WriteStartDocument(true);

@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
{
List<string> dates = new List<string>();
var dates = new List<string>();
var start = new List<DateTime> { startDateUtc, startDateUtc.ToLocalTime() }.Min().Date;
var end = new List<DateTime> { endDateUtc, endDateUtc.ToLocalTime() }.Max().Date;
@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token;
using (var response = await Post(httpOptions, true, info).ConfigureAwait(false))
using (StreamReader reader = new StreamReader(response.Content))
using (var reader = new StreamReader(response.Content))
{
var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(response.Content).ConfigureAwait(false);
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
@ -125,7 +125,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestContent = "[\"" + string.Join("\", \"", programsID) + "\"]";
using (var innerResponse = await Post(httpOptions, true, info).ConfigureAwait(false))
using (StreamReader innerReader = new StreamReader(innerResponse.Content))
using (var innerReader = new StreamReader(innerResponse.Content))
{
var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponse.Content).ConfigureAwait(false);
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
@ -136,8 +136,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken).ConfigureAwait(false);
List<ProgramInfo> programsInfo = new List<ProgramInfo>();
foreach (ScheduleDirect.Program schedule in dailySchedules.SelectMany(d => d.programs))
var programsInfo = new List<ProgramInfo>();
foreach (var schedule in dailySchedules.SelectMany(d => d.programs))
{
//_logger.LogDebug("Proccesing Schedule for statio ID " + stationID +
// " which corresponds to channel " + channelNumber + " and program id " +
@ -222,9 +222,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private ProgramInfo GetProgram(string channelId, ScheduleDirect.Program programInfo, ScheduleDirect.ProgramDetails details)
{
DateTime startAt = GetDate(programInfo.airDateTime);
DateTime endAt = startAt.AddSeconds(programInfo.duration);
ProgramAudio audioType = ProgramAudio.Stereo;
var startAt = GetDate(programInfo.airDateTime);
var endAt = startAt.AddSeconds(programInfo.duration);
var audioType = ProgramAudio.Stereo;
var programId = programInfo.programID ?? string.Empty;
@ -526,15 +526,15 @@ namespace Emby.Server.Implementations.LiveTv.Listings
try
{
using (var httpResponse = await Get(options, false, info).ConfigureAwait(false))
using (Stream responce = httpResponse.Content)
using (var responce = httpResponse.Content)
{
var root = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Headends>>(responce).ConfigureAwait(false);
if (root != null)
{
foreach (ScheduleDirect.Headends headend in root)
foreach (var headend in root)
{
foreach (ScheduleDirect.Lineup lineup in headend.lineups)
foreach (var lineup in headend.lineups)
{
lineups.Add(new NameIdPair
{
@ -887,7 +887,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var allStations = root.stations ?? Enumerable.Empty<ScheduleDirect.Station>();
foreach (ScheduleDirect.Map map in root.map)
foreach (var map in root.map)
{
var channelNumber = GetChannelNumber(map);

@ -269,7 +269,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
string path = await GetXml(info.Path, CancellationToken.None).ConfigureAwait(false);
_logger.LogDebug("Opening XmlTvReader for {path}", path);
var reader = new XmlTvReader(path, GetLanguage(info));
IEnumerable<XmlTvChannel> results = reader.GetChannels();
var results = reader.GetChannels();
// Should this method be async?
return results.Select(c => new NameIdPair() { Id = c.Id, Name = c.DisplayName }).ToList();
@ -281,7 +281,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
string path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
_logger.LogDebug("Opening XmlTvReader for {path}", path);
var reader = new XmlTvReader(path, GetLanguage(info));
IEnumerable<XmlTvChannel> results = reader.GetChannels();
var results = reader.GetChannels();
// Should this method be async?
return results.Select(c => new ChannelInfo

@ -242,7 +242,7 @@ namespace Emby.Server.Implementations.LiveTv
var channel = (LiveTvChannel)_libraryManager.GetItemById(id);
bool isVideo = channel.ChannelType == ChannelType.TV;
ILiveTvService service = GetService(channel);
var service = GetService(channel);
_logger.LogInformation("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
MediaSourceInfo info;
@ -892,7 +892,7 @@ namespace Emby.Server.Implementations.LiveTv
var programList = _libraryManager.QueryItems(internalQuery).Items;
var totalCount = programList.Length;
IOrderedEnumerable<LiveTvProgram> orderedPrograms = programList.Cast<LiveTvProgram>().OrderBy(i => i.StartDate.Date);
var orderedPrograms = programList.Cast<LiveTvProgram>().OrderBy(i => i.StartDate.Date);
if (query.IsAiring ?? false)
{
@ -2302,7 +2302,7 @@ namespace Emby.Server.Implementations.LiveTv
// ServerConfiguration.SaveConfiguration crashes during xml serialization for AddListingProvider
info = _jsonSerializer.DeserializeFromString<ListingsProviderInfo>(_jsonSerializer.SerializeToString(info));
IListingsProvider provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
if (provider == null)
{
@ -2313,9 +2313,9 @@ namespace Emby.Server.Implementations.LiveTv
await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false);
LiveTvOptions config = GetConfiguration();
var config = GetConfiguration();
List<ListingsProviderInfo> list = config.ListingProviders.ToList();
var list = config.ListingProviders.ToList();
int index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
if (index == -1 || string.IsNullOrWhiteSpace(info.Id))

@ -262,7 +262,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var name = string.Format("Tuner {0}", i + 1);
var currentChannel = "none"; /// @todo Get current channel and map back to Station Id
var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
tuners.Add(new LiveTvTunerInfo
{
Name = name,

@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
continue;
var commandList = commands.GetCommands();
foreach (Tuple<string, string> command in commandList)
foreach (var command in commandList)
{
var channelMsg = CreateSetMessage(i, command.Item1, command.Item2, lockKeyValue);
await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var commandList = commands.GetCommands();
var receiveBuffer = new byte[8192];
foreach (Tuple<string, string> command in commandList)
foreach (var command in commandList)
{
var channelMsg = CreateSetMessage(_activeTuner, command.Item1, command.Item2, _lockkey);
await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false);

@ -19,10 +19,10 @@ namespace Emby.Server.Implementations.Net
//TODO Remove and reimplement using the IsDisposed property directly.
/// <summary>
/// Throws an <see cref="System.ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true.
/// Throws an <see cref="ObjectDisposedException"/> if the <see cref="IsDisposed"/> property is true.
/// </summary>
/// <seealso cref="IsDisposed"/>
/// <exception cref="System.ObjectDisposedException">Thrown if the <see cref="IsDisposed"/> property is true.</exception>
/// <exception cref="ObjectDisposedException">Thrown if the <see cref="IsDisposed"/> property is true.</exception>
/// <seealso cref="Dispose()"/>
protected virtual void ThrowIfDisposed()
{

@ -133,8 +133,8 @@ namespace Emby.Server.Implementations.Net
{
ThrowIfDisposed();
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint remoteEndPoint = (EndPoint)sender;
var sender = new IPEndPoint(IPAddress.Any, 0);
var remoteEndPoint = (EndPoint)sender;
var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint);

@ -7,7 +7,7 @@ namespace System.Net
using System.Text;
/// <summary>
/// Extension methods to convert <see cref="System.Numerics.BigInteger"/>
/// Extension methods to convert <see cref="BigInteger"/>
/// instances to hexadecimal, octal, and binary strings.
/// </summary>
public static class BigIntegerExtensions
@ -17,7 +17,7 @@ namespace System.Net
/// </summary>
/// <param name="bigint">A <see cref="BigInteger"/>.</param>
/// <returns>
/// A <see cref="System.String"/> containing a binary
/// A <see cref="string"/> containing a binary
/// representation of the supplied <see cref="BigInteger"/>.
/// </returns>
public static string ToBinaryString(this BigInteger bigint)
@ -54,7 +54,7 @@ namespace System.Net
/// </summary>
/// <param name="bigint">A <see cref="BigInteger"/>.</param>
/// <returns>
/// A <see cref="System.String"/> containing a hexadecimal
/// A <see cref="string"/> containing a hexadecimal
/// representation of the supplied <see cref="BigInteger"/>.
/// </returns>
public static string ToHexadecimalString(this BigInteger bigint)
@ -67,7 +67,7 @@ namespace System.Net
/// </summary>
/// <param name="bigint">A <see cref="BigInteger"/>.</param>
/// <returns>
/// A <see cref="System.String"/> containing an octal
/// A <see cref="string"/> containing an octal
/// representation of the supplied <see cref="BigInteger"/>.
/// </returns>
public static string ToOctalString(this BigInteger bigint)

@ -30,7 +30,7 @@ namespace System.Net
throw new ArgumentOutOfRangeException(nameof(i));
}
byte width = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? (byte)32 : (byte)128;
IPNetworkCollection ipn = this._ipnetwork.Subnet(width);
var ipn = this._ipnetwork.Subnet(width);
return ipn[i].Network;
}
}

@ -33,7 +33,7 @@ namespace System.Net
{
get
{
BigInteger uintNetwork = this._ipaddress & this._netmask;
var uintNetwork = this._ipaddress & this._netmask;
return uintNetwork;
}
}
@ -61,7 +61,7 @@ namespace System.Net
{
int width = this._family == Sockets.AddressFamily.InterNetwork ? 4 : 16;
BigInteger uintBroadcast = this._network + this._netmask.PositiveReverse(width);
var uintBroadcast = this._network + this._netmask.PositiveReverse(width);
return uintBroadcast;
}
}
@ -88,7 +88,7 @@ namespace System.Net
{
get
{
BigInteger fisrt = this._family == Sockets.AddressFamily.InterNetworkV6
var fisrt = this._family == Sockets.AddressFamily.InterNetworkV6
? this._network
: (this.Usable <= 0) ? this._network : this._network + 1;
return IPNetwork.ToIPAddress(fisrt, this._family);
@ -102,7 +102,7 @@ namespace System.Net
{
get
{
BigInteger last = this._family == Sockets.AddressFamily.InterNetworkV6
var last = this._family == Sockets.AddressFamily.InterNetworkV6
? this._broadcast
: (this.Usable <= 0) ? this._network : this._broadcast - 1;
return IPNetwork.ToIPAddress(last, this._family);
@ -122,8 +122,8 @@ namespace System.Net
return this.Total;
}
byte[] mask = new byte[] { 0xff, 0xff, 0xff, 0xff, 0x00 };
BigInteger bmask = new BigInteger(mask);
BigInteger usableIps = (_cidr > 30) ? 0 : ((bmask >> _cidr) - 1);
var bmask = new BigInteger(mask);
var usableIps = (_cidr > 30) ? 0 : ((bmask >> _cidr) - 1);
return usableIps;
}
}
@ -137,7 +137,7 @@ namespace System.Net
{
int max = this._family == Sockets.AddressFamily.InterNetwork ? 32 : 128;
BigInteger count = BigInteger.Pow(2, (max - _cidr));
var count = BigInteger.Pow(2, (max - _cidr));
return count;
}
}
@ -523,7 +523,7 @@ namespace System.Net
return;
}
BigInteger uintIpAddress = IPNetwork.ToBigInteger(ipaddress);
var uintIpAddress = IPNetwork.ToBigInteger(ipaddress);
byte? cidr2 = null;
bool parsed = IPNetwork.TryToCidr(netmask, out cidr2);
if (parsed == false)
@ -537,7 +537,7 @@ namespace System.Net
}
byte cidr = (byte)cidr2;
IPNetwork ipnet = new IPNetwork(uintIpAddress, ipaddress.AddressFamily, cidr);
var ipnet = new IPNetwork(uintIpAddress, ipaddress.AddressFamily, cidr);
ipnetwork = ipnet;
return;
@ -754,7 +754,7 @@ namespace System.Net
return;
}
BigInteger mask = new BigInteger(new byte[] {
var mask = new BigInteger(new byte[] {
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
@ -762,7 +762,7 @@ namespace System.Net
0x00
});
BigInteger masked = cidr == 0 ? 0 : mask << (128 - cidr);
var masked = cidr == 0 ? 0 : mask << (128 - cidr);
byte[] m = masked.ToByteArray();
byte[] bmask = new byte[17];
int copy = m.Length > 16 ? 16 : m.Length;
@ -858,7 +858,7 @@ namespace System.Net
/// cidr = null;
/// return;
/// }
BigInteger uintNetmask = (BigInteger)uintNetmask2;
var uintNetmask = (BigInteger)uintNetmask2;
byte? cidr2 = null;
IPNetwork.InternalToCidr(tryParse, uintNetmask, netmask.AddressFamily, out cidr2);
@ -951,8 +951,8 @@ namespace System.Net
return;
}
BigInteger mask = IPNetwork.ToUint(cidr, family);
IPAddress netmask2 = IPNetwork.ToIPAddress(mask, family);
var mask = IPNetwork.ToUint(cidr, family);
var netmask2 = IPNetwork.ToIPAddress(mask, family);
netmask = netmask2;
return;
@ -990,7 +990,7 @@ namespace System.Net
/// <returns></returns>
public static uint BitsSet(IPAddress netmask)
{
BigInteger uintNetmask = IPNetwork.ToBigInteger(netmask);
var uintNetmask = IPNetwork.ToBigInteger(netmask);
uint bits = IPNetwork.BitsSet(uintNetmask, netmask.AddressFamily);
return bits;
}
@ -1013,7 +1013,7 @@ namespace System.Net
{
throw new ArgumentNullException(nameof(netmask));
}
BigInteger uintNetmask = IPNetwork.ToBigInteger(netmask);
var uintNetmask = IPNetwork.ToBigInteger(netmask);
bool valid = IPNetwork.InternalValidNetmask(uintNetmask, netmask.AddressFamily);
return valid;
}
@ -1042,7 +1042,7 @@ namespace System.Net
0x00
});
BigInteger neg = ((~netmask) & (mask));
var neg = ((~netmask) & (mask));
bool isNetmask = ((neg + 1) & neg) == 0;
return isNetmask;
@ -1068,7 +1068,7 @@ namespace System.Net
Array.Reverse(bytes2);
byte[] sized = Resize(bytes2, family);
IPAddress ip = new IPAddress(sized);
var ip = new IPAddress(sized);
return ip;
}
@ -1122,9 +1122,9 @@ namespace System.Net
return false;
}
BigInteger uintNetwork = _network;
BigInteger uintBroadcast = _broadcast;
BigInteger uintAddress = IPNetwork.ToBigInteger(ipaddress);
var uintNetwork = _network;
var uintBroadcast = _broadcast;
var uintAddress = IPNetwork.ToBigInteger(ipaddress);
bool contains = (uintAddress >= uintNetwork
&& uintAddress <= uintBroadcast);
@ -1146,11 +1146,11 @@ namespace System.Net
throw new ArgumentNullException(nameof(network2));
}
BigInteger uintNetwork = _network;
BigInteger uintBroadcast = _broadcast;
var uintNetwork = _network;
var uintBroadcast = _broadcast;
BigInteger uintFirst = network2._network;
BigInteger uintLast = network2._broadcast;
var uintFirst = network2._network;
var uintLast = network2._broadcast;
bool contains = (uintFirst >= uintNetwork
&& uintLast <= uintBroadcast);
@ -1175,11 +1175,11 @@ namespace System.Net
throw new ArgumentNullException(nameof(network2));
}
BigInteger uintNetwork = _network;
BigInteger uintBroadcast = _broadcast;
var uintNetwork = _network;
var uintBroadcast = _broadcast;
BigInteger uintFirst = network2._network;
BigInteger uintLast = network2._broadcast;
var uintFirst = network2._network;
var uintLast = network2._broadcast;
bool overlap =
(uintFirst >= uintNetwork && uintFirst <= uintBroadcast)
@ -1428,8 +1428,8 @@ namespace System.Net
return;
}
IPNetwork first = (network1._network < network2._network) ? network1 : network2;
IPNetwork last = (network1._network > network2._network) ? network1 : network2;
var first = (network1._network < network2._network) ? network1 : network2;
var last = (network1._network > network2._network) ? network1 : network2;
/// Starting from here :
/// network1 and network2 have the same cidr,
@ -1449,10 +1449,10 @@ namespace System.Net
return;
}
BigInteger uintSupernet = first._network;
var uintSupernet = first._network;
byte cidrSupernet = (byte)(first._cidr - 1);
IPNetwork networkSupernet = new IPNetwork(uintSupernet, first._family, cidrSupernet);
var networkSupernet = new IPNetwork(uintSupernet, first._family, cidrSupernet);
if (networkSupernet._network != first._network)
{
if (trySupernet == false)
@ -1535,9 +1535,9 @@ namespace System.Net
return true;
}
List<IPNetwork> supernetted = new List<IPNetwork>();
List<IPNetwork> ipns = IPNetwork.Array2List(ipnetworks);
Stack<IPNetwork> current = IPNetwork.List2Stack(ipns);
var supernetted = new List<IPNetwork>();
var ipns = IPNetwork.Array2List(ipnetworks);
var current = IPNetwork.List2Stack(ipns);
int previousCount = 0;
int currentCount = current.Count;
@ -1547,8 +1547,8 @@ namespace System.Net
supernetted.Clear();
while (current.Count > 1)
{
IPNetwork ipn1 = current.Pop();
IPNetwork ipn2 = current.Peek();
var ipn1 = current.Pop();
var ipn2 = current.Peek();
IPNetwork outNetwork = null;
bool success = ipn1.TrySupernet(ipn2, out outNetwork);
@ -1578,7 +1578,7 @@ namespace System.Net
private static Stack<IPNetwork> List2Stack(List<IPNetwork> list)
{
Stack<IPNetwork> stack = new Stack<IPNetwork>();
var stack = new Stack<IPNetwork>();
list.ForEach(new Action<IPNetwork>(
delegate (IPNetwork ipn)
{
@ -1590,7 +1590,7 @@ namespace System.Net
private static List<IPNetwork> Array2List(IPNetwork[] array)
{
List<IPNetwork> ipns = new List<IPNetwork>();
var ipns = new List<IPNetwork>();
ipns.AddRange(array);
IPNetwork.RemoveNull(ipns);
ipns.Sort(new Comparison<IPNetwork>(
@ -1659,10 +1659,10 @@ namespace System.Net
throw new NotSupportedException("MixedAddressFamily");
}
IPNetwork ipnetwork = new IPNetwork(0, startIP.AddressFamily, 0);
var ipnetwork = new IPNetwork(0, startIP.AddressFamily, 0);
for (byte cidr = 32; cidr >= 0; cidr--)
{
IPNetwork wideSubnet = IPNetwork.Parse(start, cidr);
var wideSubnet = IPNetwork.Parse(start, cidr);
if (wideSubnet.Contains(endIP))
{
ipnetwork = wideSubnet;
@ -1707,7 +1707,7 @@ namespace System.Net
}
IPNetwork[] nnin = Array.FindAll<IPNetwork>(ipnetworks, new Predicate<IPNetwork>(
IPNetwork[] nnin = Array.FindAll(ipnetworks, new Predicate<IPNetwork>(
delegate (IPNetwork ipnet)
{
return ipnet != null;
@ -1726,19 +1726,19 @@ namespace System.Net
if (nnin.Length == 1)
{
IPNetwork ipn0 = nnin[0];
var ipn0 = nnin[0];
ipnetwork = ipn0;
return;
}
Array.Sort<IPNetwork>(nnin);
IPNetwork nnin0 = nnin[0];
BigInteger uintNnin0 = nnin0._ipaddress;
Array.Sort(nnin);
var nnin0 = nnin[0];
var uintNnin0 = nnin0._ipaddress;
IPNetwork nninX = nnin[nnin.Length - 1];
IPAddress ipaddressX = nninX.Broadcast;
var nninX = nnin[nnin.Length - 1];
var ipaddressX = nninX.Broadcast;
AddressFamily family = ipnetworks[0]._family;
var family = ipnetworks[0]._family;
foreach (var ipnx in ipnetworks)
{
if (ipnx._family != family)
@ -1747,10 +1747,10 @@ namespace System.Net
}
}
IPNetwork ipn = new IPNetwork(0, family, 0);
var ipn = new IPNetwork(0, family, 0);
for (byte cidr = nnin0._cidr; cidr >= 0; cidr--)
{
IPNetwork wideSubnet = new IPNetwork(uintNnin0, family, cidr);
var wideSubnet = new IPNetwork(uintNnin0, family, cidr);
if (wideSubnet.Contains(ipaddressX))
{
ipn = wideSubnet;
@ -1773,7 +1773,7 @@ namespace System.Net
public string Print()
{
StringWriter sw = new StringWriter();
var sw = new StringWriter();
sw.WriteLine("IPNetwork : {0}", ToString());
sw.WriteLine("Network : {0}", Network);
@ -1819,7 +1819,7 @@ namespace System.Net
cidr = 64;
return true;
}
BigInteger uintIPAddress = IPNetwork.ToBigInteger(ipaddress);
var uintIPAddress = IPNetwork.ToBigInteger(ipaddress);
uintIPAddress = uintIPAddress >> 29;
if (uintIPAddress <= 3)
{

@ -47,7 +47,7 @@ namespace System.Net
{
get
{
BigInteger count = BigInteger.Pow(2, this._cidrSubnet - this._cidr);
var count = BigInteger.Pow(2, this._cidrSubnet - this._cidr);
return count;
}
}
@ -61,11 +61,11 @@ namespace System.Net
throw new ArgumentOutOfRangeException(nameof(i));
}
BigInteger last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6
var last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6
? this._lastUsable : this._broadcast;
BigInteger increment = (last - this._network) / this.Count;
BigInteger uintNetwork = this._network + ((increment + 1) * i);
IPNetwork ipn = new IPNetwork(uintNetwork, this._ipnetwork.AddressFamily, this._cidrSubnet);
var increment = (last - this._network) / this.Count;
var uintNetwork = this._network + ((increment + 1) * i);
var ipn = new IPNetwork(uintNetwork, this._ipnetwork.AddressFamily, this._cidrSubnet);
return ipn;
}
}

@ -214,9 +214,9 @@ namespace Emby.Server.Implementations.Networking
subnets = new List<string>();
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
foreach (var unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
{
if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
{
@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.Networking
public int GetRandomUnusedUdpPort()
{
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 0);
var localEndPoint = new IPEndPoint(IPAddress.Any, 0);
using (var udpClient = new UdpClient(localEndPoint))
{
var port = ((IPEndPoint)(udpClient.Client.LocalEndPoint)).Port;
@ -522,8 +522,8 @@ namespace Emby.Server.Implementations.Networking
/// <param name="endpointstring">The endpointstring.</param>
/// <param name="defaultport">The defaultport.</param>
/// <returns>IPEndPoint.</returns>
/// <exception cref="System.ArgumentException">Endpoint descriptor may not be empty.</exception>
/// <exception cref="System.FormatException"></exception>
/// <exception cref="ArgumentException">Endpoint descriptor may not be empty.</exception>
/// <exception cref="FormatException"></exception>
private static async Task<IPEndPoint> Parse(string endpointstring, int defaultport)
{
if (string.IsNullOrEmpty(endpointstring)
@ -585,7 +585,7 @@ namespace Emby.Server.Implementations.Networking
/// </summary>
/// <param name="p">The p.</param>
/// <returns>System.Int32.</returns>
/// <exception cref="System.FormatException"></exception>
/// <exception cref="FormatException"></exception>
private static int GetPort(string p)
{
int port;
@ -605,7 +605,7 @@ namespace Emby.Server.Implementations.Networking
/// </summary>
/// <param name="p">The p.</param>
/// <returns>IPAddress.</returns>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentException"></exception>
private static async Task<IPAddress> GetIPfromHost(string p)
{
var hosts = await Dns.GetHostAddressesAsync(p).ConfigureAwait(false);

@ -469,12 +469,12 @@ namespace Emby.Server.Implementations.Playlists
folderPath = folderPath + Path.DirectorySeparatorChar;
}
Uri folderUri = new Uri(folderPath);
Uri fileAbsoluteUri = new Uri(fileAbsolutePath);
var folderUri = new Uri(folderPath);
var fileAbsoluteUri = new Uri(fileAbsolutePath);
if (folderUri.Scheme != fileAbsoluteUri.Scheme) { return fileAbsolutePath; } // path can't be made relative.
Uri relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri);
var relativeUri = folderUri.MakeRelativeUri(fileAbsoluteUri);
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
if (fileAbsoluteUri.Scheme.Equals("file", StringComparison.CurrentCultureIgnoreCase))

@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="taskManager">The task manager.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">
/// <exception cref="ArgumentNullException">
/// scheduledTask
/// or
/// applicationPaths
@ -256,7 +256,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// Gets the triggers that define when the task will run
/// </summary>
/// <value>The triggers.</value>
/// <exception cref="System.ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">value</exception>
public TaskTriggerInfo[] Triggers
{
get
@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary>
/// <param name="options">Task options.</param>
/// <returns>Task.</returns>
/// <exception cref="System.InvalidOperationException">Cannot execute a Task that is already running</exception>
/// <exception cref="InvalidOperationException">Cannot execute a Task that is already running</exception>
public async Task Execute(TaskOptions options)
{
var task = Task.Run(async () => await ExecuteInternal(options).ConfigureAwait(false));
@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <summary>
/// Stops the task if it is currently executing
/// </summary>
/// <exception cref="System.InvalidOperationException">Cannot cancel a Task unless it is in the Running state.</exception>
/// <exception cref="InvalidOperationException">Cannot cancel a Task unless it is in the Running state.</exception>
public void Cancel()
{
if (State != TaskState.Running)
@ -705,8 +705,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </summary>
/// <param name="info">The info.</param>
/// <returns>BaseTaskTrigger.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
/// <exception cref="System.ArgumentException">Invalid trigger type: + info.Type</exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException">Invalid trigger type: + info.Type</exception>
private ITaskTrigger GetTrigger(TaskTriggerInfo info)
{
var options = new TaskOptions

@ -61,7 +61,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <param name="applicationPaths">The application paths.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentException">kernel</exception>
/// <exception cref="ArgumentException">kernel</exception>
public TaskManager(IApplicationPaths applicationPaths, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem, ISystemEvents systemEvents)
{
ApplicationPaths = applicationPaths;

@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.Security
/// </summary>
/// <param name="value">The value.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">value</exception>
public string EncryptString(string value)
{
if (value == null)
@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Security
/// </summary>
/// <param name="value">The value.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">value</exception>
/// <exception cref="ArgumentNullException">value</exception>
public string DecryptString(string value)
{
if (value == null)

@ -27,7 +27,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="stream">The stream.</param>
/// <exception cref="System.ArgumentNullException">obj</exception>
/// <exception cref="ArgumentNullException">obj</exception>
public void SerializeToStream(object obj, Stream stream)
{
if (obj == null)
@ -48,7 +48,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="file">The file.</param>
/// <exception cref="System.ArgumentNullException">obj</exception>
/// <exception cref="ArgumentNullException">obj</exception>
public void SerializeToFile(object obj, string file)
{
if (obj == null)
@ -61,7 +61,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
using (Stream stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
using (var stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{
SerializeToStream(obj, stream);
}
@ -79,7 +79,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="type">The type.</param>
/// <param name="file">The file.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.ArgumentNullException">type</exception>
/// <exception cref="ArgumentNullException">type</exception>
public object DeserializeFromFile(Type type, string file)
{
if (type == null)
@ -92,7 +92,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
using (Stream stream = OpenFile(file))
using (var stream = OpenFile(file))
{
return DeserializeFromStream(stream, type);
}
@ -104,7 +104,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="file">The file.</param>
/// <returns>``0.</returns>
/// <exception cref="System.ArgumentNullException">file</exception>
/// <exception cref="ArgumentNullException">file</exception>
public T DeserializeFromFile<T>(string file)
where T : class
{
@ -113,7 +113,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
using (Stream stream = OpenFile(file))
using (var stream = OpenFile(file))
{
return DeserializeFromStream<T>(stream);
}
@ -125,7 +125,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="stream">The stream.</param>
/// <returns>``0.</returns>
/// <exception cref="System.ArgumentNullException">stream</exception>
/// <exception cref="ArgumentNullException">stream</exception>
public T DeserializeFromStream<T>(Stream stream)
{
if (stream == null)
@ -153,7 +153,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="text">The text.</param>
/// <returns>``0.</returns>
/// <exception cref="System.ArgumentNullException">text</exception>
/// <exception cref="ArgumentNullException">text</exception>
public T DeserializeFromString<T>(string text)
{
if (string.IsNullOrEmpty(text))
@ -170,7 +170,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="stream">The stream.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.ArgumentNullException">stream</exception>
/// <exception cref="ArgumentNullException">stream</exception>
public object DeserializeFromStream(Stream stream, Type type)
{
if (stream == null)
@ -236,7 +236,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="json">The json.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.ArgumentNullException">json</exception>
/// <exception cref="ArgumentNullException">json</exception>
public object DeserializeFromString(string json, Type type)
{
if (string.IsNullOrEmpty(json))
@ -257,7 +257,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">obj</exception>
/// <exception cref="ArgumentNullException">obj</exception>
public string SerializeToString(object obj)
{
if (obj == null)

@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Services
public void RegisterRestPaths(HttpListenerHost appHost, Type requestType, Type serviceType)
{
var attrs = appHost.GetRouteAttributes(requestType);
foreach (RouteAttribute attr in attrs)
foreach (var attr in attrs)
{
var restPath = new RestPath(appHost.CreateInstance, appHost.GetParseFn, requestType, serviceType, attr.Path, attr.Verbs, attr.IsHidden, attr.Summary, attr.Description);

@ -201,8 +201,8 @@ namespace Emby.Server.Implementations.Session
/// <param name="remoteEndPoint">The remote end point.</param>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.UnauthorizedAccessException"></exception>
/// <exception cref="ArgumentNullException">user</exception>
/// <exception cref="UnauthorizedAccessException"></exception>
public SessionInfo LogSessionActivity(string appName,
string appVersion,
string deviceId,
@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.Session
/// Removes the now playing item id.
/// </summary>
/// <param name="session">The session.</param>
/// <exception cref="System.ArgumentNullException">item</exception>
/// <exception cref="ArgumentNullException">item</exception>
private void RemoveNowPlayingItem(SessionInfo session)
{
session.NowPlayingItem = null;
@ -404,7 +404,7 @@ namespace Emby.Server.Implementations.Session
CheckDisposed();
SessionInfo sessionInfo = _activeConnections.GetOrAdd(key, k =>
var sessionInfo = _activeConnections.GetOrAdd(key, k =>
{
return CreateSession(k, appName, appVersion, deviceId, deviceName, remoteEndPoint, user);
});
@ -571,7 +571,7 @@ namespace Emby.Server.Implementations.Session
/// </summary>
/// <param name="info">The info.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">info</exception>
/// <exception cref="ArgumentNullException">info</exception>
public async Task OnPlaybackStart(PlaybackStartInfo info)
{
CheckDisposed();
@ -784,8 +784,8 @@ namespace Emby.Server.Implementations.Session
/// </summary>
/// <param name="info">The info.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">info</exception>
/// <exception cref="System.ArgumentOutOfRangeException">positionTicks</exception>
/// <exception cref="ArgumentNullException">info</exception>
/// <exception cref="ArgumentOutOfRangeException">positionTicks</exception>
public async Task OnPlaybackStopped(PlaybackStopInfo info)
{
CheckDisposed();
@ -1284,8 +1284,8 @@ namespace Emby.Server.Implementations.Session
/// </summary>
/// <param name="sessionId">The session identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <exception cref="System.UnauthorizedAccessException">Cannot modify additional users without authenticating first.</exception>
/// <exception cref="System.ArgumentException">The requested user is already the primary user of the session.</exception>
/// <exception cref="UnauthorizedAccessException">Cannot modify additional users without authenticating first.</exception>
/// <exception cref="ArgumentException">The requested user is already the primary user of the session.</exception>
public void AddAdditionalUser(string sessionId, Guid userId)
{
CheckDisposed();
@ -1318,8 +1318,8 @@ namespace Emby.Server.Implementations.Session
/// </summary>
/// <param name="sessionId">The session identifier.</param>
/// <param name="userId">The user identifier.</param>
/// <exception cref="System.UnauthorizedAccessException">Cannot modify additional users without authenticating first.</exception>
/// <exception cref="System.ArgumentException">The requested user is already the primary user of the session.</exception>
/// <exception cref="UnauthorizedAccessException">Cannot modify additional users without authenticating first.</exception>
/// <exception cref="ArgumentException">The requested user is already the primary user of the session.</exception>
public void RemoveAdditionalUser(string sessionId, Guid userId)
{
CheckDisposed();

@ -29,8 +29,8 @@ namespace Emby.Server.Implementations.Sorting
char thisCh = s1[thisMarker];
char thatCh = s2[thatMarker];
StringBuilder thisChunk = new StringBuilder();
StringBuilder thatChunk = new StringBuilder();
var thisChunk = new StringBuilder();
var thatChunk = new StringBuilder();
while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || SortHelper.InChunk(thisCh, thisChunk[0])))
{

@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.TV
OrderBy = new[] { new ValueTuple<string, SortOrder>(ItemSortBy.DatePlayed, SortOrder.Descending) },
SeriesPresentationUniqueKey = presentationUniqueKey,
Limit = limit,
DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions
DtoOptions = new DtoOptions
{
Fields = new ItemFields[]
{
@ -196,7 +196,7 @@ namespace Emby.Server.Implementations.TV
IsPlayed = true,
Limit = 1,
ParentIndexNumberNotEquals = 0,
DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions
DtoOptions = new DtoOptions
{
Fields = new ItemFields[]
{

@ -164,7 +164,7 @@ namespace NLangDetect.Core
public string Detect()
{
List<Language> probabilities = GetProbabilities();
var probabilities = GetProbabilities();
return
probabilities.Count > 0
@ -179,7 +179,7 @@ namespace NLangDetect.Core
DetectBlock();
}
List<Language> list = SortProbability(_langprob);
var list = SortProbability(_langprob);
return list;
}
@ -241,7 +241,7 @@ namespace NLangDetect.Core
{
CleanText();
List<string> ngrams = ExtractNGrams();
var ngrams = ExtractNGrams();
if (ngrams.Count == 0)
{
@ -250,7 +250,7 @@ namespace NLangDetect.Core
_langprob = new double[_langlist.Count];
Random rand = (_seed.HasValue ? new Random(_seed.Value) : new Random());
var rand = (_seed.HasValue ? new Random(_seed.Value) : new Random());
for (int t = 0; t < _trialsCount; t++)
{
@ -305,7 +305,7 @@ namespace NLangDetect.Core
private List<string> ExtractNGrams()
{
var list = new List<string>();
NGram ngram = new NGram();
var ngram = new NGram();
for (int i = 0; i < _text.Length; i++)
{
@ -332,7 +332,7 @@ namespace NLangDetect.Core
return;
}
ProbVector langProbMap = _wordLangProbMap[word];
var langProbMap = _wordLangProbMap[word];
double weight = alpha / _BaseFreq;
for (int i = 0; i < prob.Length; i++)

@ -54,7 +54,7 @@ namespace NLangDetect.Core
public static Detector Create(double alpha)
{
Detector detector = CreateDetector();
var detector = CreateDetector();
detector.SetAlpha(alpha);

@ -13,8 +13,8 @@ namespace NLangDetect.Core
public static LangProfile load(string lang, string file)
{
LangProfile profile = new LangProfile(lang);
TagExtractor tagextractor = new TagExtractor("abstract", 100);
var profile = new LangProfile(lang);
var tagextractor = new TagExtractor("abstract", 100);
Stream inputStream = null;
try
@ -28,7 +28,7 @@ namespace NLangDetect.Core
inputStream = new GZipStream(inputStream, CompressionMode.Decompress);
}
using (XmlReader xmlReader = XmlReader.Create(inputStream))
using (var xmlReader = XmlReader.Create(inputStream))
{
while (xmlReader.Read())
{

@ -25,7 +25,7 @@ namespace NLangDetect.Core
{
if (string.IsNullOrEmpty(plainText)) { throw new ArgumentException("Argument can't be null nor empty.", nameof(plainText)); }
Detector detector = DetectorFactory.Create(_DefaultAlpha);
var detector = DetectorFactory.Create(_DefaultAlpha);
detector.Append(plainText);

@ -59,8 +59,8 @@ namespace NLangDetect.Core.Utils
ICollection<string> keys = freq.Keys;
int roman = 0;
// TODO IMM HI: move up?
Regex regex1 = new Regex("^[A-Za-z]$", RegexOptions.Compiled);
List<string> keysToRemove = new List<string>();
var regex1 = new Regex("^[A-Za-z]$", RegexOptions.Compiled);
var keysToRemove = new List<string>();
foreach (string key in keys)
{
@ -93,7 +93,7 @@ namespace NLangDetect.Core.Utils
ICollection<string> keys2 = freq.Keys;
// TODO IMM HI: move up?
Regex regex2 = new Regex(".*[A-Za-z].*", RegexOptions.Compiled);
var regex2 = new Regex(".*[A-Za-z].*", RegexOptions.Compiled);
foreach (string key in keys2)
{

@ -30,7 +30,7 @@ namespace NLangDetect.Core.Utils
{
var manifestName = typeof(Messages).Assembly.GetManifestResourceNames().FirstOrDefault(i => i.IndexOf("messages.properties", StringComparison.Ordinal) != -1);
Stream messagesStream =
var messagesStream =
typeof(Messages).Assembly
.GetManifestResourceStream(manifestName);

@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.TextEncoding
public CharacterEncoding DetectEncoding(byte[] buffer, int size)
{
// First check if we have a BOM and return that if so
CharacterEncoding encoding = CheckBom(buffer, size);
var encoding = CheckBom(buffer, size);
if (encoding != CharacterEncoding.None)
{
return encoding;

@ -83,7 +83,7 @@ namespace UniversalDetector.Core
/// convert this encoding string to a number, here called order.
/// This allow multiple encoding of a language to share one frequency table
/// </summary>
/// <param name="buf">A <see cref="System.Byte"/></param>
/// <param name="buf">A <see cref="byte"/></param>
/// <param name="offset"></param>
/// <returns></returns>
public abstract int GetOrder(byte[] buf, int offset);
@ -91,7 +91,7 @@ namespace UniversalDetector.Core
/// <summary>
/// Feed a character with known length
/// </summary>
/// <param name="buf">A <see cref="System.Byte"/></param>
/// <param name="buf">A <see cref="byte"/></param>
/// <param name="offset">buf offset</param>
public void HandleOneChar(byte[] buf, int offset, int charLen)
{

@ -108,7 +108,7 @@ namespace UniversalDetector.Core
{
byte[] result = null;
using (MemoryStream ms = new MemoryStream(buf.Length))
using (var ms = new MemoryStream(buf.Length))
{
bool meetMSB = false;
@ -156,7 +156,7 @@ namespace UniversalDetector.Core
{
byte[] result = null;
using (MemoryStream ms = new MemoryStream(buf.Length))
using (var ms = new MemoryStream(buf.Length))
{
bool inTag = false;

@ -84,7 +84,7 @@ namespace UniversalDetector.Core
}
else if (j != activeSM)
{
CodingStateMachine t = codingSM[activeSM];
var t = codingSM[activeSM];
codingSM[activeSM] = codingSM[j];
codingSM[j] = t;
}

@ -122,7 +122,7 @@ namespace UniversalDetector.Core
}
}
ProbingState st = ProbingState.NotMe;
var st = ProbingState.NotMe;
for (int i = 0; i < probers.Length; i++)
{

@ -59,7 +59,7 @@ namespace UniversalDetector.Core
probers[7] = new SingleByteCharSetProber(new Win1253Model());
probers[8] = new SingleByteCharSetProber(new Latin5BulgarianModel());
probers[9] = new SingleByteCharSetProber(new Win1251BulgarianModel());
HebrewProber hebprober = new HebrewProber();
var hebprober = new HebrewProber();
probers[10] = hebprober;
// Logical
probers[11] = new SingleByteCharSetProber(new Win1255Model(), false, hebprober);
@ -75,7 +75,7 @@ namespace UniversalDetector.Core
public override ProbingState HandleData(byte[] buf, int offset, int len)
{
ProbingState st = ProbingState.NotMe;
var st = ProbingState.NotMe;
//apply filter to original buffer, and we got new buffer back
//depend on what script it is, we will feed them the new buffer

@ -168,7 +168,7 @@ namespace UniversalDetector.Core
}
}
ProbingState st = ProbingState.NotMe;
var st = ProbingState.NotMe;
switch (inputState)
{

@ -415,7 +415,7 @@ namespace Emby.Server.Implementations.Updates
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">package</exception>
/// <exception cref="ArgumentNullException">package</exception>
public async Task InstallPackage(PackageVersionInfo package, bool isPlugin, IProgress<double> progress, CancellationToken cancellationToken)
{
if (package == null)
@ -626,7 +626,7 @@ namespace Emby.Server.Implementations.Updates
/// Uninstalls a plugin
/// </summary>
/// <param name="plugin">The plugin.</param>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentException"></exception>
public void UninstallPlugin(IPlugin plugin)
{
plugin.OnUninstalling();

@ -34,7 +34,7 @@ namespace Emby.XmlTv.Classes
private static XmlReader CreateXmlTextReader(string path)
{
XmlReaderSettings settings = new XmlReaderSettings();
var settings = new XmlReaderSettings();
// https://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.xmlresolver(v=vs.110).aspx
// Looks like we don't need this anyway?

@ -36,8 +36,8 @@ namespace Jellyfin.Server
public static async Task<int> Main(string[] args)
{
StartupOptions options = new StartupOptions(args);
Version version = Assembly.GetEntryAssembly().GetName().Version;
var options = new StartupOptions(args);
var version = Assembly.GetEntryAssembly().GetName().Version;
if (options.ContainsOption("-v") || options.ContainsOption("--version"))
{
@ -45,7 +45,7 @@ namespace Jellyfin.Server
return 0;
}
ServerApplicationPaths appPaths = createApplicationPaths(options);
var appPaths = createApplicationPaths(options);
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath);
await createLogger(appPaths);
@ -57,7 +57,7 @@ namespace Jellyfin.Server
_logger.LogInformation("Jellyfin version: {Version}", version);
EnvironmentInfo environmentInfo = new EnvironmentInfo(getOperatingSystem());
var environmentInfo = new EnvironmentInfo(getOperatingSystem());
ApplicationHost.LogEnvironmentInfo(_logger, appPaths, environmentInfo);
SQLitePCL.Batteries_V2.Init();
@ -173,7 +173,7 @@ namespace Jellyfin.Server
if (!File.Exists(configPath))
{
// For some reason the csproj name is used instead of the assembly name
using (Stream rscstr = typeof(Program).Assembly
using (var rscstr = typeof(Program).Assembly
.GetManifestResourceStream("Jellyfin.Server.Resources.Configuration.logging.json"))
using (Stream fstr = File.Open(configPath, FileMode.CreateNew))
{

@ -75,7 +75,7 @@ namespace Jellyfin.SocketSharp
//
// We use a substream, as in 2.x we will support large uploads streamed to disk,
//
HttpPostedFile sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
var sub = new HttpPostedFile(e.Filename, e.ContentType, input, e.Start, e.Length);
files[e.Name] = sub;
}
}
@ -207,17 +207,17 @@ namespace Jellyfin.SocketSharp
async Task LoadWwwForm(WebROCollection form)
{
using (Stream input = InputStream)
using (var input = InputStream)
{
using (var ms = new MemoryStream())
{
await input.CopyToAsync(ms).ConfigureAwait(false);
ms.Position = 0;
using (StreamReader s = new StreamReader(ms, ContentEncoding))
using (var s = new StreamReader(ms, ContentEncoding))
{
StringBuilder key = new StringBuilder();
StringBuilder value = new StringBuilder();
var key = new StringBuilder();
var value = new StringBuilder();
int c;
while ((c = s.Read()) != -1)
@ -269,7 +269,7 @@ namespace Jellyfin.SocketSharp
{
public override string ToString()
{
StringBuilder result = new StringBuilder();
var result = new StringBuilder();
foreach (var pair in this)
{
if (result.Length > 0)
@ -715,7 +715,7 @@ namespace Jellyfin.SocketSharp
if (at_eof || ReadBoundary())
return null;
Element elem = new Element();
var elem = new Element();
string header;
while ((header = ReadHeaders()) != null)
{

@ -902,7 +902,7 @@ namespace MediaBrowser.Api.Library
var dtoOptions = GetDtoOptions(_authContext, request);
BaseItem parent = item.GetParent();
var parent = item.GetParent();
while (parent != null)
{

@ -751,7 +751,7 @@ namespace MediaBrowser.Api.Playback
MediaSourceInfo mediaSource = null;
if (string.IsNullOrWhiteSpace(request.LiveStreamId))
{
TranscodingJob currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ?
var currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ?
ApiEntryPoint.Instance.GetTranscodingJob(request.PlaySessionId)
: null;

@ -168,7 +168,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// </summary>
/// <param name="request">The request.</param>
/// <returns>IEnumerable{TaskInfo}.</returns>
/// <exception cref="MediaBrowser.Common.Extensions.ResourceNotFoundException">Task not found</exception>
/// <exception cref="ResourceNotFoundException">Task not found</exception>
public object Get(GetScheduledTask request)
{
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id));
@ -187,7 +187,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <exception cref="MediaBrowser.Common.Extensions.ResourceNotFoundException">Task not found</exception>
/// <exception cref="ResourceNotFoundException">Task not found</exception>
public void Post(StartScheduledTask request)
{
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id));
@ -214,7 +214,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <exception cref="MediaBrowser.Common.Extensions.ResourceNotFoundException">Task not found</exception>
/// <exception cref="ResourceNotFoundException">Task not found</exception>
public void Delete(StopScheduledTask request)
{
var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, request.Id));
@ -231,7 +231,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <exception cref="MediaBrowser.Common.Extensions.ResourceNotFoundException">Task not found</exception>
/// <exception cref="ResourceNotFoundException">Task not found</exception>
public void Post(UpdateScheduledTaskTriggers request)
{
// We need to parse this manually because we told service stack not to with IRequiresRequestStream

@ -95,7 +95,7 @@ namespace MediaBrowser.Api
var items = GetSimilaritems(item, libraryManager, inputItems, getSimilarityScore)
.ToList();
List<BaseItem> returnItems = items;
var returnItems = items;
if (request.Limit.HasValue)
{

@ -459,7 +459,7 @@ namespace MediaBrowser.Api.UserLibrary
if (string.IsNullOrEmpty(val))
{
return Array.Empty<ValueTuple<string, Model.Entities.SortOrder>>();
return Array.Empty<ValueTuple<string, SortOrder>>();
}
var vals = val.Split(',');
@ -470,7 +470,7 @@ namespace MediaBrowser.Api.UserLibrary
var sortOrders = requestedSortOrder.Split(',');
var result = new ValueTuple<string, Model.Entities.SortOrder>[vals.Length];
var result = new ValueTuple<string, SortOrder>[vals.Length];
for (var i = 0; i < vals.Length; i++)
{
@ -479,7 +479,7 @@ namespace MediaBrowser.Api.UserLibrary
var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending;
result[i] = new ValueTuple<string, Model.Entities.SortOrder>(vals[i], sortOrder);
result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
}
return result;

@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Net
/// <param name="options">The options.</param>
/// <returns>Task{System.String}.</returns>
/// <exception cref="System.ArgumentNullException">progress</exception>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
/// <exception cref="Model.Net.HttpException"></exception>
Task<string> GetTempFile(HttpRequestOptions options);
/// <summary>

@ -212,7 +212,7 @@ namespace MediaBrowser.Common.Plugins
/// Returns true or false indicating success or failure
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="System.ArgumentNullException">configuration</exception>
/// <exception cref="ArgumentNullException">configuration</exception>
public virtual void UpdateConfiguration(BasePluginConfiguration configuration)
{
if (configuration == null)

@ -69,7 +69,7 @@ namespace MediaBrowser.Common.Plugins
/// Returns true or false indicating success or failure
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <exception cref="System.ArgumentNullException">configuration</exception>
/// <exception cref="ArgumentNullException">configuration</exception>
void UpdateConfiguration(BasePluginConfiguration configuration);
/// <summary>

@ -108,14 +108,14 @@ namespace MediaBrowser.Common.Updates
/// <param name="progress">The progress.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">package</exception>
/// <exception cref="ArgumentNullException">package</exception>
Task InstallPackage(PackageVersionInfo package, bool isPlugin, IProgress<double> progress, CancellationToken cancellationToken);
/// <summary>
/// Uninstalls a plugin
/// </summary>
/// <param name="plugin">The plugin.</param>
/// <exception cref="System.ArgumentException"></exception>
/// <exception cref="ArgumentException"></exception>
void UninstallPlugin(IPlugin plugin);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save