Ejemplo n.º 1
0
        /// <summary>
        /// Gets all available refactoring options generated by automatically scanning of currently executed assembly.
        /// </summary>
        public static CustomAddInActionDictionary AutoDiscoverRefactorOptions(params Assembly[] assemblies)
        {
            try
            {
                CustomAddInActionDictionary dict = new CustomAddInActionDictionary();
                Type generalType = typeof(IPackageAction);

                foreach (Assembly a in assemblies)
                {
                    Type[] availableTypes = a.GetTypes();

                    foreach (Type type in availableTypes)
                    {
                        if (!type.IsAbstract && generalType.IsAssignableFrom(type))
                        {
                            try
                            {
                                // store for future usage:
                                dict.Add(Activator.CreateInstance(type) as IPackageAction);
                            }
                            catch (TargetInvocationException e)
                            {
                                Trace.TraceError(e.ToString());
                            }
                            catch (ArgumentException e)
                            {
                                Trace.TraceError(e.ToString());
                            }
                            catch (MissingMethodException e)
                            {
                                Trace.TraceError(e.ToString());
                            }
                        }
                    }
                }

                return(dict);
            }
            catch (Exception e)
            {
                Trace.TraceError(e.ToString());
                throw;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Store the action for future usage.
 /// </summary>
 public void Add(IPackageAction action)
 {
     actions.Add(action);
 }