1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-21 03:54:07 +02:00
Files
.github
.idea
Application
Browser
Configuration
Controls
Dialogs
Management
Analytics
AnalyticsFile.cs
AnalyticsManager.cs
AnalyticsReport.cs
AnalyticsReportGenerator.cs
BrowserCache.cs
ClipboardManager.cs
FormManager.cs
LockManager.cs
ProfileManager.cs
VideoPlayer.cs
Plugins
Properties
Resources
Updates
Utils
bld
lib
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
packages.config
TweetDuck/Management/Analytics/AnalyticsReport.cs

58 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Specialized;
using System.Text;
namespace TweetDuck.Management.Analytics {
sealed class AnalyticsReport : IEnumerable {
private OrderedDictionary data = new OrderedDictionary(32);
private int separators;
public void Add(int ignored) { // adding separators to pretty print
data.Add((++separators).ToString(), null);
}
public void Add(string key, string value) {
data.Add(key, value);
}
public AnalyticsReport FinalizeReport() {
if (!data.IsReadOnly) {
data = data.AsReadOnly();
}
return this;
}
public IEnumerator GetEnumerator() {
return data.GetEnumerator();
}
public NameValueCollection ToNameValueCollection() {
NameValueCollection collection = new NameValueCollection();
foreach (DictionaryEntry entry in data) {
if (entry.Value != null) {
collection.Add(((string) entry.Key).ToLower().Replace(' ', '_'), (string) entry.Value);
}
}
return collection;
}
public override string ToString() {
StringBuilder build = new StringBuilder(625);
foreach (DictionaryEntry entry in data) {
if (entry.Value == null) {
build.AppendLine();
}
else {
build.AppendLine(entry.Key + ": " + entry.Value);
}
}
return build.ToString();
}
}
}