Exemplo n.º 1
0
        private void InternalConfig(ViewerConfiguration viewerConfig)
        {
            if (viewerConfig == null)
            {
                return;
            }

            foreach (KeyValueConfigurationElement keyValue in viewerConfig.Plugins)
            {
                string type       = keyValue.Value;
                Type   pluginType = Type.GetType(type, false);
                if (pluginType != null && typeof(IJsonViewerPlugin).IsAssignableFrom(pluginType))
                {
                    continue;
                }
                try
                {
                    IJsonViewerPlugin plugin = (IJsonViewerPlugin)Activator.CreateInstance(pluginType);
                    AddPlugin(plugin);
                }
                catch
                {
                    //Silently ignore any errors in plugin creation
                }
            }
        }
Exemplo n.º 2
0
        private void InitControl(TextEditorControlEx ctrol, Configuration config)
        {
            ViewerConfiguration viewerConfig = (ViewerConfiguration)config.GetSection("jsonViewer");

            foreach (KeyValueConfigurationElement item in viewerConfig.TextEditor)
            {
                switch (item.Key)
                {
                case "SyntaxHighlighting":
                    ctrol.SyntaxHighlighting = item.Value;
                    break;

                case "ShowInvalidLines":
                    ctrol.ShowInvalidLines = bool.TryParse(item.Value, out bool lines) ? lines : true;
                    break;

                case "ShowHRuler":
                    ctrol.ShowHRuler = bool.TryParse(item.Value, out bool ruler) ? ruler : true;
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 3
0
 public void Initialize()
 {
     try
     {
         Configuration config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
         if (config == null)
         {
             InitDefaults();
         }
         ViewerConfiguration viewerConfig = (ViewerConfiguration)config.GetSection("jsonViewer");
         InternalConfig(viewerConfig);
     }
     catch
     {
         InitDefaults();
     }
 }