[hyena] Clean up, make Sample subclassable
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] Clean up, make Sample subclassable
- Date: Wed, 26 May 2010 02:35:11 +0000 (UTC)
commit 1684bec802e1ce56407a73d83d96076fbe9df928
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu Feb 18 17:55:24 2010 -0800
Clean up, make Sample subclassable
src/Hyena/Hyena.Metrics/MetricsCollection.cs | 6 +++---
src/Hyena/Hyena.Metrics/Sample.cs | 6 +++++-
src/Hyena/Makefile.am | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/Hyena/Hyena.Metrics/MetricsCollection.cs b/src/Hyena/Hyena.Metrics/MetricsCollection.cs
index 5b649cd..a421ece 100644
--- a/src/Hyena/Hyena.Metrics/MetricsCollection.cs
+++ b/src/Hyena/Hyena.Metrics/MetricsCollection.cs
@@ -37,6 +37,8 @@ namespace Hyena.Metrics
{
public sealed class MetricsCollection : List<Metric>, IDisposable
{
+ public static readonly int FormatVersion = 1;
+
public string AnonymousUserId { get; private set; }
public ISampleStore Store { get; private set; }
@@ -75,15 +77,13 @@ namespace Hyena.Metrics
Clear ();
}
- const int CUR_FMT_VERSION = 1;
-
public string ToJsonString ()
{
var report = new Dictionary<string, object> ();
report["ID"] = AnonymousUserId;
report["Now"] = DateTimeUtil.ToInvariantString (DateTime.Now);
- report["FormatVersion"] = CUR_FMT_VERSION;
+ report["FormatVersion"] = FormatVersion;
var metrics = new Dictionary<string, object> ();
foreach (var metric in this.OrderBy (m => m.Name)) {
diff --git a/src/Hyena/Hyena.Metrics/Sample.cs b/src/Hyena/Hyena.Metrics/Sample.cs
index fca35df..ceb6e27 100644
--- a/src/Hyena/Hyena.Metrics/Sample.cs
+++ b/src/Hyena/Hyena.Metrics/Sample.cs
@@ -32,7 +32,7 @@ namespace Hyena.Metrics
public class Sample
{
[DatabaseColumn (Constraints = DatabaseColumnConstraints.PrimaryKey)]
- private long Id { get; set; }
+ protected long Id { get; set; }
[DatabaseColumn]
public string MetricName { get; protected set; }
@@ -50,7 +50,11 @@ namespace Hyena.Metrics
{
MetricName = metric.Name;
Stamp = DateTime.Now;
+ SetValue (value);
+ }
+ protected void SetValue (object value)
+ {
if (value == null) {
Value = "";
} else if (value is DateTime) {
diff --git a/src/Hyena/Makefile.am b/src/Hyena/Makefile.am
index 05a3812..f631f9f 100644
--- a/src/Hyena/Makefile.am
+++ b/src/Hyena/Makefile.am
@@ -90,6 +90,7 @@ SOURCES = \
Hyena.Json/Tokenizer.cs \
Hyena.Json/Token.cs \
Hyena.Json/JsonObject.cs \
+ Hyena.Json/Serializer.cs \
Hyena.Json/JsonArray.cs \
Hyena.Json/Tests/TokenizerTests.cs \
Hyena.Json/TokenType.cs \
@@ -102,7 +103,6 @@ SOURCES = \
Hyena.Metrics/Sample.cs \
Hyena.Metrics/Tests/MetricsTests.cs \
Hyena.Json/Deserializer.cs \
- Hyena.Json/Serializer.cs \
Hyena.Json/Tests/SerializerTests.cs \
Hyena.Json/IJsonCollection.cs \
Hyena.Json/Tests/DeserializerTests.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]