|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Text;
|
4 |
| -using System.Threading.Tasks; |
5 | 4 | using Rubberduck.VBEditor.ComManagement.TypeLibs;
|
6 | 5 | using Rubberduck.VBEditor.SafeComWrappers.Abstract;
|
7 | 6 | using Reflection = System.Reflection;
|
8 |
| -using System.Linq; |
| 7 | +using ComTypes = System.Runtime.InteropServices.ComTypes; |
9 | 8 |
|
10 | 9 | namespace Rubberduck.VBEditor.ComManagement.TypeLibsAPI
|
11 | 10 | {
|
@@ -258,7 +257,7 @@ public static string GetProjectConditionalCompilationArgsRaw(IVBProject project)
|
258 | 257 | /// <returns>returns the raw unparsed conditional arguments string, e.g. "foo = 1 : bar = 2"</returns>
|
259 | 258 | public static string GetProjectConditionalCompilationArgsRaw(TypeLibWrapper projectTypeLib)
|
260 | 259 | {
|
261 |
| - return projectTypeLib.ConditionalCompilationArguments; |
| 260 | + return projectTypeLib.ConditionalCompilationArgumentsRaw; |
262 | 261 | }
|
263 | 262 |
|
264 | 263 | /// <summary>
|
@@ -298,18 +297,7 @@ public static Dictionary<string, string> GetProjectConditionalCompilationArgs(IV
|
298 | 297 | /// <returns>returns a Dictionary<string, string>, parsed from the conditional arguments string</returns>
|
299 | 298 | public static Dictionary<string, string> GetProjectConditionalCompilationArgs(TypeLibWrapper projectTypeLib)
|
300 | 299 | {
|
301 |
| - // FIXME move dictionary stuff into the lower API here |
302 |
| - string args = GetProjectConditionalCompilationArgsRaw(projectTypeLib); |
303 |
| - |
304 |
| - if (args.Length > 0) |
305 |
| - { |
306 |
| - string[] argsArray = args.Split(new[] { ':' }); |
307 |
| - return argsArray.Select(item => item.Split('=')).ToDictionary(s => s[0], s => s[1]); |
308 |
| - } |
309 |
| - else |
310 |
| - { |
311 |
| - return new Dictionary<string, string>(); |
312 |
| - } |
| 300 | + return projectTypeLib.ConditionalCompilationArguments; |
313 | 301 | }
|
314 | 302 |
|
315 | 303 | /// <summary>
|
@@ -349,7 +337,7 @@ public static void SetProjectConditionalCompilationArgsRaw(IVBProject project, s
|
349 | 337 | /// <param name="newConditionalArgs">Raw string representing the arguments, e.g. "foo = 1 : bar = 2"</param>
|
350 | 338 | public static void SetProjectConditionalCompilationArgsRaw(TypeLibWrapper projectTypeLib, string newConditionalArgs)
|
351 | 339 | {
|
352 |
| - projectTypeLib.ConditionalCompilationArguments = newConditionalArgs; |
| 340 | + projectTypeLib.ConditionalCompilationArgumentsRaw = newConditionalArgs; |
353 | 341 | }
|
354 | 342 |
|
355 | 343 | /// <summary>
|
@@ -389,9 +377,7 @@ public static void SetProjectConditionalCompilationArgs(IVBProject project, Dict
|
389 | 377 | /// <param name="newConditionalArgs">Dictionary<string, string> representing the argument name-value pairs</param>
|
390 | 378 | public static void SetProjectConditionalCompilationArgs(TypeLibWrapper projectTypeLib, Dictionary<string, string> newConditionalArgs)
|
391 | 379 | {
|
392 |
| - // FIXME move dictionary stuff into the lower API here |
393 |
| - var rawArgsString = string.Join(" : ", newConditionalArgs.Select(x => x.Key + " = " + x.Value)); |
394 |
| - SetProjectConditionalCompilationArgsRaw(projectTypeLib, rawArgsString); |
| 380 | + projectTypeLib.ConditionalCompilationArguments = newConditionalArgs; |
395 | 381 | }
|
396 | 382 |
|
397 | 383 | /// <summary>
|
@@ -829,6 +815,66 @@ public static string GetUserFormControlType(TypeInfoWrapper userFormTypeInfo, st
|
829 | 815 | return userFormTypeInfo.ImplementedInterfaces.Get("FormItf").GetControlType(controlName).GetProgID();
|
830 | 816 | }
|
831 | 817 |
|
| 818 | + /// <summary> |
| 819 | + /// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID |
| 820 | + /// </summary> |
| 821 | + /// <param name="ide">Safe-com wrapper representing the VBE</param> |
| 822 | + /// <param name="projectName">The VBA project name</param> |
| 823 | + /// <param name="componentName">The name of the component (module/class etc) to get flags for</param> |
| 824 | + /// <returns>bool indicating success/failure.</returns> |
| 825 | + public static ComTypes.TYPEFLAGS GetComponentTypeFlags(IVBE ide, string projectName, string componentName) |
| 826 | + { |
| 827 | + using (var typeLibs = new VBETypeLibsAccessor(ide)) |
| 828 | + { |
| 829 | + return GetComponentTypeFlags(typeLibs.Get(projectName), componentName); |
| 830 | + } |
| 831 | + } |
| 832 | + |
| 833 | + /// <summary> |
| 834 | + /// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID |
| 835 | + /// </summary> |
| 836 | + /// <param name="project">Safe-com wrapper representing the VBA project</param> |
| 837 | + /// <param name="componentName">The name of the component (module/class etc) to get flags for</param> |
| 838 | + /// <returns>bool indicating success/failure.</returns> |
| 839 | + public static ComTypes.TYPEFLAGS GetComponentTypeFlags(IVBProject project, string componentName) |
| 840 | + { |
| 841 | + using (var typeLib = TypeLibWrapper.FromVBProject(project)) |
| 842 | + { |
| 843 | + return GetComponentTypeFlags(typeLib, componentName); |
| 844 | + } |
| 845 | + } |
| 846 | + |
| 847 | + /// <summary> |
| 848 | + /// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID |
| 849 | + /// </summary> |
| 850 | + /// <param name="projectTypeLib">Low-level ITypeLib wrapper representing the VBA project</param> |
| 851 | + /// <param name="componentName">The name of the component (module/class etc) to get flags for</param> |
| 852 | + /// <returns>bool indicating success/failure.</returns> |
| 853 | + public static ComTypes.TYPEFLAGS GetComponentTypeFlags(TypeLibWrapper projectTypeLib, string componentName) |
| 854 | + { |
| 855 | + return GetComponentTypeFlags(projectTypeLib.TypeInfos.Get(componentName)); |
| 856 | + } |
| 857 | + |
| 858 | + /// <summary> |
| 859 | + /// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID |
| 860 | + /// </summary> |
| 861 | + /// <param name="component">Safe-com wrapper representing the VBA component to get flags for</param> |
| 862 | + /// <returns>bool indicating success/failure.</returns> |
| 863 | + public static ComTypes.TYPEFLAGS GetComponentTypeFlags(IVBComponent component) |
| 864 | + { |
| 865 | + return GetComponentTypeFlags(component.ParentProject, component.Name); |
| 866 | + } |
| 867 | + |
| 868 | + /// <summary> |
| 869 | + /// Retreives the TYPEFLAGS of a VBA component (e.g. module/class), providing flags like TYPEFLAG_FCANCREATE, TYPEFLAG_FPREDECLID |
| 870 | + /// </summary> |
| 871 | + /// <param name="componentTypeInfo">Low-level ITypeInfo wrapper representing the VBA component to get flags for</param> |
| 872 | + /// <returns>bool indicating success/failure.</returns> |
| 873 | + public static ComTypes.TYPEFLAGS GetComponentTypeFlags(TypeInfoWrapper componentTypeInfo) |
| 874 | + { |
| 875 | + return componentTypeInfo.Flags; |
| 876 | + } |
| 877 | + |
832 | 878 | /// <summary>
|
833 | 879 | /// Returns a TypeInfoReference object containing information about the specified VBA project reference
|
834 | 880 | /// </summary>
|
|
0 commit comments