forked from speckleworks/SpeckleCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request speckleworks#90 from speckleworks/Dimitrie/dev/loc…
…aldb-sqlite Dimitrie/dev/localdb sqlite
- Loading branch information
Showing
12 changed files
with
848 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using SQLite; | ||
|
||
namespace SpeckleCore | ||
{ | ||
/// <summary> | ||
/// A class for a generic speckle account, composed of all the identification props for a user & server combination. | ||
/// </summary> | ||
public class Account | ||
{ | ||
[PrimaryKey, AutoIncrement] | ||
public int AccountId { get; set; } | ||
|
||
public string ServerName { get; set; } | ||
|
||
[Indexed] | ||
public string RestApi { get; set; } | ||
|
||
[Indexed] | ||
public string Email { get; set; } | ||
|
||
public string Token { get; set; } | ||
|
||
public bool IsDefault { get; set; } = false; | ||
} | ||
|
||
/// <summary> | ||
/// Special class for efficiently storing sent objects. Why? We do not want to store them fully as they are already stored in the users's file. Kind of duplicates the CachedObject. | ||
/// </summary> | ||
public class SentObject | ||
{ | ||
/// <summary> | ||
/// Represents the api this object came from | ||
/// </summary> | ||
[Indexed] | ||
public string RestApi { get; set; } | ||
|
||
[Indexed] | ||
public string DatabaseId { get; set; } | ||
|
||
[Indexed] | ||
public string Hash { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// A class for storing cached objects (that have been retrieved from a database). | ||
/// </summary> | ||
public class CachedObject | ||
{ | ||
/// <summary> | ||
/// Represents hash(databaseId + restApi) | ||
/// </summary> | ||
[PrimaryKey, Indexed( Unique = true )] | ||
public string CombinedHash { get; set; } | ||
|
||
/// <summary> | ||
/// Represents the api this object came from | ||
/// </summary> | ||
[Indexed] | ||
public string RestApi { get; set; } | ||
|
||
[Indexed] | ||
public string DatabaseId { get; set; } | ||
|
||
[Indexed] | ||
public string Hash { get; set; } | ||
|
||
public DateTime AddedOn {get;set;} | ||
|
||
public byte[ ] Bytes { get; set; } | ||
|
||
/// <summary> | ||
/// Returns the speckle object from cache. | ||
/// </summary> | ||
/// <returns></returns> | ||
public SpeckleObject ToSpeckle( ) | ||
{ | ||
return SpeckleCore.Converter.getObjFromBytes( this.Bytes ) as SpeckleObject; | ||
} | ||
} | ||
|
||
public class CachedStream | ||
{ | ||
/// <summary> | ||
/// Represents hash(streamId + restApi) | ||
/// </summary> | ||
[PrimaryKey, Indexed( Unique = true )] | ||
public string CombinedHash { get; set; } | ||
|
||
/// <summary> | ||
/// Represents the api this object came from | ||
/// </summary> | ||
[Indexed] | ||
public string RestApi { get; set; } | ||
|
||
[Indexed] | ||
public string StreamId { get; set; } | ||
|
||
public DateTime AddedOn { get; set; } | ||
|
||
public DateTime UpdatedOn { get; set; } | ||
|
||
public byte[ ] Bytes { get; set; } | ||
|
||
public SpeckleStream ToSpeckle() | ||
{ | ||
return SpeckleStream.FromJson( SpeckleCore.Converter.getObjFromBytes( this.Bytes ) as string ); // ((SpeckleCore.Converter.getObjFromBytes( this.Bytes ) as SpeckleStream; | ||
} | ||
} | ||
} |
Oops, something went wrong.