Exemplo n.º 1
0
        public static ValueMarshaller GetMarshaller(Type type)
        {
            ValueMarshaller marshaller = null;

            lock (marshallers) {
                if (marshallers.ContainsKey(type))
                {
                    return(marshallers[type]);
                }

                var typeInfo = type.GetTypeInfo();

                if (typeInfo.IsSubclassOf(typeof(ValueType)))
                {
                    marshaller = new SimpleValueMarshaller(type);
                }

                if (typeInfo.IsInterface &&
                    typeof(IUnknown).GetTypeInfo().IsAssignableFrom(typeInfo))
                {
                    marshaller = new InterfaceValueMarshaller(type);
                }

                if (marshaller != null)
                {
                    marshallers.Add(type, marshaller);
                }
                else
                {
                    throw new InvalidOperationException($"Don't know how to marshal {type.FullName}");
                }
            }

            return(marshaller);
        }
Exemplo n.º 2
0
 public ToRuntimeGenerator(ILGenerator generator, InterfaceValueMarshaller parent)
 {
     this.generator = generator;
     this.parent    = parent;
 }