예제 #1
0
    public MarshallingRegistry(Ioc ioc)
    {
        this.ioc = ioc ?? throw new ArgumentNullException(nameof(ioc));

        ValueTypeMarshaller valueTypeMarshaller = new(ioc);

        Marshallers = new List <IMarshaller>
        {
            new InterfaceArrayMarshaller(ioc),
            new ArrayOfInterfaceMarshaller(ioc),
            new BoolToIntArrayMarshaller(ioc),
            new BoolToIntMarshaller(ioc),
            new InterfaceMarshaller(ioc),
            new PointerSizeMarshaller(ioc),
            new StringMarshaller(ioc),
            new RemappedTypeMarshaller(ioc),
            new StructWithNativeTypeMarshaller(ioc),
            new StructWithNativeTypeArrayMarshaller(ioc),
            new NullableInstanceMarshaller(ioc),
            new BitfieldMarshaller(ioc),
            new ValueTypeArrayMarshaller(ioc),
            new FallbackFieldMarshaller(ioc),
            valueTypeMarshaller
        };
        RefWrappingMarshallers = Marshallers.Select(x => new RefWrapperMarshaller(ioc, x)).ToArray();
        EnumWrappingMarshaller = new EnumParameterWrapperMarshaller(ioc, valueTypeMarshaller);
        RelationMarshallers    = new Dictionary <Type, IRelationMarshaller>
        {
            [typeof(StructSizeRelation)]    = new StructSizeRelationMarshaller(ioc),
            [typeof(LengthRelation)]        = new LengthRelationMarshaller(ioc),
            [typeof(ConstantValueRelation)] = new ConstantValueRelationMarshaller(ioc)
        };
    }
예제 #2
0
 private IEnumerable <IMarshaller> GetMarshallers(CsMarshalBase csElement)
 {
     if (RefWrapperMarshaller.IsApplicable(csElement))
     {
         return(RefWrappingMarshallers);
     }
     if (EnumParameterWrapperMarshaller.IsApplicable(csElement))
     {
         return(Marshallers.Prepend(EnumWrappingMarshaller));
     }
     return(Marshallers);
 }