Пример #1
0
 internal static CilTypeDefinition Create(TypeDefinition typeDef, ref CilReaders readers, int token)
 {
     CilTypeDefinition type = new CilTypeDefinition();
     type._typeDefinition = typeDef;
     type._token = token;
     type._readers = readers;
     type._isBaseTypeInitialized = false;
     type._isLayoutInitialized = false;
     return type;
 }
Пример #2
0
 internal static CilField Create(FieldDefinition fieldDefinition, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
 {
     CilField field = new CilField();
     field._fieldDefinition = fieldDefinition;
     field._token = token;
     field._readers = readers;
     field._typeDefinition = typeDefinition;
     field._isDefaultInitialized = false;
     return field;
 }
Пример #3
0
        internal static CilTypeDefinition Create(TypeDefinition typeDef, ref CilReaders readers, int token)
        {
            CilTypeDefinition type = new CilTypeDefinition();

            type._typeDefinition        = typeDef;
            type._token                 = token;
            type._readers               = readers;
            type._isBaseTypeInitialized = false;
            type._isLayoutInitialized   = false;
            return(type);
        }
Пример #4
0
 internal static CilProperty Create(PropertyDefinition propertyDef, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
 {
     CilProperty property = new CilProperty();
     property._typeDefinition = typeDefinition;
     property._propertyDef = propertyDef;
     property._readers = readers;
     property._isSignatureInitialized = false;
     property._isDefaultValueInitialized = false;
     property._isGetterInitialized = false;
     property._isSetterInitialized = false;
     property._token = token;
     property._accessors = propertyDef.GetAccessors();
     return property;
 }
Пример #5
0
 internal static CilEventDefinition Create(EventDefinition eventDefinition, int token, ref CilReaders readers, CilTypeDefinition declaringType)
 {
     CilEventDefinition eventDef = new CilEventDefinition();
     eventDef._eventDefinition = eventDefinition;
     eventDef._readers = readers;
     eventDef._typeDefinition = declaringType;
     eventDef._accessors = eventDefinition.GetAccessors();
     eventDef._isAdderInitialized = false;
     eventDef._isRemoverInitialized = false;
     eventDef._isRaiserInitialized = false;
     eventDef._isEntityInitialized = false;
     eventDef._token = token;
     return eventDef;
 }
Пример #6
0
 internal static CilMethodDefinition Create(MethodDefinition methodDefinition, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
 {
     CilMethodDefinition method = new CilMethodDefinition();
     method._methodDefinition = methodDefinition;
     method._token = token;
     method._typeDefinition = typeDefinition;
     method._readers = readers;
     method._provider = readers.Provider;
     method._rva = -1;
     method._methodDeclarationToken = -1;
     method._isIlReaderInitialized = false;
     method._isSignatureInitialized = false;
     method._isImportInitialized = false;
     if(method.RelativeVirtualAddress != 0)
         method._methodBody = method._readers.PEReader.GetMethodBody(method.RelativeVirtualAddress);
     return method;
 }
Пример #7
0
        private IEnumerable <CilTypeDefinition> GetTypeDefinitions()
        {
            var handles = _readers.MdReader.TypeDefinitions;

            foreach (var handle in handles)
            {
                if (handle.IsNil)
                {
                    continue;
                }
                var typeDefinition = _readers.MdReader.GetTypeDefinition(handle);
                if (typeDefinition.GetDeclaringType().IsNil)
                {
                    yield return(CilTypeDefinition.Create(typeDefinition, ref _readers, MetadataTokens.GetToken(handle)));
                }
            }
        }
Пример #8
0
 internal static CilMethodDefinition Create(MethodDefinitionHandle methodHandle, ref CilReaders readers, CilTypeDefinition typeDefinition)
 {
     MethodDefinition method = readers.MdReader.GetMethodDefinition(methodHandle);
     int token = MetadataTokens.GetToken(methodHandle);
     return Create(method, token, ref readers, typeDefinition);
 }
Пример #9
0
        internal static CilProperty Create(PropertyDefinition propertyDef, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
        {
            CilProperty property = new CilProperty();

            property._typeDefinition            = typeDefinition;
            property._propertyDef               = propertyDef;
            property._readers                   = readers;
            property._isSignatureInitialized    = false;
            property._isDefaultValueInitialized = false;
            property._isGetterInitialized       = false;
            property._isSetterInitialized       = false;
            property._token     = token;
            property._accessors = propertyDef.GetAccessors();
            return(property);
        }
Пример #10
0
        internal static CilMethodDefinition Create(MethodDefinitionHandle methodHandle, ref CilReaders readers, CilTypeDefinition typeDefinition)
        {
            MethodDefinition method = readers.MdReader.GetMethodDefinition(methodHandle);
            int token = MetadataTokens.GetToken(methodHandle);

            return(Create(method, token, ref readers, typeDefinition));
        }
Пример #11
0
        internal static CilMethodDefinition Create(MethodDefinition methodDefinition, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
        {
            CilMethodDefinition method = new CilMethodDefinition();

            method._methodDefinition = methodDefinition;
            method._token            = token;
            method._typeDefinition   = typeDefinition;
            method._readers          = readers;
            method._provider         = readers.Provider;
            method._rva = -1;
            method._methodDeclarationToken = -1;
            method._isIlReaderInitialized  = false;
            method._isSignatureInitialized = false;
            method._isImportInitialized    = false;
            if (method.RelativeVirtualAddress != 0)
            {
                method._methodBody = method._readers.PEReader.GetMethodBody(method.RelativeVirtualAddress);
            }
            return(method);
        }
Пример #12
0
        internal static CilField Create(FieldDefinition fieldDefinition, int token, ref CilReaders readers, CilTypeDefinition typeDefinition)
        {
            CilField field = new CilField();

            field._fieldDefinition      = fieldDefinition;
            field._token                = token;
            field._readers              = readers;
            field._typeDefinition       = typeDefinition;
            field._isDefaultInitialized = false;
            return(field);
        }
Пример #13
0
        internal static CilEventDefinition Create(EventDefinition eventDefinition, int token, ref CilReaders readers, CilTypeDefinition declaringType)
        {
            CilEventDefinition eventDef = new CilEventDefinition();

            eventDef._eventDefinition      = eventDefinition;
            eventDef._readers              = readers;
            eventDef._typeDefinition       = declaringType;
            eventDef._accessors            = eventDefinition.GetAccessors();
            eventDef._isAdderInitialized   = false;
            eventDef._isRemoverInitialized = false;
            eventDef._isRaiserInitialized  = false;
            eventDef._isEntityInitialized  = false;
            eventDef._token = token;
            return(eventDef);
        }
Пример #14
0
 public TypeDefinitionNode(CilTypeDefinition typeDef)
 {
     _typeDefinition = typeDef;
     _children.AddRange(typeDef.FieldDefinitions.Select(cf => new FieldNode(cf)));
     _children.AddRange(typeDef.Properties.Select(cp => new PropertyNode(cp)));
     _children.AddRange(
         typeDef.MethodDefinitions
             .Where(cmd => !cmd.Name.StartsWith("get_") && !cmd.Name.StartsWith("set_"))
             .Select(cmd => new MethodNode(cmd)));
 }