示例#1
0
        IObjectSerializer <T> ConstructBTreeNodeSerializer <T>()
        {
            var      genericTypes = typeof(T).GenericTypeArguments;
            TypeInfo typeInfo;

            if (BTreeNodeBinaryFormatterSerializer.CanSerialize(typeof(T)))
            {
                typeInfo = typeof(BTreeNodeBinaryFormatterSerializer <>).GetTypeInfo();
            }
            else
            {
                typeInfo = typeof(BTreeNodeBsonSerializer <>).GetTypeInfo();
            }

            var genericType = typeInfo.MakeGenericType(genericTypes);

            return((IObjectSerializer <T>)Activator.CreateInstance(genericType));
        }
        IObjectSerializer <T> ConstructBTreeNodeSerializer <T>()
        {
            var      genericTypes = typeof(T).GenericTypeArguments;
            TypeInfo typeInfo;

            if (BTreeNodeBinaryFormatterSerializer.CanSerialize(typeof(T)))
            {
                typeInfo = typeof(BTreeNodeBinaryFormatterSerializer <>).GetTypeInfo();
            }
            else
            {
                typeInfo = typeof(BTreeNodeBsonSerializer <>).GetTypeInfo();
            }

            var genericType = typeInfo.MakeGenericType(genericTypes);

            var constructor = genericType.GetTypeInfo().DeclaredConstructors.First();

            return((IObjectSerializer <T>)constructor.Invoke(new object[0]));
        }