Пример #1
0
        public BaseClassTypeDefs(TypeDefinition type)
        {
            if (type.BaseType.Name != "EventSource")
            {
                throw new InvalidOperationException("Base type must be EventSource");
            }

            var ns     = type.BaseType.Namespace + ".";
            var module = type.Module;

            BaseTypeRef  = type.BaseType;
            BaseTypeImpl = type.BaseType.Resolve();

            var sourceModule = BaseTypeImpl.Module;

            EventLevel    = sourceModule.FindType(ns + "EventLevel").ImportInto(module);
            EventKeywords = sourceModule.FindType(ns + "EventKeywords").ImportInto(module);
            EventOpcode   = sourceModule.FindType(ns + "EventOpcode").ImportInto(module);
            EventTask     = sourceModule.FindType(ns + "EventTask").ImportInto(module);

            EventSourceAttribute = sourceModule.FindType(ns + "EventSourceAttribute").ImportInto(module);
            EventAttribute       = sourceModule.FindType(ns + "EventAttribute").ImportInto(module);
            NonEventAttribute    = sourceModule.FindType(ns + "NonEventAttribute").ImportInto(module);

            IsEnabledSpecific  = BaseTypeImpl.FindMethod("IsEnabled", EventLevel, EventKeywords).ImportInto(module);
            IsEnabledFallback  = BaseTypeImpl.FindMethod("IsEnabled").ImportInto(module);
            WriteEventFallback = BaseTypeImpl.FindMethod("WriteEvent", module.TypeSystem.Int32, module.ImportReference(typeof(object[]))).ImportInto(module);
            WriteEventCore     = BaseTypeImpl.Methods.Named("WriteEventCore").ImportInto(module);

            EventDataRef            = BaseTypeImpl.NestedTypes.Named("EventData").ImportInto(module);
            EventDataImpl           = EventDataRef.Resolve();
            EventDataSetDataPointer = EventDataImpl.Properties.Named("DataPointer").SetMethod.ImportInto(module);
            EventDataSetSize        = EventDataImpl.Properties.Named("Size").SetMethod.ImportInto(module);
        }
Пример #2
0
        public GuessingTypeDefs(ModuleDefinition module)
        {
            BaseTypeRef  = GuessBaseType(module).ImportInto(module);
            BaseTypeImpl = BaseTypeRef.Resolve();

            var sourceModule = BaseTypeImpl.Module;

            EventLevel           = ImportOne(module, sourceModule, "EventLevel", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            EventKeywords        = ImportOne(module, sourceModule, "EventKeywords", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            EventOpcode          = ImportOne(module, sourceModule, "EventOpcode", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            EventTask            = ImportOne(module, sourceModule, "EventTask", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            EventSourceAttribute = ImportOne(module, sourceModule, "EventSourceAttribute", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            EventAttribute       = ImportOne(module, sourceModule, "EventAttribute", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");
            NonEventAttribute    = ImportOne(module, sourceModule, "NonEventAttribute", "Microsoft.Diagnostics.Tracing", "System.Diagnostics.Tracing");

            IsEnabledSpecific  = BaseTypeImpl.FindMethod("IsEnabled", EventLevel, EventKeywords).ImportInto(module);
            IsEnabledFallback  = BaseTypeImpl.FindMethod("IsEnabled").ImportInto(module);
            WriteEventFallback = BaseTypeImpl.FindMethod("WriteEvent", module.TypeSystem.Int32, module.ImportReference(typeof(object[]))).ImportInto(module);
            WriteEventCore     = BaseTypeImpl.Methods.First(m => m.Name == "WriteEventCore").ImportInto(module);

            EventDataRef            = BaseTypeImpl.NestedTypes.First(t => t.Name == "EventData").ImportInto(module);
            EventDataImpl           = EventDataRef.Resolve();
            EventDataSetDataPointer = EventDataImpl.Properties.Named("DataPointer").SetMethod.ImportInto(module);
            EventDataSetSize        = EventDataImpl.Properties.Named("Size").SetMethod.ImportInto(module);
        }