public UriSchemeInfo GetSystemUriScheme(string name, Dictionary <string, string> options) { if (!name.All(c => char.IsLetterOrDigit(c) || c == '+' || c == '-' || c == '.')) { Logger.GetInstance(typeof(UriSchemeManager)).Error("Do not find valid scheme name: \"" + name + "\""); return(new UriSchemeInfo { Name = name }); } var opts = options ?? new Dictionary <string, string>(); UriSchemeInfo result = null; try { result = OnGetSystemUriScheme(name, opts); } catch (Exception e) { Logger.GetInstance(typeof(UriSchemeManager)).Error("Can not get system uri scheme: " + e.Message); } return(result ?? new UriSchemeInfo { Name = name }); }
/// <inheritdoc /> protected override GetUriSchemeResult OnGetSystemUriScheme( string schemeName, Dictionary <string, string> options) { if (!Platform.IsWindows) { return(new GetUriSchemeResult { Status = GetUriSchemeStatus.UnsupportedPlatform }); } var shouldAcceptWhitelistOnly = false; if (options.ContainsKey(OptionAcceptWhitelistOnly)) { shouldAcceptWhitelistOnly = Core.Util.Convert.ToBool(options[OptionAcceptWhitelistOnly]); } var uriSchemeInfo = new UriSchemeInfo { Name = schemeName }; var realSchemeName = GetRealSchemeNameFromHkcu(schemeName); if (string.IsNullOrWhiteSpace(realSchemeName)) { realSchemeName = schemeName; } using (var baseKey = Win32Registry.Key.OpenBaseKey( Win32Registry.Hive.ClassesRoot, Win32Registry.View.Default)) { var commandPair = GetCommandPair( baseKey, schemeName, realSchemeName, shouldAcceptWhitelistOnly ); if (string.IsNullOrWhiteSpace(commandPair.Key)) { return(new GetUriSchemeResult { Status = GetUriSchemeStatus.NotAvailable }); } uriSchemeInfo.CommandPath = commandPair.Key; uriSchemeInfo.CommandParameter = commandPair.Value; uriSchemeInfo.DefaultIcon = GetDefaultIconPath(baseKey, realSchemeName); } return(new GetUriSchemeResult { Status = GetUriSchemeStatus.Ok, UriScheme = uriSchemeInfo }); }
public bool IsSystemUriSchemeValid(UriSchemeInfo uriSchemeInfo) { if (uriSchemeInfo == null) { return(false); } return(!string.IsNullOrWhiteSpace(uriSchemeInfo.Name) && !string.IsNullOrWhiteSpace(uriSchemeInfo.CommandPath) && !string.IsNullOrWhiteSpace(uriSchemeInfo.DefaultIcon)); }
protected override UriSchemeInfo OnGetSystemUriScheme(string schemeName, Dictionary <string, string> options) { var shouldAcceptWhitelistOnly = false; if (options.ContainsKey(OptionAcceptWhitelistOnly)) { shouldAcceptWhitelistOnly = Util.Convert.ToBool(options[OptionAcceptWhitelistOnly]); } var uriSchemeInfo = new UriSchemeInfo { Name = schemeName }; var realSchemeName = GetRealSchemeNameFromHkcu(schemeName); if (string.IsNullOrWhiteSpace(realSchemeName)) { realSchemeName = schemeName; } using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Default)) { var commandPair = GetCommandPair( baseKey, schemeName, realSchemeName, shouldAcceptWhitelistOnly ); if (string.IsNullOrWhiteSpace(commandPair.Key)) { return(uriSchemeInfo); } uriSchemeInfo.CommandPath = commandPair.Key; uriSchemeInfo.CommandParameter = commandPair.Value; uriSchemeInfo.DefaultIcon = GetDefaultIconPath(baseKey, realSchemeName); } return(uriSchemeInfo); }