Esempio n. 1
0
        private void InitializeOwnerType(AssemblyDefinitionEditor ade, TypeDefinitionEditor tde)
        {
            IHandler handler = PluginFactory.GetInstance().Package.ActiveHandler;

            if (handler != null)
            {
                object current = handler.TargetObject;
                if (current is AssemblyDefinition)
                {
                    OwnerType.SelectedItem = ade;
                    ade.SelectedOperand    = current as AssemblyDefinition;
                }
                else if (current is ModuleDefinition)
                {
                    OwnerType.SelectedItem = ade;
                    ade.SelectedOperand    = (current as ModuleDefinition).Assembly;
                }
                else if (current is TypeDefinition)
                {
                    OwnerType.SelectedItem = tde;
                    tde.SelectedOperand    = current as TypeDefinition;
                }
                else if (current is MemberReference)
                {
                    MemberReference mref = current as MemberReference;
                    if (mref.DeclaringType is TypeDefinition)
                    {
                        OwnerType.SelectedItem = tde;
                        tde.SelectedOperand    = mref.DeclaringType as TypeDefinition;
                    }
                }
            }
        }
Esempio n. 2
0
        public InjectForm()
        {
            InitializeComponent();
            _mappings           = new Dictionary <object, InjectType[]>();
            _extraTypeSupported = new List <InjectType>();
            _extraTypeSupported.AddRange(new[]
            {
                InjectType.Class,
                InjectType.Property,
                InjectType.Field,
                InjectType.Event,
                InjectType.Resource
            });

            var ade      = new AssemblyDefinitionEditor();
            var adetypes = new[]
            {
                InjectType.Class,
                InjectType.Interface,
                InjectType.Struct,
                InjectType.Enum,
                InjectType.AssemblyReference,
                InjectType.Resource
            };

            _mappings.Add(ade, adetypes);
            OwnerType.Items.Add(ade);

            var tde      = new TypeDefinitionEditor();
            var tdetypes = new[]
            {
                InjectType.Class,
                InjectType.Interface,
                InjectType.Struct,
                InjectType.Enum,
                InjectType.Constructor,
                InjectType.Method,
                InjectType.Property,
                InjectType.Field,
                InjectType.Event
            };

            _mappings.Add(tde, tdetypes);
            OwnerType.Items.Add(tde);

            InitializeOwnerType(ade, tde);
        }