示例#1
0
        public EmitTranslator(AppDomain hostDomain, string name)
        {
            AssemblyName asmName = new AssemblyName(name);
            m_assembly = hostDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);

            m_module = m_assembly.DefineDynamicModule(name + ".exe", true);
            m_typeTable = new ExtensionTable<Type>();
            m_methodTable = new ExtensionTable<MethodInfo>();
            m_ctorTable = new ExtensionTable<ConstructorInfo>();
            m_fieldTable = new ExtensionTable<FieldInfo>();
        }
示例#2
0
        public EmitTranslator(AppDomain hostDomain, string name)
        {
            AssemblyName asmName = new AssemblyName(name);

            m_assembly = hostDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);

            m_module      = m_assembly.DefineDynamicModule(name + ".exe", true);
            m_typeTable   = new ExtensionTable <Type>();
            m_methodTable = new ExtensionTable <MethodInfo>();
            m_ctorTable   = new ExtensionTable <ConstructorInfo>();
            m_fieldTable  = new ExtensionTable <FieldInfo>();
        }
示例#3
0
    private void FacadeTest <TUnderlyingType, TType, TConverter>(
        TUnderlyingType underlyingValue,
        TType value,
        TypeModelContainer container = null) where TConverter : struct, ITypeFacadeConverter <TUnderlyingType, TType>
    {
        if (container == null)
        {
            container = TypeModelContainer.CreateDefault();
            container.RegisterTypeFacade <TUnderlyingType, TType, TConverter>();
        }

        FlatBufferSerializer serializer = new FlatBufferSerializer(
            new FlatBufferSerializerOptions(FlatBufferDeserializationOption.Greedy),
            container);

        byte[] destination  = new byte[1024];
        byte[] destination2 = new byte[1024];

        var compiled = serializer.Compile <ExtensionTable <TType> >();

        var underlyingItem = new ExtensionTable <TUnderlyingType> {
            Item = underlyingValue
        };
        var facadeItem = new ExtensionTable <TType> {
            Item = value
        };

        serializer.Serialize(facadeItem, destination);
        serializer.Serialize(underlyingItem, destination2);

        Assert.True(destination.AsSpan().SequenceEqual(destination2));

        var parsed = serializer.Parse <ExtensionTable <TType> >(destination);

        Assert.Equal(parsed.Item, value);
        Assert.Equal(serializer.GetMaxSize(facadeItem), serializer.GetMaxSize(underlyingItem));
    }
示例#4
0
 public override Unit Get(Unit p_key)
 {
     return(ExtensionTable.Get(p_key));
 }