Ejemplo n.º 1
0
        internal void FindMethods()
        {
            //reset
            if (methods == null)
            {
                methods = new List <OwnerMember>();
            }
            else
            {
                methods.Clear();
            }

            //try to add all of its instance methods
            MethodInfo[] allMethods = owner.GetType().GetMethods();
            for (int i = 0; i < allMethods.Length; i++)
            {
                //short circuit if static
                if (allMethods[i].IsStatic)
                {
                    continue;
                }

                CommandAttribute attribute = allMethods[i].GetCommand();
                if (attribute != null)
                {
                    OwnerMember method = new OwnerMember(owner, allMethods[i])
                    {
                        name        = attribute.name,
                        description = attribute.description,
                        type        = allMethods[i].ReturnType
                    };
                    methods.Add(method);
                }
            }
        }
        public override FSharpSymbol GetFSharpSymbol()
        {
            var mfv     = OwnerMember?.GetFSharpSymbol() as FSharpMemberOrFunctionOrValue;
            var members = mfv?.DeclaringEntity?.Value.MembersFunctionsAndValues;

            var range = mfv?.DeclarationLocation;

            return(members?.FirstOrDefault(m => m.LogicalName == CompiledName && m.DeclarationLocation.Equals(range)));
        }
Ejemplo n.º 3
0
        internal void FindProperties()
        {
            //reset
            if (properties == null)
            {
                properties = new List <OwnerMember>();
            }
            else
            {
                properties.Clear();
            }

            //try to add all of its instance properties
            PropertyInfo[] allProperties = owner.GetType().GetProperties();
            for (int i = 0; i < allProperties.Length; i++)
            {
                //short circuit if static
                MethodInfo get = allProperties[i].GetGetMethod();
                MethodInfo set = null;
                if (get != null && get.IsStatic)
                {
                    continue;
                }
                else if (get == null)
                {
                    set = allProperties[i].GetSetMethod();
                    if (set != null && set.IsStatic)
                    {
                        continue;
                    }
                }

                CommandAttribute attribute = allProperties[i].GetCommand();
                if (attribute != null)
                {
                    OwnerMember method = new OwnerMember(owner, allProperties[i])
                    {
                        name           = attribute.name,
                        description    = attribute.description,
                        type           = get?.ReturnType,
                        canGetProperty = get != null,
                        canSetProperty = set != null
                    };
                    properties.Add(method);
                }
            }
        }