示例#1
0
        internal object CreateTabCompletionSource(CommandLineArgumentsDefinition definition, CommandLineArgument argument)
        {
            ITabCompletionSource ret;

            if (this.CompletionSourceType.GetInterfaces().Contains(typeof(ISmartTabCompletionSource)))
            {
                var source = Activator.CreateInstance(CompletionSourceType) as ISmartTabCompletionSource;
                return(new ArgumentAwareWrapperSmartTabCompletionSource(definition, argument, source));
            }
            else if (this.CompletionSourceType.IsSubclassOf(typeof(ArgumentAwareTabCompletionSource)))
            {
                ret = (ITabCompletionSource)Activator.CreateInstance(this.CompletionSourceType, definition, argument);
            }
            else if (this.CompletionSourceType.GetInterfaces().Contains(typeof(ITabCompletionSource)))
            {
                var toWrap = (ITabCompletionSource)Activator.CreateInstance(this.CompletionSourceType);
                ret = new ArgumentAwareWrapperTabCompletionSource(definition, argument, toWrap);
            }
            else
            {
                throw new InvalidArgDefinitionException("The type " + this.CompletionSourceType.FullName + " does not implement ITabCompletionSource or ITabCompletionSource.  The target argument was " + argument.DefaultAlias);
            }

            return(ret);
        }
示例#2
0
        internal object CreateTabCompletionSource(CommandLineArgumentsDefinition definition, CommandLineArgument argument)
        {
            ITabCompletionSource ret;
            if(this.CompletionSourceType.GetInterfaces().Contains(typeof(ISmartTabCompletionSource)))
            {
                var source = Activator.CreateInstance(CompletionSourceType) as ISmartTabCompletionSource;
                return new ArgumentAwareWrapperSmartTabCompletionSource(definition, argument, source);
            }
            else if (this.CompletionSourceType.IsSubclassOf(typeof(ArgumentAwareTabCompletionSource)))
            {
                ret = (ITabCompletionSource)Activator.CreateInstance(this.CompletionSourceType, definition, argument);
            }
            else if (this.CompletionSourceType.GetInterfaces().Contains(typeof(ITabCompletionSource)))
            {
                var toWrap = (ITabCompletionSource)Activator.CreateInstance(this.CompletionSourceType);
                ret = new ArgumentAwareWrapperTabCompletionSource(definition, argument, toWrap);
            }
            else
            {
                throw new InvalidArgDefinitionException("The type " + this.CompletionSourceType.FullName + " does not implement ITabCompletionSource or ITabCompletionSource.  The target argument was " + argument.DefaultAlias);
            }

            return ret;
        }