Ejemplo n.º 1
0
 public static string GetReadableTypeName(Type type)
 {
     return(NespUtilities.ReservedTypeNames.TryGetValue(type, out var typeName)
         ? typeName
         : NespUtilities.GetReadableTypeName(
                type, GetReadableTypeName));
 }
Ejemplo n.º 2
0
 public override string ToString()
 {
     if (type != null)
     {
         return($"{this.Symbol}:{NespUtilities.GetReadableTypeName(type)}");
     }
     else
     {
         return($"{this.Symbol}:?");
     }
 }
Ejemplo n.º 3
0
        public void AddCandidate(TypeInfo typeInfo)
        {
            var typeName = NespUtilities.GetReadableTypeName(typeInfo.AsType());

            lock (fields)
            {
                foreach (var field in typeInfo.DeclaredFields
                         .Where(field => field.IsPublic && (!typeInfo.IsEnum || !field.IsSpecialName)))
                {
                    var key = $"{typeName}.{field.Name}";
                    fields.AddCandidate(key, field);
                }
            }

            var propertyMethods = new HashSet <MethodInfo>();

            lock (properties)
            {
                foreach (var property in typeInfo.DeclaredProperties
                         .Where(property => property.CanRead && property.GetMethod.IsPublic))
                {
                    var key = $"{typeName}.{property.Name}";
                    properties.AddCandidate(key, property);

                    propertyMethods.Add(property.GetMethod);
                    propertyMethods.Add(property.SetMethod);
                }
            }

            lock (methods)
            {
                foreach (var method in typeInfo.DeclaredMethods
                         .Where(method => method.IsPublic && (propertyMethods.Contains(method) == false)))
                {
                    var key = $"{typeName}.{method.Name}";
                    methods.AddCandidate(key, method);
                }
            }
        }
Ejemplo n.º 4
0
 private static string GetReadableTypeName(Type type)
 {
     return(NespUtilities.GetReadableTypeName(type, GetReadableTypeName));
 }