Esempio n. 1
0
        protected void AddConst <T>(TypeDefinition target, TypeReference type, NamedConst <T> c)
        {
            var field = new FieldDefinition(c.Name, FieldAttributes.FamANDAssem | FieldAttributes.Family | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault, type)
            {
                Constant = c.Value
            };

            target.Fields.Add(field);
        }
Esempio n. 2
0
        public TraceMethod(MethodDefinition method, CustomAttribute a, bool isEmpty = true)
        {
            Method         = method;
            IsEmpty        = isEmpty;
            EventAttribute = a;
            if (a == null)
            {
                return;
            }

            Id       = (int)a.ConstructorArguments[0].Value;
            Level    = TraceMethod.GetProp <EventLevel, EventLevel?>(a, "Level", v => v);
            Keywords = TraceMethod.GetProp <EventKeywords, EventKeywords?>(a, "Keywords", v => v);
            Task     = TraceMethod.GetProp <EventTask, NamedConst <int> >(a, "Task", v => NamedConst.Existing(v.ToString(), (int)v));
            Opcode   = TraceMethod.GetProp <EventOpcode, NamedConst <int> >(a, "Opcode", v => NamedConst.Existing(v.ToString(), (int)v));

            if (Task != null)
            {
                log.Trace($"{method} {Task.Name}={Task.Value} - exists: {Task.Exists}");
            }
            if (Opcode != null)
            {
                log.Trace($"{method} {Opcode.Name}={Opcode.Value} - exists: {Opcode.Exists}");
            }
        }