Beispiel #1
0
        public static List <MemberInfo> GetSuggestableMemberInfos(this Type type, bool isStatic, ScriptRunner script)
        {
            if (type == null || script == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var members    = new List <MemberInfo>();
            var properties = type.GetProperties().DistinctBy(x => x.Name);
            var fields     = type.GetFields().Where(x => !x.IsSpecialName).DistinctBy(x => x.Name);

            var extensionMethods = script.ExtensionMethods.Where(x => x.Value.Any(v => v.Item2.IsAssignableFrom(type) ||
                                                                                  type.GetTypeInfo().ImplementedInterfaces.Any(typeInfo => GetNameWithoutGenericArity(typeInfo) == x.Key)))
                                   .SelectMany(x => x.Value.Select(v => v.Item1));
            var methods = type.GetMethods().Where(x => !x.IsSpecialName);
            var events  = type.GetEvents().DistinctBy(x => x.Name);

            if (!isStatic)
            {
                properties = properties.Where(x => !x.IsStatic());
                fields     = fields.Where(x => !x.IsStatic);
                methods    = methods.Where(x => !x.IsStatic);
                events     = events.Where(x => !x.IsStatic());
            }

            if (extensionMethods != null && !isStatic)
            {
                methods = methods.Union(extensionMethods).DistinctBy(x => x.Name);
            }
            else
            {
                methods = methods.DistinctBy(x => x.Name);
            }

            members.AddRange(properties);
            members.AddRange(fields);
            members.AddRange(methods);
            members.AddRange(events);

            return(members.DistinctBy(x => x.Name).OrderBy(x => x.Name).ToList());
        }
Beispiel #2
0
 public Globals(ScriptRunner script)
 {
     this.script = script;
 }
 public AutoCompletionHandler(ScriptRunner script)
 {
     this.script = script;
 }