コード例 #1
0
 void InitHelpers()
 {
     _baseRefs  = new BaseRefs(ModuleDefinition);
     _helper    = new ModuleHelper(ModuleDefinition, _baseRefs);
     _anchor    = new Anchor(ModuleDefinition, _helper, _baseRefs);
     _attribute = new AnchorAttribute(ModuleDefinition, _helper, _baseRefs);
     _tie       = new Tie(ModuleDefinition, _helper, _baseRefs);
 }
コード例 #2
0
    void BuildAttributeEntity(TypeDefinition db, PropertyDefinition dbProperty, TypeDefinition anchorEntityType, PropertyDefinition prop)
    {
        var isHistorical = IsHistorical(prop);

        var anchorAttrSig = AnchorAttribute.GetName(isHistorical, dbProperty.Name, prop.Name);

        var anchorAttributeEntityType = _attribute.Create(db, anchorAttrSig, prop, isHistorical, anchorEntityType);

        ModuleDefinition.Types.Add(anchorAttributeEntityType);

        var anchAttrAttr = new CustomAttribute(_baseRefs.AttributeTypeAttributeRef);

        anchAttrAttr.ConstructorArguments.Add(new CustomAttributeArgument(_baseRefs.StringReference, anchorAttributeEntityType.Name));
        prop.CustomAttributes.Add(anchAttrAttr);

        var entityAttrDbSetType = new GenericInstanceType(ModuleDefinition.ImportReference(typeof(DbSet <>)));

        entityAttrDbSetType.GenericArguments.Add(anchorAttributeEntityType);

        _helper.CreateProperty(db, entityAttrDbSetType, anchorAttrSig);

        LogMessage($"Make attribute: {anchorAttrSig}", MessageImportance.High);
    }