mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-05 15:28:28 +01:00
make model project portable
This commit is contained in:
@@ -91,7 +91,6 @@
|
||||
<Compile Include="Security\IRequiresRegistration.cs" />
|
||||
<Compile Include="Security\ISecurityManager.cs" />
|
||||
<Compile Include="Security\PaymentRequiredException.cs" />
|
||||
<Compile Include="Threading\PeriodicTimer.cs" />
|
||||
<Compile Include="Updates\IInstallationManager.cs" />
|
||||
<Compile Include="Updates\InstallationEventArgs.cs" />
|
||||
<Compile Include="Updates\InstallationFailedEventArgs.cs" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
@@ -50,16 +50,18 @@ namespace MediaBrowser.Common.Net
|
||||
/// Gets or sets the headers.
|
||||
/// </summary>
|
||||
/// <value>The headers.</value>
|
||||
public NameValueCollection Headers { get; set; }
|
||||
public Dictionary<string,string> Headers { get; set; }
|
||||
|
||||
private readonly IDisposable _disposable;
|
||||
|
||||
public HttpResponseInfo(IDisposable disposable)
|
||||
{
|
||||
_disposable = disposable;
|
||||
Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
public HttpResponseInfo()
|
||||
{
|
||||
Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -7,12 +7,6 @@ namespace MediaBrowser.Common.Net
|
||||
{
|
||||
public interface INetworkManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the machine's local ip address
|
||||
/// </summary>
|
||||
/// <returns>IPAddress.</returns>
|
||||
IEnumerable<IPAddress> GetLocalIpAddresses();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a random port number that is currently available
|
||||
/// </summary>
|
||||
@@ -45,13 +39,6 @@ namespace MediaBrowser.Common.Net
|
||||
/// <returns>PC's in the Domain</returns>
|
||||
IEnumerable<FileSystemEntryInfo> GetNetworkDevices();
|
||||
|
||||
/// <summary>
|
||||
/// Parses the specified endpointstring.
|
||||
/// </summary>
|
||||
/// <param name="endpointstring">The endpointstring.</param>
|
||||
/// <returns>IPEndPoint.</returns>
|
||||
IPEndPoint Parse(string endpointstring);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is in local network] [the specified endpoint].
|
||||
/// </summary>
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace MediaBrowser.Common.Threading
|
||||
{
|
||||
public class PeriodicTimer : IDisposable
|
||||
{
|
||||
public Action<object> Callback { get; set; }
|
||||
private Timer _timer;
|
||||
private readonly object _state;
|
||||
private readonly object _timerLock = new object();
|
||||
private readonly TimeSpan _period;
|
||||
|
||||
public PeriodicTimer(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
if (callback == null)
|
||||
{
|
||||
throw new ArgumentNullException("callback");
|
||||
}
|
||||
|
||||
Callback = callback;
|
||||
_period = period;
|
||||
_state = state;
|
||||
|
||||
StartTimer(dueTime);
|
||||
}
|
||||
|
||||
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
if (e.Mode == PowerModes.Resume)
|
||||
{
|
||||
DisposeTimer();
|
||||
StartTimer(Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
}
|
||||
|
||||
private void TimerCallback(object state)
|
||||
{
|
||||
Callback(state);
|
||||
}
|
||||
|
||||
private void StartTimer(TimeSpan dueTime)
|
||||
{
|
||||
lock (_timerLock)
|
||||
{
|
||||
_timer = new Timer(TimerCallback, _state, dueTime, _period);
|
||||
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeTimer()
|
||||
{
|
||||
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
|
||||
|
||||
lock (_timerLock)
|
||||
{
|
||||
if (_timer != null)
|
||||
{
|
||||
_timer.Dispose();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisposeTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user