20 changed files with 142 additions and 152 deletions
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
public class UnitTestAddInTree : IAddInTree |
||||
{ |
||||
public List<T> BuildItems<T>(string path, object caller) |
||||
{ |
||||
return AddInTree.BuildItems<T>(path, caller); |
||||
} |
||||
} |
||||
} |
||||
@ -1,13 +0,0 @@
@@ -1,13 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
public interface IAddInTree |
||||
{ |
||||
List<T> BuildItems<T>(string path, object caller); |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
sealed class AddInTreeImpl : IAddInTree |
||||
{ |
||||
IReadOnlyList<AddIn> IAddInTree.AddIns { |
||||
get { return AddInTree.AddIns; } |
||||
} |
||||
|
||||
IReadOnlyList<T> IAddInTree.BuildItems<T>(string path, object caller, bool throwOnNotFound) |
||||
{ |
||||
return AddInTree.BuildItems<T>(path, caller, throwOnNotFound); |
||||
} |
||||
|
||||
object IAddInTree.BuildItem(string path, object caller) |
||||
{ |
||||
return AddInTree.BuildItem(path, caller); |
||||
} |
||||
|
||||
AddInTreeNode IAddInTree.GetTreeNode(string path, bool throwOnNotFound) |
||||
{ |
||||
return AddInTree.GetTreeNode(path, throwOnNotFound); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
[FallbackService(typeof(AddInTreeImpl))] |
||||
public interface IAddInTree |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the AddIns that are registered for this AddIn tree.
|
||||
/// </summary>
|
||||
IReadOnlyList<AddIn> AddIns { get; } |
||||
|
||||
/// <summary>
|
||||
/// Builds the items in the path. Ensures that all items have the type T.
|
||||
/// </summary>
|
||||
/// <param name="path">A path in the addin tree.</param>
|
||||
/// <param name="caller">The owner used to create the objects.</param>
|
||||
/// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/>
|
||||
/// if the path is not found. If false, an empty ArrayList is returned when the
|
||||
/// path is not found.</param>
|
||||
IReadOnlyList<T> BuildItems<T>(string path, object caller, bool throwOnNotFound = true); |
||||
|
||||
/// <summary>
|
||||
/// Builds a single item in the addin tree.
|
||||
/// </summary>
|
||||
/// <param name="path">A path to the item in the addin tree.</param>
|
||||
/// <param name="caller">The owner used to create the objects.</param>
|
||||
/// <exception cref="TreePathNotFoundException">The path does not
|
||||
/// exist or does not point to an item.</exception>
|
||||
object BuildItem(string path, object caller); |
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="AddInTreeNode"/> representing the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the AddIn tree node</param>
|
||||
/// <param name="throwOnNotFound">
|
||||
/// If set to <c>true</c>, this method throws a
|
||||
/// <see cref="TreePathNotFoundException"/> when the path does not exist.
|
||||
/// If set to <c>false</c>, <c>null</c> is returned for non-existing paths.
|
||||
/// </param>
|
||||
AddInTreeNode GetTreeNode(string path, bool throwOnNotFound = true); |
||||
} |
||||
} |
||||
@ -1,58 +0,0 @@
@@ -1,58 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Globalization; |
||||
using Microsoft.Win32; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
/// <summary>
|
||||
/// RegistryService.
|
||||
/// </summary>
|
||||
public static class RegistryService |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the registry value.
|
||||
/// </summary>
|
||||
/// <param name="hive">Registry hive.</param>
|
||||
/// <param name="key">Registry key.</param>
|
||||
/// <param name="value">Registry value.</param>
|
||||
/// <param name="kind">Registry kind.</param>
|
||||
/// <param name="data">Data.</param>
|
||||
/// <returns>True, if the data was found, False otherwise.</returns>
|
||||
public static bool GetRegistryValue<T>(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data) |
||||
{ |
||||
data = default(T); |
||||
|
||||
try { |
||||
using (RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(hive, String.Empty)) |
||||
{ |
||||
if (baseKey != null) |
||||
{ |
||||
using (RegistryKey registryKey = baseKey.OpenSubKey(key, RegistryKeyPermissionCheck.ReadSubTree)) |
||||
{ |
||||
if (registryKey != null) |
||||
{ |
||||
RegistryValueKind kindFound = registryKey.GetValueKind(value); |
||||
if (kindFound == kind) |
||||
{ |
||||
object regValue = registryKey.GetValue(value, null); |
||||
if (regValue != null) |
||||
{ |
||||
data = (T)Convert.ChangeType(regValue, typeof(T), CultureInfo.InvariantCulture); |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} catch { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue