public static string GetNodeJSON(string type, string key = null, string property = null, bool includeCaches = false) { if (key.IsNullOrEmpty()) { var nodesToSerialize = PollingEngine.GetNodes(type).Select(n => NodeData.FromNode(n)); return(JsonConvert.SerializeObject(nodesToSerialize, _serializationSettings)); } var node = PollingEngine.GetNode(type, key); if (node == null) { throw new DataPullException("No {0} node found with key: {1}", type, key); } // Node level if (property.IsNullOrEmpty()) { var nodeToSerialize = NodeData.FromNode(node, includeCaches); return(JsonConvert.SerializeObject(nodeToSerialize, _serializationSettings)); } var cache = node.GetCache(property); if (cache == null) { throw new DataPullException("{0} node was found, but no cache for property: {1}", node.NodeType, property); } var cacheToSerialize = CacheData.FromCache(cache, includeCaches); return(JsonConvert.SerializeObject(cacheToSerialize, _serializationSettings)); }
public Task StartAsync(CancellationToken cancellationToken) { _cancellationToken = cancellationToken; _logger.LogInformation("Polling service is starting."); PollingEngine.StartPolling(_cancellationToken); return(Task.CompletedTask); }
/// <summary> /// Tries added this node to the global polling engine. If another copy of this node is present (same unique key) /// then this method will return false, indicating it was not added and will not be polled. /// </summary> /// <remarks>If this return FALSE, be sure not to cache the node anywhere else, as it should likely be garbage collected</remarks> /// <returns>Whether the node was added to the list of global pollers</returns> public bool TryAddToGlobalPollers() { return(AddedToGlobalPollers = PollingEngine.TryAdd(this)); }
public void Dispose() { PollingEngine.TryRemove(this); }
/// <summary> /// Tries added this node to the global polling engine. If another copy of this node is present (same unique key) /// then this method will return false, indicating it was not added and will not be polled. /// </summary> /// <remarks>If this return FALSE, be sure not to cache the node anywhere else, as it should likely be garbage collected</remarks> /// <returns>Whether the node was added to the list of global pollers</returns> public bool TryAddToGlobalPollers() { AddedToGlobalPollers = PollingEngine.TryAdd(this); RegisterProviders(); return(AddedToGlobalPollers); }
public Task StopAsync(CancellationToken cancellationToken) { _logger.LogInformation("Polling service is stopping."); PollingEngine.StopPolling(); return(Task.CompletedTask); }