/// <summary>
        /// Tries to find a disassembled entity, given a disassembled target.
        /// </summary>
        /// <param name="disassemblyTarget">The disassembly target.</param>
        /// <returns></returns>
        public DisassembledEntity FindDisassembledEntity(DisassemblyTarget disassemblyTarget)
        {
            //  If there's no target, we can't find anything.
            if (disassemblyTarget == null)
            {
                return(null);
            }

            switch (disassemblyTarget.TargetType)
            {
            case DisassemblyTargetType.Class:

                //  Find the class with the given name.
                return(AllClasses.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Enumeration:

                //  Find the enumeration with the given name.
                return(AllEnumerations.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Method:

                //  Find the entity with the given name.
                return(AllMethods.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Property:

                //  Find the entity with the given name.
                return(AllProperties.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Field:

                //  Find the entity with the given name.
                return(AllFields.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Structure:

                //  Find the structure with the given name.
                return(AllStructures.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Interface:

                //  Find the structure with the given name.
                return(AllInterfaces.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Event:

                //  Find the structure with the given name.
                return(AllEvents.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));

            case DisassemblyTargetType.Delegate:

                //  Find the structure with the given name.
                return(AllDelegates.FirstOrDefault(c => c.FullName == disassemblyTarget.FullName));


            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #2
0
        public Class FindClassByType(TypeInfo type)
        {
            var allClasses = string.Join("'", AllClasses.Select(c => c.ClassName));

            return(AllClasses.FirstOrDefault(c => c.ClassName == type.Name + ".cs"));
        }