public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string keyName; if (ProjectGuid.HasValue) { keyName = "Projects\\" + ProjectGuid.Value.ToString("B").ToUpperInvariant() + "\\Extensions\\" + Extension; } else { keyName = "Extensions\\" + Extension; } using (var key = packageKey.CreateSubKey(keyName)) { if (DefaultName != null) { key.SetValue(null, ResolveStringResource(package, DefaultName)); key.SetValue("DefaultName", DefaultName); } key.SetValue("FactoryType", FactoryType.GUID.ToString("B").ToUpperInvariant()); key.SetValue("Priority", Priority); if (TemplateResource != null) { key.SetValue("TemplateResource", TemplateResource); } } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { using (var key = packageKey.CreateSubKey("CommandLine\\" + Name)) { key.SetValue("ExpectArgument", ExpectArgument ? 1 : 0); } }
public HResult GetInstallationPath(INiPackage package, out string path) { path = null; try { if (package == null) { throw new ArgumentNullException("package"); } PackageRegistration registration; if (!_byPackage.TryGetValue(package, out registration)) { return(HResult.False); } path = Path.Combine( _env.FileSystemRoot, "Packages", registration.PackageId ); return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { using (var key = packageKey.CreateSubKey("ApplicationIcon")) { key.SetValue(null, FileName); } }
protected string ResolveStringResource(INiPackage package, string key) { if (package == null) throw new ArgumentNullException("package"); if (key == null) throw new ArgumentNullException("key"); return package.ResolveStringResource(key); }
public PackageRegistration GetRegistration(INiPackage package) { if (package == null) { throw new ArgumentNullException("package"); } return(_byPackage[package]); }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string guid = Type.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("CLSID\\" + guid)) { key.SetValue("Class", Type.AssemblyQualifiedName); } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string factoryGuid = FactoryType.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("Editors\\" + factoryGuid)) { key.SetValue(null, ResolveStringResource(package, Name)); key.SetValue("DisplayName", Name); } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string toolWindowGuid = ToolType.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("ToolWindows\\" + toolWindowGuid)) { key.SetValue("Style", Style.ToString()); key.SetValue("Orientation", Orientation.ToString()); key.SetValue("MultipleInstances", MultipleInstances ? 1 : 0); key.SetValue("Transient", Transient ? 1 : 0); } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string factoryGuid = FactoryType.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("Projects\\" + factoryGuid)) { key.SetValue(null, ResolveStringResource(package, Name)); key.SetValue("DisplayName", Name); key.SetValue("ProjectFileExtensions", ProjectFileExtensions); key.SetValue("DefaultProjectExtension", DefaultProjectExtension); key.SetValue("PossibleProjectExtensions", PossibleProjectExtensions); } }
protected string ResolveStringResource(INiPackage package, string key) { if (package == null) { throw new ArgumentNullException("package"); } if (key == null) { throw new ArgumentNullException("key"); } return(package.ResolveStringResource(key)); }
public NiSettings(INiPackage package) { if (package == null) throw new ArgumentNullException("package"); _package = package; var env = (INiEnv)package.GetService(typeof(INiEnv)); _registryKey = env.RegistryRoot + "\\Configuration\\Packages\\" + package.GetType().GUID.ToString("B").ToUpperInvariant(); }
public MenuBuilder(INiPackage package, string niMenu, Dictionary<string, object> resources) { if (package == null) throw new ArgumentNullException("package"); if (niMenu == null) throw new ArgumentNullException("niMenu"); if (resources == null) throw new ArgumentNullException("resources"); _commandManager = (NiCommandManager)package.GetService(typeof(INiCommandManager)); _menuManager = (INiMenuManager)package.GetService(typeof(INiMenuManager)); _package = package; _niMenu = niMenu; _resources = resources; }
public static string ResolveStringResource(this INiPackage self, string key) { if (String.IsNullOrEmpty(key)) { return(key); } if (key.StartsWith("@")) { string value; ErrorUtil.ThrowOnFailure(self.GetStringResource(key.Substring(1), out value)); return(value); } return(key); }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string optionPageGuid = PageType.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("OptionPages\\" + optionPageGuid)) { key.SetValue("Class", PageType.AssemblyQualifiedName); key.SetValue("CategoryName", CategoryName); key.SetValue("PageName", PageName); if (CategoryNameResourceKey != null) key.SetValue("CategoryNameResourceKey", CategoryNameResourceKey); if (PageNameResourceKey != null) key.SetValue("PageNameResourceKey", PageNameResourceKey); } }
public NiSettings(INiPackage package) { if (package == null) { throw new ArgumentNullException("package"); } _package = package; var env = (INiEnv)package.GetService(typeof(INiEnv)); _registryKey = env.RegistryRoot + "\\Configuration\\Packages\\" + package.GetType().GUID.ToString("B").ToUpperInvariant(); }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { foreach (var entry in HighlightingManager.Manager.HighlightingDefinitions.Values.OfType <DictionaryEntry>()) { var syntaxMode = (SyntaxMode)entry.Key; foreach (string extension in syntaxMode.Extensions) { var attribute = new ProvideEditorExtensionAttribute(typeof(TextEditorFactory), extension, 100) { DefaultName = syntaxMode.Name }; attribute.Register(package, context, packageKey); } } }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { foreach (var entry in HighlightingManager.Manager.HighlightingDefinitions.Values.OfType<DictionaryEntry>()) { var syntaxMode = (SyntaxMode)entry.Key; foreach (string extension in syntaxMode.Extensions) { var attribute = new ProvideEditorExtensionAttribute(typeof(TextEditorFactory), extension, 100) { DefaultName = syntaxMode.Name }; attribute.Register(package, context, packageKey); } } }
public void LoadFromResources(INiPackage package, IResource resource) { if (resource == null) { throw new ArgumentNullException("resource"); } string niMenu = null; var resources = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); using (var stream = new MemoryStream()) { // We copy the stream into a memory stream to limit the number // of MBRO calls made. using (var source = StreamUtil.ToStream(resource)) { source.CopyTo(stream); } stream.Position = 0; using (var reader = new ResourceReader(stream)) { foreach (DictionaryEntry entry in reader) { if (String.Equals((string)entry.Key, "NiMenu", StringComparison.OrdinalIgnoreCase)) { niMenu = (string)entry.Value; } else { resources.Add((string)entry.Key, entry.Value); } } } } if (niMenu == null) { throw new NetIdeException(Labels.NiMenuMissing); } new MenuBuilder(package, niMenu, resources).Build(); }
private bool PerformUnregistration(string fileSystemRoot, INiPackage package) { // Unregister when this package is already installed. using (var contextKey = OpenContextRegistry(false)) using (var key = contextKey.OpenSubKey("InstalledProducts\\" + _packageId)) { if (key == null) { return(false); } } var registrationContext = new NiRegistrationContext(Context, _packageId, fileSystemRoot); Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); return(true); }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string optionPageGuid = PageType.GUID.ToString("B").ToUpperInvariant(); using (var key = packageKey.CreateSubKey("OptionPages\\" + optionPageGuid)) { key.SetValue("Class", PageType.AssemblyQualifiedName); key.SetValue("CategoryName", CategoryName); key.SetValue("PageName", PageName); if (CategoryNameResourceKey != null) { key.SetValue("CategoryNameResourceKey", CategoryNameResourceKey); } if (PageNameResourceKey != null) { key.SetValue("PageNameResourceKey", PageNameResourceKey); } } }
public MenuBuilder(INiPackage package, string niMenu, Dictionary <string, object> resources) { if (package == null) { throw new ArgumentNullException("package"); } if (niMenu == null) { throw new ArgumentNullException("niMenu"); } if (resources == null) { throw new ArgumentNullException("resources"); } _commandManager = (NiCommandManager)package.GetService(typeof(INiCommandManager)); _menuManager = (INiMenuManager)package.GetService(typeof(INiMenuManager)); _package = package; _niMenu = niMenu; _resources = resources; }
protected IDisposable CreateAppDomain(string packagePath, string entryPoint, out INiPackage package) { string entryAssembly; string entryTypeName; if (!TryParseEntryPoint(entryPoint, out entryAssembly, out entryTypeName)) { throw new PackageInstallationException(Labels.InvalidManifest, 3); } var setup = new AppDomainSetup { ApplicationBase = packagePath, ApplicationName = "Net IDE package manager" }; var appDomain = AppDomain.CreateDomain( setup.ApplicationName, AppDomain.CurrentDomain.Evidence, setup ); try { package = (INiPackage)appDomain.CreateInstanceAndUnwrap( entryAssembly, entryTypeName ); return(new AppDomainUnloader(appDomain)); } catch { AppDomain.Unload(appDomain); throw; } }
private void PerformRegistration(string packageId, string fileSystemRoot, INiPackage package) { var registrationContext = new NiRegistrationContext(Context, packageId, fileSystemRoot); // Unregister when this package is already installed. bool isInstalled; using (var rootKey = OpenContextRegistry(false)) using (var packageKey = rootKey.OpenSubKey("InstalledProducts\\" + packageId)) { isInstalled = packageKey != null; } if (isInstalled) { Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); } // Perform the registration process. Marshal.ThrowExceptionForHR((int)package.Register(registrationContext)); }
public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { string keyName; if (ProjectGuid.HasValue) keyName = "Projects\\" + ProjectGuid.Value.ToString("B").ToUpperInvariant() + "\\Extensions\\" + Extension; else keyName = "Extensions\\" + Extension; using (var key = packageKey.CreateSubKey(keyName)) { if (DefaultName != null) { key.SetValue(null, ResolveStringResource(package, DefaultName)); key.SetValue("DefaultName", DefaultName); } key.SetValue("FactoryType", FactoryType.GUID.ToString("B").ToUpperInvariant()); key.SetValue("Priority", Priority); if (TemplateResource != null) key.SetValue("TemplateResource", TemplateResource); } }
public Settings(INiPackage package) : base(package) { }
private bool PerformUnregistration(string fileSystemRoot, INiPackage package) { // Unregister when this package is already installed. using (var contextKey = OpenContextRegistry(false)) using (var key = contextKey.OpenSubKey("InstalledProducts\\" + _packageId)) { if (key == null) return false; } var registrationContext = new NiRegistrationContext(Context, _packageId, fileSystemRoot); Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); return true; }
public abstract void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey);
public override void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey) { }
public void LoadFromResources(INiPackage package, IResource resource) { if (resource == null) throw new ArgumentNullException("resource"); string niMenu = null; var resources = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); using (var stream = new MemoryStream()) { // We copy the stream into a memory stream to limit the number // of MBRO calls made. using (var source = StreamUtil.ToStream(resource)) { source.CopyTo(stream); } stream.Position = 0; using (var reader = new ResourceReader(stream)) { foreach (DictionaryEntry entry in reader) { if (String.Equals((string)entry.Key, "NiMenu", StringComparison.OrdinalIgnoreCase)) niMenu = (string)entry.Value; else resources.Add((string)entry.Key, entry.Value); } } } if (niMenu == null) throw new NetIdeException(Labels.NiMenuMissing); new MenuBuilder(package, niMenu, resources).Build(); }
protected IDisposable CreateAppDomain(string packagePath, string entryPoint, out INiPackage package) { string entryAssembly; string entryTypeName; if (!TryParseEntryPoint(entryPoint, out entryAssembly, out entryTypeName)) throw new PackageInstallationException(Labels.InvalidManifest, 3); var setup = new AppDomainSetup { ApplicationBase = packagePath, ApplicationName = "Net IDE package manager" }; var appDomain = AppDomain.CreateDomain( setup.ApplicationName, AppDomain.CurrentDomain.Evidence, setup ); try { package = (INiPackage)appDomain.CreateInstanceAndUnwrap( entryAssembly, entryTypeName ); return new AppDomainUnloader(appDomain); } catch { AppDomain.Unload(appDomain); throw; } }
private void PerformRegistration(string packageId, string fileSystemRoot, INiPackage package) { var registrationContext = new NiRegistrationContext(Context, packageId, fileSystemRoot); // Unregister when this package is already installed. bool isInstalled; using (var rootKey = OpenContextRegistry(false)) using (var packageKey = rootKey.OpenSubKey("InstalledProducts\\" + packageId)) { isInstalled = packageKey != null; } if (isInstalled) Marshal.ThrowExceptionForHR((int)package.Unregister(registrationContext)); // Perform the registration process. Marshal.ThrowExceptionForHR((int)package.Register(registrationContext)); }