Ejemplo n.º 1
0
 /// <summary>
 /// Mark all properties with the given name reachable.
 /// </summary>
 internal static void MarkPropertiesReachable(this TypeReference type, string propertyName, ReachableContext context)
 {
     while ((type != null) && (context.Contains(type)))
     {
         TypeDefinition typeDef = context.GetTypeDefinition(type);
         if (typeDef != null)
         {
             if (typeDef.HasProperties)
             {
                 foreach (PropertyDefinition prop in typeDef.Properties)
                 {
                     if (prop.Name == propertyName)
                     {
                         prop.MarkReachable(context);
                     }
                 }
             }
             type = typeDef.BaseType;
         }
         else
         {
             type = null;
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Mark all fields with the given name reachable.
 /// </summary>
 internal static void MarkFieldsReachable(this TypeReference type, string fieldName, ReachableContext context)
 {
     while ((type != null) && (context.Contains(type)))
     {
         TypeDefinition typeDef = context.GetTypeDefinition(type);
         if (typeDef != null)
         {
             if (typeDef.HasFields)
             {
                 foreach (FieldDefinition field in typeDef.Fields)
                 {
                     if (field.Name == fieldName)
                     {
                         field.MarkReachable(context);
                     }
                 }
             }
             type = typeDef.BaseType;
         }
         else
         {
             type = null;
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Mark all properties with the given name reachable.
 /// </summary>
 internal static void MarkPropertiesReachable(this TypeReference type, string propertyName, ReachableContext context)
 {
     while ((type != null) && (context.Contains(type)))
     {
         TypeDefinition typeDef = context.GetTypeDefinition(type);
         if (typeDef != null)
         {
             if (typeDef.HasProperties)
             {
                 foreach (PropertyDefinition prop in typeDef.Properties)
                 {
                     if (prop.Name == propertyName)
                     {
                         prop.MarkReachable(context);
                     }
                 }
             }
             type = typeDef.BaseType;
         }
         else
         {
             type = null;
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Mark all fields with the given name reachable.
 /// </summary>
 internal static void MarkFieldsReachable(this TypeReference type, string fieldName, ReachableContext context)
 {
     while ((type != null) && (context.Contains(type)))
     {
         TypeDefinition typeDef = context.GetTypeDefinition(type);
         if (typeDef != null)
         {
             if (typeDef.HasFields)
             {
                 foreach (FieldDefinition field in typeDef.Fields)
                 {
                     if (field.Name == fieldName)
                     {
                         field.MarkReachable(context);
                     }
                 }
             }
             type = typeDef.BaseType;
         }
         else
         {
             type = null;
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Resolve type reference into type defition.
        /// Generic instance types are resolved to their element type.
        /// </summary>
        internal static TypeDefinition Resolve(this TypeReference type, ReachableContext context)
        {
            if (context.Contains(type))
            {
                var typeDef = type as TypeDefinition;
                if (typeDef != null) { return typeDef; }

                var git = type as GenericInstanceType;
                if (git != null) { return git.ElementType.Resolve(context); }

                return context.GetTypeDefinition(type);
            }

            // Type not in project, don't care about it.
            return null;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Resolve type reference into type defition.
        /// Generic instance types are resolved to their element type.
        /// </summary>
        internal static TypeDefinition Resolve(this TypeReference type, ReachableContext context)
        {
            if (context.Contains(type))
            {
                var typeDef = type as TypeDefinition;
                if (typeDef != null)
                {
                    return(typeDef);
                }

                var git = type as GenericInstanceType;
                if (git != null)
                {
                    return(git.ElementType.Resolve(context));
                }

                return(context.GetTypeDefinition(type));
            }

            // Type not in project, don't care about it.
            return(null);
        }