예제 #1
0
        public IEnumerable <string> GetSuggestions(Type type, string startsWith)
        {
            if (this.cachedFuncGetSuggestions is null)
            {
                // cache function delegate
                this.cachedType = type;
                try
                {
                    this.cachedFuncGetSuggestions = (CustomSuggestionsDelegate)
                                                    type.ScriptingGetMethod(this.methodName)
                                                    .CreateDelegate(typeof(CustomSuggestionsDelegate));
                }
                catch (NullReferenceException)
                {
                    throw new Exception(
                              $"Please ensure that the static method with name {this.methodName} exists in {type.Name}");
                }
            }
            else if (this.cachedType != type)
            {
                throw new Exception("Cached method is for the another type");
            }

            return(this.cachedFuncGetSuggestions(startsWith));
        }
        public IEnumerable <string> GetSuggestions(Type type, string startsWith)
        {
            if (this.cachedFuncGetSuggestions is null)
            {
                // cache function delegate
                this.cachedType = type;
                this.cachedFuncGetSuggestions = (CustomSuggestionsDelegate)
                                                type.ScriptingGetMethod(this.methodName)
                                                .CreateDelegate(typeof(CustomSuggestionsDelegate));
            }
            else if (this.cachedType != type)
            {
                throw new Exception("Cached method is for the another type");
            }

            return(this.cachedFuncGetSuggestions(startsWith));
        }