Ejemplo n.º 1
0
        public string UnaliasTest(string name)
        {
            string result = InteropTypeResolver.Unalias(name);

            return(result);
            // TODO: add assertions to method InteropTypeResolverTest.UnaliasTest(String)
        }
Ejemplo n.º 2
0
        private Type GetPropertyType(
            TypeBuilder typeBuilder,
            string defaultType,
            IdentifierExpression property,
            HashSet <string> imports)
        {
            if (property.Attributes == null || property.Attributes.Count == 0)
            {
                return(Interpreter.InteropTypeResolver.ResolveType(
                           imports,
                           _importsLock,
                           new[] { InteropTypeResolver.Unalias(defaultType) },
                           isType: true));
            }

            var scanner = new AphidAttributeScanner(property);

            scanner.Next();
            var typeName = InteropTypeResolver.Unalias(scanner.CurrentAttribute);

            Type t = typeName == typeBuilder.Name
                ? typeBuilder
                : Interpreter.InteropTypeResolver.ResolveType(
                imports,
                _importsLock,
                new[] { typeName },
                isType: true);

            if (!scanner.Next())
            {
                return(t);
            }

            t = scanner.Match("list")
                ? typeof(List <>).MakeGenericType(t)
                : scanner.Match("set")
                    ? t.MakeArrayType()
                    : throw new AphidParserException(
                          "Invalid property attribute '{0}'.",
                          scanner.CurrentAttribute);

            return(!scanner.EndOfStream()
                ? throw new AphidParserException(
                       "Unexpected property attribute '{0}'.",
                       scanner.CurrentAttribute)
                : t);
        }