示例#1
0
        public void Publish <T>(TKey key, T data)
        {
            List <object> subscriptions;

            if (!_events.TryGetValue(key, out subscriptions))
            {
                _debugger?.LogWarningFormat("No subscriptions found for event type: {0}", typeof(T));
                return;
            }

            _debugger?.LogFormat("Publishing {0}", typeof(T));
            for (int i = subscriptions.Count - 1; i >= 0; i--)
            {
                if (i >= subscriptions.Count)
                {
                    continue;
                }

                var sub = subscriptions[i] as Action <T>;
                sub?.Invoke(data);
            }
        }
 /// <summary>
 /// If no file exists at <paramref name="filePath"/>, the default value for <typeparamref name="TModel"/> is used
 /// <para>
 /// Otherwise, opens the file located at <paramref name="filePath"/> and deserializes the data to type <typeparamref name="TModel"/>
 /// </para>
 /// </summary>
 public TModel Read <TModel>(string filePath)
 {
     if (!File.Exists(filePath))
     {
         _debugger.LogWarningFormat("No file found at the filePath:{0}", filePath);
         return(default);