Exemple #1
0
        protected MemberInfo[] GetMembers(MemberTypes targets)
        {
            if (MyPrevious == null)
            {
                // Do we have a namespace?
                if (MyImport == null)
                {
                    // Get all members in the default namespace
                    return(this.GetDefaultNamespaceMembers(MyName, targets));
                }
                else
                {
                    return(MyImport.FindMembers(MyName, targets));
                }
            }
            else
            {
                // We are not the first element; find all members with our name on the type of the previous member
                var foundMembers    = MyPrevious.TargetType.FindMembers(targets, BindFlags, MyOptions.MemberFilter, MyName);
                var importedMembers = MyContext.Imports.RootImport.FindMembers(MyName, targets);
                if (foundMembers.Length == 0) //If no members found search in root import
                {
                    return(importedMembers);
                }

                MemberInfo[] allMembers = new MemberInfo[foundMembers.Length + importedMembers.Length];
                foundMembers.CopyTo(allMembers, 0);
                importedMembers.CopyTo(allMembers, foundMembers.Length);
                return(allMembers);
            }
        }
Exemple #2
0
        protected MemberInfo[] GetMembers(MemberTypes targets)
        {
            if (Previous == null)
            {
                // Do we have a namespace?
                if (Import == null)
                {
                    // Get all members in the default namespace
                    return(GetDefaultNamespaceMembers(MemberName, targets));
                }

                return(Import.FindMembers(MemberName, targets));
            }

            // We are not the first element; find all members with our name on the type of the previous member
            return(Previous.TargetType.FindMembers(targets, BindFlags, Context.BuilderOptions.MemberFilter, MemberName));
        }
Exemple #3
0
        protected MemberInfo[] GetMembers(MemberTypes targets)
        {
            if (MyPrevious == null)
            {
                // Do we have a namespace?
                if (MyImport == null)
                {
                    // Get all members in the default namespace
                    return(this.GetDefaultNamespaceMembers(MyName, targets));
                }
                else
                {
                    return(MyImport.FindMembers(MyName, targets));
                }
            }
            else
            {
                // We are not the first element; find all members with our name on the type of the previous member
                var foundMembers = MyPrevious.TargetType.FindMembers(targets, BindFlags, MyOptions.MemberFilter, MyName);

                // in case the target type is an interface and implements other interfaces we have to search there as well
                if (foundMembers.Length == 0 && MyPrevious.TargetType.IsInterface)
                {
                    foundMembers = MyPrevious.TargetType.GetInterfaces().SelectMany(x => x.FindMembers(
                                                                                        targets,
                                                                                        BindFlags,
                                                                                        MyOptions.MemberFilter,
                                                                                        MyName)).ToArray();
                }

                var importedMembers = MyContext.Imports.RootImport.FindMembers(MyName, targets);

                if (foundMembers.Length == 0)
                {
                    // if no members are available check static extension methods in the context
                    return(importedMembers);
                }

                return(foundMembers.Union(importedMembers).ToArray());
            }
        }
Exemple #4
0
 protected MemberInfo[] GetMembers(MemberTypes targets)
 {
     if (MyPrevious == null)
     {
         // Do we have a namespace?
         if (MyImport == null)
         {
             // Get all members in the default namespace
             return(this.GetDefaultNamespaceMembers(MyName, targets));
         }
         else
         {
             return(MyImport.FindMembers(MyName, targets));
         }
     }
     else
     {
         // We are not the first element; find all members with our name on the type of the previous member
         return(MyPrevious.TargetType.FindMembers(targets, BindFlags, MyOptions.MemberFilter, MyName));
     }
 }