コード例 #1
0
        public ColumnRetriever TryGet(PropertyInfo propertyInfo)
        {
            var protoContract = propertyInfo.PropertyType.GetCustomAttribute <ProtoContractAttribute>();

            if (protoContract != null)
            {
                var converterType = typeof(ProtoBufferConverter <>).MakeGenericType(propertyInfo.PropertyType);
                var converter     = (TypeConverter)Activator.CreateInstance(converterType);

                var binaryConverter = new BinaryConverter(converter);

                var column = TableColumn.Blob(propertyInfo.Name,
                                              TableColumn.HasSqlNotNull(propertyInfo),
                                              TableColumn.HasSqlPrimaryKey(propertyInfo));

                return(new ColumnRetriever(propertyInfo, column, binaryConverter, false));
            }

            return(null);
        }
コード例 #2
0
        public ColumnRetriever TryGet(PropertyInfo propertyInfo)
        {
            TypeConverter converter = TryGetConverter(propertyInfo);

            if (converter == null)
            {
                return(null);
            }

            bool requiresEscape = true;
            var  column         = TableColumn.VariableText(propertyInfo.Name,
                                                           TableColumn.HasSqlNotNull(propertyInfo),
                                                           TableColumn.HasSqlPrimaryKey(propertyInfo));

            if (converter is BinaryConverter)
            {
                requiresEscape = false;
                column         = TableColumn.Blob(propertyInfo.Name,
                                                  TableColumn.HasSqlNotNull(propertyInfo),
                                                  TableColumn.HasSqlPrimaryKey(propertyInfo));
            }

            return(new ColumnRetriever(propertyInfo, column, converter, requiresEscape));
        }