3using System.Threading.Tasks;
18 private bool prevHasSniffers =
false;
34 this.CheckEventHandlers();
43 this.CheckEventHandlers();
51 bool Result = base.Remove(Sniffer);
52 this.CheckEventHandlers();
56 private void CheckEventHandlers()
60 if (this.prevHasSniffers != b)
64 Database.CollectionCleared += this.Database_CollectionCleared;
65 Database.CollectionRepaired += this.Database_CollectionRepaired;
66 Database.ObjectDeleted += this.Database_ObjectDeleted;
67 Database.ObjectInserted += this.Database_ObjectInserted;
68 Database.ObjectUpdated += this.Database_ObjectUpdated;
70 Search.ObjectAddedToIndex += this.Search_ObjectAddedToIndex;
71 Search.ObjectUpdatedInIndex += this.Search_ObjectUpdatedInIndex;
72 Search.ObjectRemovedFromIndex += this.Search_ObjectRemovedFromIndex;
76 Database.CollectionCleared -= this.Database_CollectionCleared;
77 Database.CollectionRepaired -= this.Database_CollectionRepaired;
78 Database.ObjectDeleted -= this.Database_ObjectDeleted;
79 Database.ObjectInserted -= this.Database_ObjectInserted;
80 Database.ObjectUpdated -= this.Database_ObjectUpdated;
82 Search.ObjectAddedToIndex -= this.Search_ObjectAddedToIndex;
83 Search.ObjectUpdatedInIndex -= this.Search_ObjectUpdatedInIndex;
84 Search.ObjectRemovedFromIndex -= this.Search_ObjectRemovedFromIndex;
87 this.prevHasSniffers = b;
91 internal static async Task<string> GetJSON(
object Object)
94 Dictionary<string, object> Obj2 =
new Dictionary<string, object>()
96 {
"ObjectId", Obj.ObjectId },
97 {
"TypeName", Obj.TypeName },
98 {
"CollectionName", Obj.CollectionName }
101 foreach (KeyValuePair<string, object> P
in Obj)
102 Obj2[P.Key] = P.Value;
107 private async
void Database_ObjectInserted(
object Sender,
ObjectEventArgs e)
122 private async
void Database_ObjectUpdated(
object Sender,
ObjectEventArgs e)
137 private async
void Database_ObjectDeleted(
object Sender,
ObjectEventArgs e)
147 this.
Error(
"Object of type " + e.
Object.GetType().FullName +
" deleted.");
172 return Task.CompletedTask;
180 return Task.CompletedTask;
188 return Task.CompletedTask;
196 return Task.CompletedTask;
204 return Task.CompletedTask;
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
Class that can be used to sniff on database updates.
SniffableDatabase()
Class that can be used to sniff on database updates.
override void AddRange(IEnumerable< ISniffer > Sniffers)
ICommunicationLayer.AddRange
override bool Remove(ISniffer Sniffer)
ICommunicationLayer.Remove
override void Add(ISniffer Sniffer)
ICommunicationLayer.Add
Simple base class for classes implementing communication protocols.
void TransmitText(string Text)
Called when text has been transmitted.
void Exception(Exception Exception)
Called to inform the viewer of an exception state.
void ReceiveText(string Text)
Called when text has been received.
ISniffer[] Sniffers
Registered sniffers.
bool HasSniffers
If there are sniffers registered on the object.
void Error(string Error)
Called to inform the viewer of an error state.
void Warning(string Warning)
Called to inform the viewer of a warning state.
void Information(string Comment)
Called to inform the viewer of something.
Event arguments for collection events.
string Collection
Collection
Event arguments for collection repaired events.
FlagSource[] Flagged
If the collection have been flagged as corrupt, and from what stack traces. Is null,...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< GenericObject > Generalize(object Object)
Creates a generalized representation of an object.
Source of code flagging a collection for repair.
int Count
Number of times the collection has been flagged from this source.
string StackTrace
Stack trace of source flagging the collection.
string Reason
Reason for flagging collection.
Event arguments for object reference events.
ObjectReference Reference
Object reference.
string IndexCollection
Collection of full-text-search index.
Event arguments for database object events.
Generic object. Contains a sequence of properties.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...