From d8263c70574c6cb27329e270aebe3ba231f5e9ce Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 10 Apr 2013 11:45:15 -0400 Subject: resharper suggestions in common implementations --- .../NetworkManagement/NetworkManager.cs | 6 +---- .../NetworkManagement/NetworkShares.cs | 31 ++++++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'MediaBrowser.Common.Implementations/NetworkManagement') diff --git a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs index d88b57be56..3c42d340b8 100644 --- a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs +++ b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs @@ -308,11 +308,7 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement //check if we have an IPv6 or ports if (values.Length <= 2) // ipv4 or hostname { - if (values.Length == 1) - //no port is specified, default - port = defaultport; - else - port = GetPort(values[1]); + port = values.Length == 1 ? defaultport : GetPort(values[1]); //try to use the address as IPv4, otherwise get hostname if (!IPAddress.TryParse(values[0], out ipaddy)) diff --git a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkShares.cs b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkShares.cs index e2a8275cff..d06c6b2e22 100644 --- a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkShares.cs +++ b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkShares.cs @@ -45,8 +45,11 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement /// /// Constructor /// - /// - /// + /// The server. + /// Name of the net. + /// The path. + /// Type of the share. + /// The remark. public Share(string server, string netName, string path, ShareType shareType, string remark) { if (ShareType.Special == shareType && "IPC$" == netName) @@ -423,9 +426,9 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement int nRet = 0; ushort entriesRead, totalEntries; - Type t = typeof(SHARE_INFO_50); - int size = Marshal.SizeOf(t); - ushort cbBuffer = (ushort)(MAX_SI50_ENTRIES * size); + var t = typeof(SHARE_INFO_50); + var size = Marshal.SizeOf(t); + var cbBuffer = (ushort)(MAX_SI50_ENTRIES * size); //On Win9x, must allocate buffer before calling API IntPtr pBuffer = Marshal.AllocHGlobal(cbBuffer); @@ -448,16 +451,16 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement { for (int i = 0, lpItem = pBuffer.ToInt32(); i < entriesRead; i++, lpItem += size) { - IntPtr pItem = new IntPtr(lpItem); + var pItem = new IntPtr(lpItem); if (1 == level) { - SHARE_INFO_1_9x si = (SHARE_INFO_1_9x)Marshal.PtrToStructure(pItem, t); + var si = (SHARE_INFO_1_9x)Marshal.PtrToStructure(pItem, t); shares.Add(si.NetName, string.Empty, si.ShareType, si.Remark); } else { - SHARE_INFO_50 si = (SHARE_INFO_50)Marshal.PtrToStructure(pItem, t); + var si = (SHARE_INFO_50)Marshal.PtrToStructure(pItem, t); shares.Add(si.NetName, si.Path, si.ShareType, si.Remark); } } @@ -542,7 +545,7 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement /// /// Constructor /// - /// + /// The server. public ShareCollection(string server) { _server = server; @@ -598,9 +601,9 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement Share match = null; - for (int i = 0; i < InnerList.Count; i++) + foreach (object t in InnerList) { - Share s = (Share)InnerList[i]; + var s = (Share)t; if (s.IsFileSystem && s.MatchesPath(path)) { @@ -608,9 +611,9 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement if (null == match) match = s; - // If this has a longer path, - // and this is a disk share or match is a special share, - // then this is a better match + // If this has a longer path, + // and this is a disk share or match is a special share, + // then this is a better match else if (match.Path.Length < s.Path.Length) { if (ShareType.Disk == s.ShareType || ShareType.Disk != match.ShareType) -- cgit v1.2.3