Beispiel #1
0
        private void ResolveNamespaces(IList <object> elements, IServiceProvider services)
        {
            var        context       = (ExpressionContext)services.GetService(typeof(ExpressionContext));
            ImportBase currentImport = context.Imports.RootImport;

            while (true)
            {
                var name = GetName(elements);
                var flag = name == null;
                if (flag)
                {
                    break;
                }
                var import = currentImport.FindImport(name);
                var flag2  = import == null;
                if (flag2)
                {
                    break;
                }
                currentImport = import;
                elements.RemoveAt(0);
                var flag3 = elements.Count > 0;
                if (flag3)
                {
                    var newFirst = (MemberElement)elements[0];
                    newFirst.SetImport(currentImport);
                }
            }
            var flag4 = elements.Count == 0;

            if (flag4)
            {
                this.ThrowCompileException("NamespaceCannotBeUsedAsType", CompileExceptionReason.TypeMismatch, currentImport.Name);
            }
        }
Beispiel #2
0
        internal Type FindType(string[] typeNameParts)
        {
            var namespaces = new string[typeNameParts.Length - 2 + 1];
            var typeName   = typeNameParts[typeNameParts.Length - 1];

            Array.Copy(typeNameParts, namespaces, namespaces.Length);
            ImportBase currentImport = this.RootImport;
            var        array         = namespaces;

            checked
            {
                for (var i = 0; i < array.Length; i++)
                {
                    var ns = array[i];
                    currentImport = currentImport.FindImport(ns);
                    var flag = currentImport == null;
                    if (flag)
                    {
                        break;
                    }
                }
                var flag2    = currentImport == null;
                var findType = flag2 ? null : currentImport.FindType(typeName);
                return(findType);
            }
        }
Beispiel #3
0
        protected override bool EqualsInternal(ImportBase import)
        {
            var otherSameType = import as MethodImport;

            return(otherSameType != null && this.Target.MethodHandle.Equals(otherSameType.Target.MethodHandle));
        }
Beispiel #4
0
        protected override bool EqualsInternal(ImportBase import)
        {
            var otherSameType = import as TypeImport;

            return(otherSameType != null && this.Target == otherSameType.Target);
        }
Beispiel #5
0
 public void SetImport(ImportBase import)
 {
     this.myImport = import;
 }