Permalink
Browse files

making some real progress slowly rebuilding project with new cassandr…

…a type system
  • Loading branch information...
1 parent 3dc09c6 commit f784bbc344939d7c9d2dd801e3318b4280295785 @nberardi nberardi committed Apr 29, 2010
@@ -49,6 +49,7 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
+ <Compile Include="FluentColumnTest.cs" />
<Compile Include="Types\AsciiTypeTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Types\UTF8TypeTest.cs" />
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using FluentCassandra.Types;
+
+namespace FluentCassandra.Test
+{
+ [TestClass]
+ public class FluentColumnTest
+ {
+ [TestMethod]
+ public void Constructor_Test()
+ {
+ // arrange
+ var nameExpected = "Test";
+ var valueExpected = 300.0;
+ var timestampExpected = DateTime.Today;
+
+ // act
+ var actual = new FluentColumn<AsciiType> {
+ Name = nameExpected,
+ Value = valueExpected
+ };
+
+ // assert
+ Assert.AreEqual(nameExpected, (string)actual.Name);
+ Assert.AreEqual(valueExpected, (double)actual.Value);
+ Assert.AreEqual(timestampExpected, actual.Timestamp.LocalDateTime.Date);
+ }
+ }
+}
@@ -52,9 +52,51 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Apache\Cassandra\AuthenticationException.cs" />
+ <Compile Include="Apache\Cassandra\AuthenticationRequest.cs" />
+ <Compile Include="Apache\Cassandra\AuthorizationException.cs" />
+ <Compile Include="Apache\Cassandra\Cassandra.cs" />
+ <Compile Include="Apache\Cassandra\Column.cs" />
+ <Compile Include="Apache\Cassandra\ColumnOrSuperColumn.cs" />
+ <Compile Include="Apache\Cassandra\ColumnParent.cs" />
+ <Compile Include="Apache\Cassandra\ColumnPath.cs" />
+ <Compile Include="Apache\Cassandra\ConsistencyLevel.cs" />
+ <Compile Include="Apache\Cassandra\Constants.cs" />
+ <Compile Include="Apache\Cassandra\Deletion.cs" />
+ <Compile Include="Apache\Cassandra\InvalidRequestException.cs" />
+ <Compile Include="Apache\Cassandra\KeyRange.cs" />
+ <Compile Include="Apache\Cassandra\KeySlice.cs" />
+ <Compile Include="Apache\Cassandra\Mutation.cs" />
+ <Compile Include="Apache\Cassandra\NotFoundException.cs" />
+ <Compile Include="Apache\Cassandra\SlicePredicate.cs" />
+ <Compile Include="Apache\Cassandra\SliceRange.cs" />
+ <Compile Include="Apache\Cassandra\SuperColumn.cs" />
+ <Compile Include="Apache\Cassandra\TimedOutException.cs" />
+ <Compile Include="Apache\Cassandra\TokenRange.cs" />
+ <Compile Include="Apache\Cassandra\UnavailableException.cs" />
+ <Compile Include="CassandraException.cs" />
+ <Compile Include="Configuration\CassandraConfiguration.cs" />
+ <Compile Include="Configuration\CassandraConfigurationContainer.cs" />
+ <Compile Include="Configuration\CassandraConfigurationMap.cs" />
+ <Compile Include="Configuration\CassandraTypeConfiguration.cs" />
+ <Compile Include="Configuration\ICassandraConfigurationMap.cs" />
+ <Compile Include="Configuration\IConfigurationContainer.cs" />
+ <Compile Include="Configuration\IKeyMapping.cs" />
+ <Compile Include="Configuration\IPropertyMapping.cs" />
+ <Compile Include="Configuration\ITypeConfiguration.cs" />
+ <Compile Include="Configuration\KeyMappingExpression.cs" />
+ <Compile Include="Configuration\PropertyMappingExpression.cs" />
+ <Compile Include="Connection\Connection.cs" />
+ <Compile Include="Connection\ConnectionBuilder.cs" />
+ <Compile Include="Connection\ConnectionProvider.cs" />
+ <Compile Include="Connection\IConnection.cs" />
+ <Compile Include="Connection\IConnectionProvider.cs" />
+ <Compile Include="Connection\NormalConnectionProvider.cs" />
+ <Compile Include="Connection\Server.cs" />
<Compile Include="FluentColumn.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="FluentColumnList`1.cs" />
<Compile Include="FluentColumnParent.cs">
<SubType>Code</SubType>
</Compile>
@@ -70,19 +112,54 @@
<Compile Include="FluentRecord.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="FluentSuperColumn.cs" />
<Compile Include="GuidGenerator.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IFluentBaseColumn.cs" />
<Compile Include="IFluentBaseColumn`1.cs" />
<Compile Include="IFluentSuperColumnFamily.cs" />
+ <Compile Include="Thrift\Collections\THashSet.cs" />
+ <Compile Include="Thrift\Protocol\TBase.cs" />
+ <Compile Include="Thrift\Protocol\TBinaryProtocol.cs" />
+ <Compile Include="Thrift\Protocol\TField.cs" />
+ <Compile Include="Thrift\Protocol\TList.cs" />
+ <Compile Include="Thrift\Protocol\TMap.cs" />
+ <Compile Include="Thrift\Protocol\TMessage.cs" />
+ <Compile Include="Thrift\Protocol\TMessageType.cs" />
+ <Compile Include="Thrift\Protocol\TProtocol.cs" />
+ <Compile Include="Thrift\Protocol\TProtocolException.cs" />
+ <Compile Include="Thrift\Protocol\TProtocolFactory.cs" />
+ <Compile Include="Thrift\Protocol\TProtocolUtil.cs" />
+ <Compile Include="Thrift\Protocol\TSet.cs" />
+ <Compile Include="Thrift\Protocol\TStruct.cs" />
+ <Compile Include="Thrift\Protocol\TType.cs" />
+ <Compile Include="Thrift\Server\TServer.cs" />
+ <Compile Include="Thrift\Server\TSimpleServer.cs" />
+ <Compile Include="Thrift\Server\TThreadedServer.cs" />
+ <Compile Include="Thrift\Server\TThreadPoolServer.cs" />
+ <Compile Include="Thrift\TApplicationException.cs" />
+ <Compile Include="Thrift\TProcessor.cs" />
+ <Compile Include="Thrift\Transport\TBufferedTransport.cs" />
+ <Compile Include="Thrift\Transport\TFramedTransport.cs" />
+ <Compile Include="Thrift\Transport\TServerSocket.cs" />
+ <Compile Include="Thrift\Transport\TServerTransport.cs" />
+ <Compile Include="Thrift\Transport\TSocket.cs" />
+ <Compile Include="Thrift\Transport\TStreamTransport.cs" />
+ <Compile Include="Thrift\Transport\TTransport.cs" />
+ <Compile Include="Thrift\Transport\TTransportException.cs" />
+ <Compile Include="Thrift\Transport\TTransportFactory.cs" />
<Compile Include="Types\AsciiType.cs" />
- <Compile Include="Types\BinaryConverter.cs" />
+ <Compile Include="Types\AsciiTypeConverter.cs" />
+ <Compile Include="Types\BytesTypeConverter.cs" />
<Compile Include="ColumnType.cs" />
<Compile Include="Types\BytesType.cs" />
<Compile Include="IFluentBaseColumnFamily.cs" />
<Compile Include="IFluentRecord.cs" />
<Compile Include="Types\CassandraType.cs" />
+ <Compile Include="Types\LexicalUUIDTypeConverter.cs" />
+ <Compile Include="Types\TimeUUIDTypeConverter.cs" />
+ <Compile Include="Types\UTF8TypeConverter.cs" />
<Compile Include="Types\LexicalUUIDType.cs" />
<Compile Include="IFluentColumn.cs" />
<Compile Include="IFluentColumnFamily`1.cs" />
@@ -96,7 +173,66 @@
<Compile Include="Types\TimeUUIDType.cs" />
<Compile Include="Types\UTF8Type.cs" />
</ItemGroup>
- <ItemGroup />
+ <ItemGroup>
+ <None Include="Thrift\Collections\.svn\all-wcprops" />
+ <None Include="Thrift\Collections\.svn\entries" />
+ <None Include="Thrift\Collections\.svn\text-base\THashSet.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\all-wcprops" />
+ <None Include="Thrift\Protocol\.svn\entries" />
+ <None Include="Thrift\Protocol\.svn\text-base\TBase.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TBinaryProtocol.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TField.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TList.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TMap.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TMessage.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TMessageType.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TProtocol.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TProtocolException.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TProtocolFactory.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TProtocolUtil.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TSet.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TStruct.cs.svn-base" />
+ <None Include="Thrift\Protocol\.svn\text-base\TType.cs.svn-base" />
+ <None Include="Thrift\Server\.svn\all-wcprops" />
+ <None Include="Thrift\Server\.svn\entries" />
+ <None Include="Thrift\Server\.svn\text-base\TServer.cs.svn-base" />
+ <None Include="Thrift\Server\.svn\text-base\TSimpleServer.cs.svn-base" />
+ <None Include="Thrift\Server\.svn\text-base\TThreadedServer.cs.svn-base" />
+ <None Include="Thrift\Server\.svn\text-base\TThreadPoolServer.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\all-wcprops" />
+ <None Include="Thrift\Transport\.svn\entries" />
+ <None Include="Thrift\Transport\.svn\text-base\TBufferedTransport.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TFramedTransport.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TServerSocket.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TServerTransport.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TSocket.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TStreamTransport.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TTransport.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TTransportException.cs.svn-base" />
+ <None Include="Thrift\Transport\.svn\text-base\TTransportFactory.cs.svn-base" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Thrift\Collections\.svn\prop-base\" />
+ <Folder Include="Thrift\Collections\.svn\props\" />
+ <Folder Include="Thrift\Collections\.svn\tmp\prop-base\" />
+ <Folder Include="Thrift\Collections\.svn\tmp\props\" />
+ <Folder Include="Thrift\Collections\.svn\tmp\text-base\" />
+ <Folder Include="Thrift\Protocol\.svn\prop-base\" />
+ <Folder Include="Thrift\Protocol\.svn\props\" />
+ <Folder Include="Thrift\Protocol\.svn\tmp\prop-base\" />
+ <Folder Include="Thrift\Protocol\.svn\tmp\props\" />
+ <Folder Include="Thrift\Protocol\.svn\tmp\text-base\" />
+ <Folder Include="Thrift\Server\.svn\prop-base\" />
+ <Folder Include="Thrift\Server\.svn\props\" />
+ <Folder Include="Thrift\Server\.svn\tmp\prop-base\" />
+ <Folder Include="Thrift\Server\.svn\tmp\props\" />
+ <Folder Include="Thrift\Server\.svn\tmp\text-base\" />
+ <Folder Include="Thrift\Transport\.svn\prop-base\" />
+ <Folder Include="Thrift\Transport\.svn\props\" />
+ <Folder Include="Thrift\Transport\.svn\tmp\prop-base\" />
+ <Folder Include="Thrift\Transport\.svn\tmp\props\" />
+ <Folder Include="Thrift\Transport\.svn\tmp\text-base\" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -10,12 +10,12 @@ namespace FluentCassandra
///
/// </summary>
/// <typeparam name="T"></typeparam>
- /// <seealso href="http://wiki.apache.org/cassandra/API"/>
public class FluentColumn<CompareWith> : IFluentColumn<CompareWith>
where CompareWith : CassandraType
{
private BytesType _value;
private FluentColumnParent _parent;
+ private IFluentColumnFamily<CompareWith> _family;
public FluentColumn()
{
@@ -47,12 +47,16 @@ public DateTimeOffset Timestamp
}
/// <summary>
- /// The column family.
+ ///
/// </summary>
public IFluentColumnFamily<CompareWith> Family
{
- get;
- internal set;
+ get { return _family; }
+ internal set
+ {
+ _family = value;
+ UpdateParent(GetParent());
+ }
}
/// <summary>
@@ -73,16 +77,6 @@ public FluentColumnParent GetParent()
return _parent;
}
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- string value = Value;
- return String.Format("{0}: {1}", Name, value);
- }
-
#region IFluentBaseColumn Members
CassandraType IFluentBaseColumn.Name { get { return Name; } }
@@ -93,6 +87,11 @@ public override string ToString()
/// <param name="parent"></param>
void IFluentBaseColumn.SetParent(FluentColumnParent parent)
{
+ UpdateParent(parent);
+ }
+
+ private void UpdateParent(FluentColumnParent parent)
+ {
_parent = parent;
}
@@ -7,7 +7,7 @@
namespace FluentCassandra
{
internal class FluentColumnList<T> : IList<T>
- where T : IFluentColumn
+ where T : IFluentBaseColumn
{
private List<T> _columns;
@@ -12,17 +12,14 @@ namespace FluentCassandra
/// </summary>
/// <typeparam name="T">A type that impliments <see cref="IFluentColumn"/>.</typeparam>
public abstract class FluentRecord<T> : DynamicObject, IFluentRecord, IFluentRecord<T>, INotifyPropertyChanged, IEnumerable<T>
- where T : IFluentBaseColumn, new()
+ where T : IFluentBaseColumn
{
- private Dictionary<object, Type> _memberHints;
-
/// <summary>
///
/// </summary>
public FluentRecord()
{
MutationTracker = new FluentMutationTracker(this);
- _memberHints = new Dictionary<object, Type>();
}
/// <summary>
@@ -31,14 +28,6 @@ public FluentRecord()
public abstract IList<T> Columns { get; }
/// <summary>
- /// Sets a hint at what a column members <see cref="Type"/> might be.
- /// </summary>
- public void SetHint(object member, Type hintType)
- {
- _memberHints[member] = hintType;
- }
-
- /// <summary>
///
/// </summary>
/// <param name="binder"></param>
@@ -69,16 +58,6 @@ public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out ob
/// <param name="result"></param>
/// <returns></returns>
public abstract bool TryGetColumn(object name, out object result);
- //{
- // var col = Columns.FirstOrDefault(c => c.Name == name);
-
- // Type hintType;
- // if (!_memberHints.TryGetValue(name, out hintType))
- // hintType = typeof(string);
-
- // result = (col == null) ? null : col.GetValue(hintType);
- // return col != null;
- //}
/// <summary>
///
@@ -111,33 +90,7 @@ public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object
/// <param name="value"></param>
/// <returns></returns>
public abstract bool TrySetColumn(object name, object value);
- //{
- // var col = Columns.FirstOrDefault(c => c.Name == name);
- // var mutationType = MutationType.Changed;
-
- // // if column doesn't exisit create it and add it to the columns
- // if (col == null)
- // {
- // mutationType = MutationType.Added;
-
- // col = new T();
- // col.Name = name;
-
- // Columns.Add(col);
- // }
-
- // // set the column value
- // col.SetValue(value);
-
- // // notify the tracker that the column has changed
- // OnColumnMutated(mutationType, col);
-
- // // declare the hint for the member
- // if (value != null)
- // SetHint(name, value.GetType());
- // return true;
- //}
#region IEnumerable<T> Members
Oops, something went wrong.

0 comments on commit f784bbc

Please sign in to comment.