Beispiel #1
0
        private void ResolveNamespaces(IList elements, ExpressionContext context)
        {
            ImportBase currentImport = context.Imports.RootImport;

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

                var 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)
                {
                    var newFirst = (MemberElement)elements[0];
                    newFirst.SetImport(currentImport);
                }
            }

            if (elements.Count == 0)
            {
                throw CreateCompileException(CompileErrors.NamespaceCannotBeUsedAsType, CompileExceptionReason.TypeMismatch, currentImport.Name);
            }
        }
Beispiel #2
0
        private void ResolveNamespaces(IList elements, IServiceProvider services)
        {
            ExpressionContext context       = (ExpressionContext)services.GetService(typeof(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);
            }
        }