Ejemplo n.º 1
0
        public void Write(TextWriter writer, Type type)
        {
            WriteTypeKind(writer, type);
            writer.Write(" \"");

            _typeNameWriter.Write(writer, type);
            writer.Write("\" as ");
            _escapedTypeNameWriter.Write(writer, type);

            writer.WriteLine(" {");

            WriteMembers(
                writer,
                () => _queryType.GetFields(type),
                i => _fieldWriter.Write(writer, i));

            WriteMembers(
                writer,
                () => _queryType.GetProperties(type),
                i => _propertyWriter.Write(writer, i));

            WriteMembers(
                writer,
                () => _queryType.GetMethods(type),
                i => _methodWriter.Write(writer, i));

            WriteMembers(
                writer,
                () => _queryType.GetEvents(type),
                i => _eventWriter.Write(writer, i));

            writer.WriteLine("}");
        }
Ejemplo n.º 2
0
        public void Write(TextWriter writer, Type type, IQueryType queryType)
        {
            WriteTypeKind(writer, type);
            writer.Write(' ');
            _typeNameWriter.Write(writer, type);

            if (type.BaseType != null)
            {
                writer.Write(" : ");
                _typeNameWriter.Write(writer, type.BaseType);
            }

            var implementedInterfaces = queryType.GetInterfaces(type).ToArray();

            if (implementedInterfaces.Length > 0)
            {
                writer.Write(" implements ");
                writer.Write(string.Join(',', implementedInterfaces.Select(_typeNameConverter.ToString)));
            }

            writer.WriteLine(" {");

            WriteMembers("Fields",
                         writer,
                         () => queryType.GetFields(type),
                         i => _fieldWriter.Write(writer, i));

            WriteMembers("Properties",
                         writer,
                         () => queryType.GetProperties(type),
                         i => _propertyWriter.Write(writer, i));

            WriteMembers("Methods",
                         writer,
                         () => queryType.GetMethods(type),
                         i => _methodWriter.Write(writer, i));

            WriteMembers("Events",
                         writer,
                         () => queryType.GetEvents(type),
                         i => _eventWriter.Write(writer, i));

            writer.WriteLine("}");
        }
Ejemplo n.º 3
0
        public void Write(TextWriter writer, EventInfo eventInfo)
        {
            var builder = new StringBuilder();

            if (eventInfo.EventHandlerType != null)
            {
                _typeNameWriter.Write(writer, eventInfo.EventHandlerType);
                writer.Write(' ');
            }

            writer.Write(eventInfo.Name);
        }
Ejemplo n.º 4
0
        public void Write(TextWriter writer, PropertyInfo propertyInfo)
        {
            bool hasGetter = propertyInfo.GetMethod?.IsPublic ?? false;
            bool hasSetter = propertyInfo.SetMethod?.IsPublic ?? false;

            _typeNameWriter.Write(writer, propertyInfo.PropertyType);
            writer.Write(' ');
            writer.Write(propertyInfo.Name);
            if (hasGetter && hasSetter)
            {
                writer.Write(" { get; set; }");
            }
            else if (hasGetter)
            {
                writer.Write(" { get; }");
            }
            else if (hasSetter)
            {
                writer.Write(" { set; }");
            }
        }
Ejemplo n.º 5
0
        public void Write(TextWriter writer, MethodInfo methodInfo)
        {
            var pars       = methodInfo.GetParameters();
            var parsString = string.Join(',', pars.Select(p => $"{p.Name}: {_typeNameConverter.ToString(p.ParameterType)}"));

            var builder = new StringBuilder();

            _typeNameWriter.Write(writer, methodInfo.ReturnType);
            writer.Write(' ');
            writer.Write(methodInfo.Name);

            if (methodInfo.IsGenericMethod)
            {
                var genericParams = string.Join(',',
                                                methodInfo.GetGenericArguments().Select(_typeNameConverter.ToString));
                writer.Write('<');
                writer.Write(genericParams);
                writer.Write('>');
            }

            writer.Write('(');
            writer.Write(parsString);
            writer.Write(')');
        }
Ejemplo n.º 6
0
 public void Write(TextWriter writer, FieldInfo fieldInfo)
 {
     _typeNameWriter.Write(writer, fieldInfo.FieldType);
     writer.Write(' ');
     writer.Write(fieldInfo.Name);
 }