示例#1
0
        internal Type FindType(string[] typeNameParts)
        {
            string[] namespaces = new string[typeNameParts.Length - 1];
            string   typeName   = typeNameParts[typeNameParts.Length - 1];

            System.Array.Copy(typeNameParts, namespaces, namespaces.Length);
            ImportBase currentImport = MyRootImport;

            foreach (string ns in namespaces)
            {
                currentImport = currentImport.FindImport(ns);
                if (currentImport == null)
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
            }

            if (currentImport == null)
            {
                return(null);
            }
            else
            {
                return(currentImport.FindType(typeName));
            }
        }
 protected override void AddMembers(MemberTypes memberType, ICollection <MemberInfo> dest)
 {
     if (MyUseTypeNameAsNamespace == false)
     {
         MemberInfo[] members = MyType.FindMembers(memberType, MyBindFlags, this.AlwaysMemberFilter, null);
         ImportBase.AddMemberRange(members, dest);
     }
 }
        private void ResolveNamespaces(IList elements, IServiceProvider services)
        {
            ExpressionContext context       = services.GetService(typeof(ExpressionContext)) as ExpressionContext;
            ImportBase        currentImport = context.Imports.RootImport;

            while (true)
            {
                string name = GetName(elements);

                if (name == null)
                {
                    break;                     // TODO: might not be correct. Was : Exit While
                }

                ImportBase import = currentImport.FindImport(name);

                if (import == null)
                {
                    break;                     // TODO: might not be correct. Was : Exit While
                }

                currentImport = import;
                elements.RemoveAt(0);

                if (elements.Count > 0)
                {
                    MemberElement newFirst = (MemberElement)elements[0];
                    newFirst.SetImport(currentImport);
                }
            }

            if (elements.Count == 0)
            {
                base.ThrowCompileException(CompileErrorResourceKeys.NamespaceCannotBeUsedAsType, CompileExceptionReason.TypeMismatch, currentImport.Name);
            }
        }
        protected override bool EqualsInternal(ImportBase import)
        {
            MethodImport otherSameType = import as MethodImport;

            return((otherSameType != null) && MyMethod.MethodHandle.Equals(otherSameType.MyMethod.MethodHandle));
        }
        protected override bool EqualsInternal(ImportBase import)
        {
            TypeImport otherSameType = import as TypeImport;

            return((otherSameType != null) && object.ReferenceEquals(MyType, otherSameType.MyType));
        }
 protected override void AddMembers(string memberName, MemberTypes memberType, ICollection <MemberInfo> dest)
 {
     MemberInfo[] members = MyType.FindMembers(memberType, MyBindFlags, this.Context.Options.MemberFilter, memberName);
     ImportBase.AddMemberRange(members, dest);
 }
示例#7
0
 public void SetImport(ImportBase import)
 {
     MyImport = import;
 }