/////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            IComponentModel               componentModel               = (IComponentModel)this.GetService(typeof(SComponentModel));
            IContentTypeRegistryService   contentTypeRegistryService   = componentModel.GetService <IContentTypeRegistryService>();
            IFileExtensionRegistryService fileExtensionRegistryService = componentModel.GetService <IFileExtensionRegistryService>();

            IContentType perlContentType = contentTypeRegistryService.GetContentType(Perl.Constants.ContentType);

            if (perlContentType != null)
            {
                IList <string> exts = fileExtensionRegistryService.GetExtensionsForContentType(perlContentType).ToList();
                foreach (string ext in exts)
                {
                    fileExtensionRegistryService.RemoveFileExtension(ext);
                }

                contentTypeRegistryService.RemoveContentType(Perl.Constants.ContentType);
            }

            perlContentType = contentTypeRegistryService.AddContentType(Perl.Constants.ContentType, new List <string> {
                "code"
            });
            fileExtensionRegistryService.AddFileExtension(".pm", perlContentType);
        }
 private void ChangeExtensions(IContentType contentType, IEnumerable <string> extensions)
 {
     foreach (var ext in extensions)
     {
         _fileExtensionRegistryService.AddFileExtension(ext, contentType);
     }
 }
Esempio n. 3
0
 public static void RegisterExtensions(
     IContentTypeRegistryService/*!*/ contentTypeRegistryService,
     IFileExtensionRegistryService/*!*/ fileExtensionRegistryService,
     IContentType/*!*/ contentType,
     IEnumerable<string>/*!*/ fileExtensions
     )
 {
     foreach (var extension in fileExtensions) {
         if (fileExtensionRegistryService.GetContentTypeForExtension(extension) == contentTypeRegistryService.UnknownContentType) {
             fileExtensionRegistryService.AddFileExtension(extension, contentType);
         }
     }
 }
Esempio n. 4
0
 public static void RegisterExtensions(
     IContentTypeRegistryService /*!*/ contentTypeRegistryService,
     IFileExtensionRegistryService /*!*/ fileExtensionRegistryService,
     IContentType /*!*/ contentType,
     IEnumerable <string> /*!*/ fileExtensions
     )
 {
     foreach (var extension in fileExtensions)
     {
         if (fileExtensionRegistryService.GetContentTypeForExtension(extension) == contentTypeRegistryService.UnknownContentType)
         {
             fileExtensionRegistryService.AddFileExtension(extension, contentType);
         }
     }
 }
Esempio n. 5
0
        private static void RegisterFileExtensions(IFileExtensionRegistryService fileExtensionRegistry, string sExtensions, IContentType contentType)
        {
            var extensions = sExtensions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var ext in extensions)
            {
                try
                {
                    fileExtensionRegistry.AddFileExtension(ext, contentType);
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show($"Extension {ext} is ignored because it is already registered " +
                                    $"with a different Visual Studio component. " +
                                    $"Please remove it from the GLSL language integration options page!", "GLSL language integration");
                }
            }
        }
Esempio n. 6
0
        private static void RegisterFileExtensions(IFileExtensionRegistryService fileExtensionRegistry, string sExtensions, IContentType contentType)
        {
            var extensions = sExtensions.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var ext in extensions)
            {
                try
                {
                    fileExtensionRegistry.AddFileExtension(ext, contentType);
                }
                catch (InvalidOperationException)
                {
                    var titel   = "GLSL language integration";
                    var message = $"{titel}:Extension {ext} is ignored because it is already registered " +
                                  $"with a different Visual Studio component. " +
                                  $"Please remove it from the {titel} options page!";
                    VsStatusBar.SetText(message);
                }
            }
        }
Esempio n. 7
0
        private static void RegisterFileExtensions(IFileExtensionRegistryService fileExtensionRegistry, string sExtensions, IContentType contentType, ILogger logger)
        {
            var extensions = sExtensions.Split(new char[] { ';', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var ext in extensions)
            {
                try
                {
                    //fileExtensionRegistry.RemoveFileExtension(ext);
                    fileExtensionRegistry.AddFileExtension(ext, contentType);
                }
                catch (InvalidOperationException ioe)
                {
                    var          otherContentType = fileExtensionRegistry.GetContentTypeForExtension(ext);
                    const string title            = "GLSL language integration";
                    var          message          = $"{title}:Extension '{ext}' is ignored because it is already registered " +
                                                    $"with the content type '{otherContentType.TypeName}'. " +
                                                    $"Please use a different extension on the {title} options page!" +
                                                    $"Following is the detailed exception message {ioe}";
                    logger.Log(message, true);
                }
            }
        }