mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-25 23:35:16 +02:00
.github
Application
Browser
Adapters
Bridge
Data
ContextInfo.cs
ResourceHandlers.cs
ResourceLink.cs
WindowState.cs
Handling
Notification
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
TrayIcon.Designer.cs
TrayIcon.cs
TweetDeckBrowser.cs
Configuration
Controls
Dialogs
Management
Plugins
Properties
Resources
Updates
Utils
bld
lib
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
packages.config
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using CefSharp;
|
|
|
|
namespace TweetDuck.Browser.Data{
|
|
sealed class ResourceHandlers{
|
|
private readonly ConcurrentDictionary<string, IResourceHandler> handlers = new ConcurrentDictionary<string, IResourceHandler>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
public bool HasHandler(IRequest request){
|
|
return handlers.ContainsKey(request.Url);
|
|
}
|
|
|
|
public IResourceHandler GetHandler(IRequest request){
|
|
return handlers.TryGetValue(request.Url, out var handler) ? handler : null;
|
|
}
|
|
|
|
public bool Register(string url, IResourceHandler handler){
|
|
if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)){
|
|
handlers.AddOrUpdate(uri.AbsoluteUri, handler, (key, prev) => handler);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool Register(ResourceLink link){
|
|
return Register(link.Url, link.Handler);
|
|
}
|
|
|
|
public bool Unregister(string url){
|
|
return handlers.TryRemove(url, out IResourceHandler _);
|
|
}
|
|
|
|
public bool Unregister(ResourceLink link){
|
|
return Unregister(link.Url);
|
|
}
|
|
}
|
|
}
|