Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
 public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey)
 {
     using (var key = packageKey.CreateSubKey("CommandLine\\" + Name))
     {
         key.SetValue("ExpectArgument", ExpectArgument ? 1 : 0);
     }
 }
 public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey)
 {
     using (var key = packageKey.CreateSubKey("CommandLine\\" + Name))
     {
         key.SetValue("ExpectArgument", ExpectArgument ? 1 : 0);
     }
 }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 6
0
 public override void Register(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey)
 {
     using (var key = packageKey.CreateSubKey("ApplicationIcon"))
     {
         key.SetValue(null, FileName);
     }
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public PackageRegistration GetRegistration(INiPackage package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            return(_byPackage[package]);
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        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));
        }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
        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();
        }
Ejemplo n.º 19
0
        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;
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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);
            }
        }
Ejemplo n.º 22
0
        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);
                }
            }
        }
Ejemplo n.º 25
0
        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();
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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);
                }
            }
        }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
        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;
            }
        }
Ejemplo n.º 30
0
        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);
            }
        }
Ejemplo n.º 32
0
 public Settings(INiPackage package)
     : base(package)
 {
 }
Ejemplo n.º 33
0
        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;
        }
Ejemplo n.º 34
0
 public abstract void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey);
Ejemplo n.º 35
0
 public override void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey)
 {
 }
Ejemplo n.º 36
0
        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();
        }
Ejemplo n.º 37
0
        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;
            }
        }
 public override void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey)
 {
 }
Ejemplo n.º 39
0
 public Settings(INiPackage package)
     : base(package)
 {
 }
Ejemplo n.º 40
0
        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));
        }
Ejemplo n.º 41
0
 public abstract void Unregister(INiPackage package, INiRegistrationContext context, INiRegistrationKey packageKey);