// Use this method to match all definitions that can be processed by this
 // class. Eg: All classes that have the interface IProtoBuf!
 public static bool MatchDecompilableClasses(TypeDefinition t)
 {
     return
         // Validate SilentOrbit.
         (SilentOrbitInspector.MatchDecompilableClasses(t) ||
          // Validate GoogleProtobuffer.
          GoogleCSInspector.MatchDecompilableClasses(t)
         );
 }
Ejemplo n.º 2
0
        public override void Decompile(out List <TypeDefinition> references)
        {
            // Create a new IRType to be filled in.
            if (IsEnum)
            {
                _constructedSubject = new IREnum(_subject.FullName, _subject.Name)
                {
                    Properties = new List <IREnumProperty>(),
                };
                // Extract the properties from this enum, local function.
                ExtractEnumProperties();

                // Enums have no references to other types.
                references = new List <TypeDefinition>();
            }
            else
            {
                var irClass = new IRClass(_subject.FullName, _subject.Name)
                {
                    PrivateTypes = new List <IRTypeNode>(),
                    Properties   = new List <IRClassProperty>(),
                };
                _constructedSubject = irClass;

                // Test for SilentOrbit decompilation.
                if (SilentOrbitInspector.MatchDecompilableClasses(_subject))
                {
                    DecompileClass_SilentOrbit(irClass, out references);
                }
                // Test for Google Protobuffer V1 decompilation.
                else if (GoogleV1Inspector.MatchDecompilableClasses(_subject))
                {
                    DecompileClass_GoogleV1(irClass, out references);
                }
                // Test for Google Protobuffer decompilation.
                else if (GoogleCSInspector.MatchDecompilableClasses(_subject))
                {
                    DecompileClass_Google(irClass, out references);
                }
                // Else fail..
                else
                {
                    throw new ExtractionException("Unrecognized proto compiler!");
                }
            }
        }