private void Grid_Initialized(object sender, EventArgs e) { CodeTextEditor.SyntaxHighlighting = HighlightingLoader.Load( new XmlTextReader(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Python.Dark.xshd")), HighlightingManager.Instance); IEnumerable <Type> namespaces = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.Namespace != null && t.IsPublic && t.IsClass && t.Namespace.EndsWith("Macros.Commands")); _completionData = new List <PythonCompletionData>(); foreach (Type type in namespaces) { MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); foreach (MethodInfo methodInfo in methods) { CommandsDisplayAttribute attr = methodInfo.GetCustomAttribute <CommandsDisplayAttribute>(); if (attr == null) { continue; } _completionData.Add( new PythonCompletionData(methodInfo.Name, attr.Description, attr.InsertText)); } } CodeTextEditor.TextArea.TextEntered += OnTextEntered; SearchPanel.Install(CodeTextEditor); }
public void EnsureAllCategoriesAreLocalizable() { IEnumerable <Type> types = Assembly.GetAssembly(typeof(Engine)).GetTypes().Where(t => t.Namespace != null && t.Namespace.EndsWith("Macros.Commands") && t.IsClass && t.IsPublic && !t.Name.Contains("Dummy")); foreach (Type type in types) { MethodInfo[] members = type.GetMethods(BindingFlags.Public | BindingFlags.Static); foreach (MethodInfo member in members) { CommandsDisplayAttribute attr = member.GetCustomAttribute <CommandsDisplayAttribute>(); if (attr == null) { Assert.Fail($"{type.Name}.{member.Name} has no CommandsDisplayAttribute."); } string resourceName = Strings.ResourceManager.GetString(attr.Category); if (string.IsNullOrEmpty(resourceName)) { Assert.Fail( $"{type.Name}.{member.Name}: Category \"{attr.Category}\" has no resource entry."); } } } }
public MacrosCommandViewModel() { IEnumerable <Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.Namespace != null && t.Namespace.StartsWith("ClassicAssist.Data.Macros.Commands")); foreach (Type type in types) { MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo memberInfo in members) { CommandsDisplayAttribute attr = memberInfo.GetCustomAttribute <CommandsDisplayAttribute>(); if (attr == null) { continue; } CommandsData entry = new CommandsData { Category = attr.Category, IsExpanded = false, Name = memberInfo.ToString(), Tooltip = attr.Description, Attribute = attr }; Items.Add(entry); } } }
private void Grid_Initialized(object sender, EventArgs e) { CodeTextEditor.SyntaxHighlighting = HighlightingLoader.Load( new XmlTextReader(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Python.Dark.xshd")), HighlightingManager.Instance); IEnumerable <Type> namespaces = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.Namespace != null && t.IsPublic && t.IsClass && t.Namespace.EndsWith("Macros.Commands")); _completionData = new List <PythonCompletionData>(); foreach (Type type in namespaces) { MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); foreach (MethodInfo methodInfo in methods) { CommandsDisplayAttribute attr = methodInfo.GetCustomAttribute <CommandsDisplayAttribute>(); if (attr == null) { continue; } string fullName = $"{methodInfo.Name}("; bool first = true; foreach (ParameterInfo parameterInfo in methodInfo.GetParameters()) { if (first) { first = false; } else { fullName += ", "; } bool optional = parameterInfo.RawDefaultValue == null || parameterInfo.RawDefaultValue.GetType() != typeof(DBNull); fullName += $"{( optional ? "[" : "" )}{parameterInfo.ParameterType.Name} {parameterInfo.Name}{( optional ? "]" : "" )}"; } fullName += $"):{methodInfo.ReturnType.Name}"; _completionData.Add(new PythonCompletionData(methodInfo.Name, fullName, attr.Description, attr.InsertText)); } } CodeTextEditor.TextArea.TextEntered += OnTextEntered; SearchPanel.Install(CodeTextEditor); }
public void EnsureAllCommandsHaveAttribute() { IEnumerable <Type> types = Assembly.GetAssembly(typeof(Engine)).GetTypes().Where(t => t.Namespace != null && t.Namespace.EndsWith("Macros.Commands") && t.IsClass && t.IsPublic && !t.Name.Contains("Dummy")); foreach (Type type in types) { MethodInfo[] members = type.GetMethods(BindingFlags.Public | BindingFlags.Static); foreach (MethodInfo member in members) { CommandsDisplayAttribute attr = member.GetCustomAttribute <CommandsDisplayAttribute>(); if (attr == null) { Assert.Fail($"{type.Name}.{member.Name} has no CommandsDisplayAttribute."); } } } }