示例#1
0
    public MyNestedTypeInfo(TypeDefinition typeDefinition, MyClassInfo declaringType)
      : base()
    {
      Debug.Assert(Utils.IsTypeNested(typeDefinition), "Impossible! Given type is not a nested type.");

      string[] readableForms = Tools.GetHumanReadableForms(typeDefinition);
      this.name = readableForms[0];

      int indexOfLastSlash = this.name.LastIndexOf('/');
      Debug.Assert(indexOfLastSlash != -1 && indexOfLastSlash + 1 < this.Name.Length, "Impossible! This is a nested type.");

      this.name = this.name.Substring(indexOfLastSlash + 1);

      this.attributes = MyClassInfo.GetMyClassAttributes(typeDefinition);
      this.declaringType = declaringType;

      this.metaType = GetMetaType(typeDefinition);

      if (metaType == NestedTypes.Unknown)
      {
        Logger.Warning("Unrecognized meta type of '{0}'", typeDefinition.FullName);
      }
    }
示例#2
0
        public MyNestedTypeInfo(TypeDefinition typeDefinition, MyClassInfo declaringType)
            : base()
        {
            Debug.Assert(Utils.IsTypeNested(typeDefinition), "Impossible! Given type is not a nested type.");

            string[] readableForms = Tools.GetHumanReadableForms(typeDefinition);
            this.name = readableForms[0];

            int indexOfLastSlash = this.name.LastIndexOf('/');

            Debug.Assert(indexOfLastSlash != -1 && indexOfLastSlash + 1 < this.Name.Length, "Impossible! This is a nested type.");

            this.name = this.name.Substring(indexOfLastSlash + 1);

            this.attributes    = MyClassInfo.GetMyClassAttributes(typeDefinition);
            this.declaringType = declaringType;

            this.metaType = GetMetaType(typeDefinition);

            if (metaType == NestedTypes.Unknown)
            {
                Logger.Warning("Unrecognized meta type of '{0}'", typeDefinition.FullName);
            }
        }
示例#3
0
    protected void Initialize(TypeDefinition typeDefinition)
    {
      string[] readableForms = Tools.GetHumanReadableForms(typeDefinition);

      this.name = Utils.GetUnqualifiedName(readableForms[0]);

      if (Utils.IsTypeGeneric(typeDefinition))
      {
        allGenericParametersNames =
          Tools.ExamineGenericParameters(typeDefinition.GenericParameters,
                                         typeDefinition.DeclaringType,
                                         out genericParameters,
                                         true);
      }

      this.namezpace = Utils.GetTypeNamespace(typeDefinition);
      this.attributes = GetMyClassAttributes(typeDefinition);

      if (typeDefinition.BaseType != null)
      {
        readableForms = Tools.GetHumanReadableForms(typeDefinition.BaseType);
        this.baseTypeName = readableForms[0];
      }

      var interfaces = typeDefinition.Interfaces;

      if (interfaces != null)
      {
        for (int i = 0; i < interfaces.Count; i++)
        {
          readableForms = Tools.GetHumanReadableForms(interfaces[i]);

          implementedInterfacesNames.Add(readableForms[0]);
        }
      }
    }
示例#4
0
    public static string MyClassAttributesToString(MyClassAttributes myClassAttributes)
    {
      StringBuilder sb = new StringBuilder();

      if ((myClassAttributes & MyClassAttributes.Public) != 0) { sb.Append("public "); }
      else if ((myClassAttributes & MyClassAttributes.Private) != 0) { sb.Append("private "); }
      else if ((myClassAttributes & MyClassAttributes.Protected) != 0) { sb.Append("protected "); }

      if ((myClassAttributes & MyClassAttributes.Internal) != 0) { sb.Append("internal "); }
      if ((myClassAttributes & MyClassAttributes.Abstract) != 0 && (myClassAttributes & MyClassAttributes.Sealed) != 0) { sb.Append("static "); }
      else if (((myClassAttributes & MyClassAttributes.Sealed)) != 0) { sb.Append("sealed "); }
      else if (((myClassAttributes & MyClassAttributes.Abstract)) != 0) { sb.Append("abstract "); }

      if (sb.Length > 0)
      {
        sb.Length = sb.Length - 1;
      }

      return sb.ToString();
    }