Пример #1
0
        protected override void ScanCore(MemberImportingOptions options, List <MemberImporter> importList)
        {
            //Event
            var originalEvt = (EventDefinition)Member;

            evtClone = originalEvt.Clone(Session);

            //Registers importing of custom attributes
            if (evtClone.HasCustomAttributes)
            {
                importList.Add(new CustomAttributesImporter(evtClone, evtClone, Session).Scan(options));
                evtClone.CustomAttributes.Clear();
            }

            //Registers importing of add, remove and invoke methods
            if (originalEvt.AddMethod != null)
            {
                var importer = new MethodImporter(originalEvt.AddMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var add = (MethodDefinition)m;
                    add.IsAddOn        = true;
                    evtClone.AddMethod = add;
                };
                importList.Add(importer);
            }
            if (originalEvt.RemoveMethod != null)
            {
                var importer = new MethodImporter(originalEvt.RemoveMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var remove = (MethodDefinition)m;
                    remove.IsRemoveOn     = true;
                    evtClone.RemoveMethod = remove;
                };
                importList.Add(importer);
            }
            if (originalEvt.InvokeMethod != null)
            {
                var importer = new MethodImporter(originalEvt.InvokeMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var invoke = (MethodDefinition)m;
                    invoke.IsFire         = true;
                    evtClone.InvokeMethod = invoke;
                };
                importList.Add(importer);
            }

            //Imports other methods
            if (originalEvt.HasOtherMethods)
            {
                foreach (var m in originalEvt.OtherMethods)
                {
                    var importer = new MethodImporter(m, Destination, Session, false).Scan(options);
                    importer.ImportFinished += x =>
                    {
                        var method = (MethodDefinition)x;
                        method.IsOther = true;
                        evtClone.OtherMethods.Add(method);
                    };
                    importList.Add(importer);
                }
            }
        }
Пример #2
0
        protected override void ScanCore(MemberImportingOptions options, List<MemberImporter> importList)
        {
            //Event
            var originalEvt = (EventDefinition)Member;
            evtClone = originalEvt.Clone(Session);

            //Registers importing of custom attributes
            if (evtClone.HasCustomAttributes)
            {
                importList.Add(new CustomAttributesImporter(evtClone, evtClone, Session).Scan(options));
                evtClone.CustomAttributes.Clear();
            }

            //Registers importing of add, remove and invoke methods
            if (originalEvt.AddMethod != null)
            {
                var importer = new MethodImporter(originalEvt.AddMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var add = (MethodDefinition)m;
                    add.IsAddOn = true;
                    evtClone.AddMethod = add;
                };
                importList.Add(importer);
            }
            if (originalEvt.RemoveMethod != null)
            {
                var importer = new MethodImporter(originalEvt.RemoveMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var remove = (MethodDefinition)m;
                    remove.IsRemoveOn = true;
                    evtClone.RemoveMethod = remove;
                };
                importList.Add(importer);
            }
            if (originalEvt.InvokeMethod != null)
            {
                var importer = new MethodImporter(originalEvt.InvokeMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var invoke = (MethodDefinition)m;
                    invoke.IsFire = true;
                    evtClone.InvokeMethod = invoke;
                };
                importList.Add(importer);
            }

            //Imports other methods
            if (originalEvt.HasOtherMethods)
            {
                foreach (var m in originalEvt.OtherMethods)
                {
                    var importer = new MethodImporter(m, Destination, Session, false).Scan(options);
                    importer.ImportFinished += x =>
                    {
                        var method = (MethodDefinition)x;
                        method.IsOther = true;
                        evtClone.OtherMethods.Add(method);
                    };
                    importList.Add(importer);
                }
            }
        }
Пример #3
0
        protected override void ScanCore(MemberImportingOptions options, List <MemberImporter> importList)
        {
            //Property
            var originalProp = (PropertyDefinition)Member;

            propClone = originalProp.Clone(Session);

            //Registers importing of custom attributes
            if (propClone.HasCustomAttributes)
            {
                importList.Add(new CustomAttributesImporter(propClone, propClone, Session).Scan(options));
                propClone.CustomAttributes.Clear();
            }

            //Registers importing of get and set methods
            if (propClone.GetMethod != null)
            {
                var importer = new MethodImporter(propClone.GetMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m => {
                    var get = (MethodDefinition)m;
                    get.IsGetter        = true;
                    propClone.GetMethod = get;
                };
                importList.Add(importer);
            }
            if (propClone.SetMethod != null)
            {
                var importer = new MethodImporter(propClone.SetMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var set = (MethodDefinition)m;
                    set.IsSetter        = true;
                    propClone.SetMethod = set;
                };
                importList.Add(importer);
            }

            //Imports other methods
            if (originalProp.HasOtherMethods)
            {
                foreach (var m in originalProp.OtherMethods)
                {
                    var importer = new MethodImporter(m, Destination, Session, false).Scan(options);
                    importer.ImportFinished += x => {
                        var method = (MethodDefinition)x;
                        method.IsOther = true;
                        propClone.OtherMethods.Add(method);
                    };
                    importList.Add(importer);
                }
            }

            //Imports the parameters
            foreach (var p in originalProp.Parameters)
            {
                //Creates a new parameter
                var param = new ParameterDefinition(p.Name, p.Attributes, p.ParameterType)
                {
                    Constant      = p.Constant,
                    MarshalInfo   = p.MarshalInfo,
                    MetadataToken = new MetadataToken(p.MetadataToken.TokenType, GlobalContainer.GetFreeRID(Session.DestinationModule))
                };
                propClone.Parameters.Add(param);

                //Queues importing of custom attributes
                if (p.HasCustomAttributes)
                {
                    importList.Add(new CustomAttributesImporter(p, param, Session).Scan(options));
                    param.CustomAttributes.Clear();
                }

                //Queues importing of type
                var typeImporter = Helpers.CreateTypeImporter(p.ParameterType, Session, importList, options);
                typeImporter.ImportFinished += t => param.ParameterType = (TypeReference)t;
            }
        }
Пример #4
0
        protected override void ScanCore(MemberImportingOptions options, List<MemberImporter> importList)
        {
            //Property
            var originalProp = (PropertyDefinition)Member;
            propClone = originalProp.Clone(Session);
         
            //Registers importing of custom attributes
            if (propClone.HasCustomAttributes)
            {
                importList.Add(new CustomAttributesImporter(propClone, propClone, Session).Scan(options));
                propClone.CustomAttributes.Clear();
            }

            //Registers importing of get and set methods
            if (propClone.GetMethod != null)
            {
                var importer = new MethodImporter(propClone.GetMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m => {
                    var get = (MethodDefinition)m;
                    get.IsGetter = true;
                    propClone.GetMethod = get; 
                };
                importList.Add(importer);
            }
            if (propClone.SetMethod != null)
            {
                var importer = new MethodImporter(propClone.SetMethod, Destination, Session, false).Scan(options);
                importer.ImportFinished += m =>
                {
                    var set = (MethodDefinition)m;
                    set.IsSetter = true;
                    propClone.SetMethod = set;
                };
                importList.Add(importer);
            }

            //Imports other methods
            if (originalProp.HasOtherMethods)
            {
                foreach (var m in originalProp.OtherMethods)
                {
                    var importer = new MethodImporter(m, Destination, Session, false).Scan(options);
                    importer.ImportFinished += x => {
                        var method = (MethodDefinition)x;
                        method.IsOther = true;
                        propClone.OtherMethods.Add(method);
                    };
                    importList.Add(importer);
                }
            }

            //Imports the parameters
            foreach (var p in originalProp.Parameters)
            {
                //Creates a new parameter
                var param = new ParameterDefinition(p.Name, p.Attributes, p.ParameterType)
                {
                    Constant = p.Constant,
                    MarshalInfo = p.MarshalInfo,
                    MetadataToken = new MetadataToken(p.MetadataToken.TokenType, GlobalContainer.GetFreeRID(Session.DestinationModule))
                };
                propClone.Parameters.Add(param);

                //Queues importing of custom attributes
                if (p.HasCustomAttributes)
                {
                    importList.Add(new CustomAttributesImporter(p, param, Session).Scan(options));
                    param.CustomAttributes.Clear();
                }

                //Queues importing of type
                var typeImporter = Helpers.CreateTypeImporter(p.ParameterType, Session, importList, options);
                typeImporter.ImportFinished += t => param.ParameterType = (TypeReference)t;
            }

        }