Example #1
0
        static ExternalSourceEditorService()
        {
            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                var attribute = type.GetCustomAttribute <ExternalSourceEditorAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                var metadata = new ExternalSourceEditorMetadata(
                    type,
                    attribute.Key,
                    attribute.Name,
                    attribute.Description,
                    attribute.AllowOverridePath,
                    attribute.AllowSpecifyArgs,
                    attribute.AllowSpecifyAdditionalArgs);

                ExternalSourceEditorsMap.Add(metadata.Key, metadata);

                if (metadata.Key == "default")
                {
                    DefaultExternalSourceEditor = metadata;
                }
            }
        }
Example #2
0
 // todo: maybe cache and reuse instances
 private static IExternalSourceEditor CreateEditorInstance(ExternalSourceEditorMetadata editorMetadata)
 => (IExternalSourceEditor)Activator.CreateInstance(editorMetadata.Type);