Last active
December 11, 2015 13:38
-
-
Save wizzard0/4608855 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace GenericEntityFramework | |
{ | |
/// <summary> | |
/// resolves to a specific version of an entity, immutable | |
/// </summary> | |
[Plaintext] | |
public class EntitySelector : IEntitySelector | |
{ | |
[Immutable, NotNull] | |
public Guid Id { get; set; } | |
[Immutable, NotNull] | |
// in different namespace than entity guids | |
public Guid RevisionId { get; set; } | |
} | |
/// <summary> | |
/// defines aggregate body of knowledge about entity, mutable | |
/// </summary> | |
[Plaintext] | |
public class Entity | |
{ | |
[Immutable, NotNull] | |
public Guid Id { get; set; } | |
[Mutable,NotNull] | |
public HashSet<EntityRevision> Revisions { get; set; } | |
} | |
/// <summary> | |
/// specific entity revision == knowledge atom, immutable | |
/// </summary> | |
[Plaintext] | |
public class EntityRevision : IEntitySelector | |
{ | |
[Immutable, NotNull] | |
public Guid Id { get; set; } | |
/// <summary> | |
/// in different namespace than entity guids | |
/// </summary> | |
[Immutable, NotNull] | |
public Guid RevisionId { get; set; } | |
/// <summary> | |
/// MUST be not null if it's an update | |
/// </summary> | |
[CanBeNull, Immutable] | |
public EntitySelector PreviousRevisionId { get; set; } | |
/// <summary> | |
/// object+object meta, MUST be present if this is the first revision | |
/// </summary> | |
[CanBeNull,Immutable] | |
public EntityKnowledge Entity { get; set; } | |
/// <summary> | |
/// revision meta | |
/// </summary> | |
[NotNull,Immutable] | |
public KnowledgeAtom Revision { get; set; } | |
/// <summary> | |
/// what other entities are needed to reason about an object? | |
/// </summary> | |
[NotNull,Immutable] | |
public PropertySet<EntitySelector> Reference { get; set; } | |
} | |
/// <summary> | |
/// well, entity knowledge | |
/// </summary> | |
[Plaintext] | |
public class EntityKnowledge | |
{ | |
/// <summary> | |
/// object meta | |
/// </summary> | |
[Immutable, NotNull] | |
public KnowledgeAtom Meta { get; set; } | |
/// <summary> | |
/// what else | |
/// </summary> | |
[Encrypted, IndexedOnRecipient] | |
[Immutable, NotNull] | |
public UncertainPropertySet<EntitySelector> EquivalencyClass { get; set; } | |
/// <summary> | |
/// object itself, plus how to interpret | |
/// </summary> | |
[Encrypted] | |
[Immutable, NotNull] | |
public FormattedBlob Data { get; set; } | |
/// <summary> | |
/// object validator | |
/// </summary> | |
[Plaintext] | |
[Immutable, NotNull] | |
public FormattedBlob DataHash { get; set; } | |
} | |
public class KnowledgeAtom | |
{ | |
/// <summary> | |
/// when | |
/// </summary> | |
[Encrypted, IndexedOnRecipient] | |
[Immutable, NotNull] | |
public UncertainPropertySet<AbstractDateTimeRangeDescriptor> Timestamp { get; set; } | |
/// <summary> | |
/// where | |
/// </summary> | |
[Encrypted, IndexedOnRecipient] | |
[Immutable, NotNull] | |
public UncertainPropertySet<AbstractSpatialLocator> Location { get; set; } | |
/// <summary> | |
/// wherein | |
/// </summary> | |
[Encrypted, IndexedOnRecipient] | |
[Immutable, NotNull] | |
public UncertainPropertySet<EntitySelector> Parent { get; set; } | |
/// <summary> | |
/// whence === proofs about the atom's origins | |
/// </summary> | |
[Plaintext] | |
[Immutable, NotNull] | |
public UncertainPropertySet<SignedOrigin> Origin { get; set; } | |
/// <summary> | |
/// whither/whereto === means for the intended recipients to interpret | |
/// </summary> | |
[Plaintext] | |
[Immutable, NotNull] | |
public UncertainPropertySet<TargetedKey> Intent { get; set; } | |
} | |
/// <summary> | |
/// key + destination | |
/// </summary> | |
[Plaintext] | |
public class TargetedKey | |
{ | |
[Immutable, NotNull] | |
public FormattedBlob Key { get; set; } | |
[CanBeNull,Immutable] | |
public EntitySelector Target { get; set; } | |
} | |
/// <summary> | |
/// signature + source | |
/// </summary> | |
[Plaintext] | |
public class SignedOrigin | |
{ | |
[Immutable, NotNull] | |
public FormattedBlob Signature { get; set; } | |
[Immutable, CanBeNull] | |
public EntitySelector Source { get; set; } | |
} | |
/// <summary> | |
/// blob + how to deal with it, eg encoding | |
/// </summary> | |
[Encrypted] | |
public class FormattedBlob | |
{ | |
[Immutable, NotNull] | |
public byte[] Data { get; set; } | |
[Immutable, NotNull] | |
public PropertySet<EntitySelector> Formats { get; set; } | |
} | |
/// <summary> | |
/// set of certain properties, can contain zero items | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public class PropertySet<T> : HashSet<UncertainCase<T>> | |
{ | |
} | |
/// <summary> | |
/// set of uncertain properties, can contain zero items | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public class UncertainPropertySet<T> : HashSet<UncertainCase<T>> | |
{ | |
} | |
/// <summary> | |
/// one case in the set | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public class Case<T> | |
{ | |
[Immutable, NotNull] | |
public T Value { get; set; } | |
/// <summary> | |
/// the role of the case, eg. for origin, this may be "author", "contributor" etc | |
/// </summary> | |
[Immutable, NotNull] | |
public EntitySelector Role { get; set; } | |
} | |
/// <summary> | |
/// one uncertain case in the set | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public class UncertainCase<T> : Case<T> | |
{ | |
[Immutable, NotNull] | |
public float Confidence { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment