Esempio n. 1
0
        public static TypeDefinition CreateWrapper(TypeDefinition baseType, ModuleDefinition module, IReadOnlyList <IExposedProperty> properties)
        {
            TypeDefinition wrapper = baseType.AddNestedType($"ALE__GENERATED__{baseType.Name}ComponentWrapper",
                                                            TypeAttributes.NestedPublic | TypeAttributes.SequentialLayout | TypeAttributes.AnsiClass | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit,
                                                            module.GetTypeReference <ValueType>());

            wrapper.AddInterface <IExposedWrapper>();

            PropertyDefinition valuesProperty = CreateProperty <Dictionary <int, object> >(wrapper, module, "Values");

            CreateProperty <Dictionary <int, bool> >(wrapper, module, "Dirty");

            CreateSerializeMethod(wrapper, module, valuesProperty, properties);
            CreateDeserializeMethod(wrapper, module, properties);

            return(wrapper);
        }