1using System.Globalization;
2using System.Security.Cryptography;
15 public const string fName1 =
"CommunityContentManager";
42 public static void List(
string cursor,
51 Action<Exception> failure) {
57 Dictionary<string, string> dictionary =
new();
58 dictionary.Add(
"Action",
"list");
59 dictionary.Add(
"Cursor", cursor ??
string.Empty);
60 dictionary.Add(
"UserId", userId ??
string.Empty);
61 dictionary.Add(
"UserUrl", userUrl ??
string.Empty);
62 dictionary.Add(
"Type", type ??
string.Empty);
63 dictionary.Add(
"Moderation", moderation ??
string.Empty);
64 dictionary.Add(
"Search", search ??
string.Empty);
65 dictionary.Add(
"SortOrder", sortOrder ??
string.Empty);
74 delegate(
byte[] result) {
80 foreach (XElement item
in xElement.Elements()) {
98 success(list, attributeValue);
100 catch (Exception obj) {
104 delegate(Exception error) { failure(error); }
114 Action<Exception> failure) {
125 delegate(
byte[] data) {
128 new MemoryStream(data),
131 delegate(
string downloadedName) {
147 delegate(Exception error) {
164 delegate(Exception error) {
188 Action<Exception> failure) {
203 delegate(
byte[] data) {
210 new Dictionary<string, string> {
211 {
"Action",
"publish" },
212 {
"UserId", userId },
215 {
"Type", type.ToString() },
217 {
"Size", data.Length.ToString(CultureInfo.InvariantCulture) },
218 {
"Platform", VersionsManager.PlatformString },
219 {
"Version", VersionsManager.Version }
227 delegate(Exception error) {
243 Dictionary<string, string> dictionary =
new();
244 dictionary.Add(
"Action",
"delete");
245 dictionary.Add(
"UserId", userId);
246 dictionary.Add(
"Url", address);
259 delegate(Exception error) {
266 public static void Rate(
string address,
string userId,
int rating,
CancellableProgress progress, Action success, Action<Exception> failure) {
267 rating = Math.Clamp(rating, 1, 5);
271 rating.ToString(CultureInfo.InvariantCulture),
281 public static void Report(
string address,
string userId,
string report,
CancellableProgress progress, Action success, Action<Exception> failure) {
300 Action<Exception> failure) {
304 Math.Round(time).ToString(CultureInfo.InvariantCulture),
319 Action<
byte[]> success,
320 Action<Exception> failure)
329 delegate(
byte[] data) {
331 new MemoryStream(data),
334 delegate(
string downloadedName) {
347 string feedbackParameter,
353 Action<Exception> failure) {
363 Task.Delay(1500).Wait();
369 Dictionary<string, string> dictionary =
new();
370 dictionary.Add(
"Action",
"feedback");
371 dictionary.Add(
"Feedback", feedback);
372 if (feedbackParameter !=
null) {
373 dictionary.Add(
"FeedbackParameter", feedbackParameter);
375 dictionary.Add(
"UserId", userId);
376 if (address !=
null) {
377 dictionary.Add(
"Url", address);
380 dictionary.Add(
"Hash", hash);
383 dictionary.Add(
"Size", size.ToString(CultureInfo.InvariantCulture));
393 delegate { success(); },
394 delegate(Exception error) { failure(error); }
400 static string MakeFeedbackCacheKey(
string address,
string feedback,
string userId) => $
"{address}\n{feedback}\n{userId}";
411 IEnumerable<XElement> feedbackElements = xElement.Element(
"Feedback")?.Elements();
412 if (feedbackElements !=
null) {
413 foreach (XElement item
in feedbackElements) {
418 IEnumerable<XElement> contentElements = xElement.Element(
"Content")?.Elements();
419 if (contentElements !=
null) {
420 foreach (XElement item2
in contentElements) {
427 catch (Exception e) {
434 XElement xElement =
new(
"Cache");
435 XElement xElement2 =
new(
"Feedback");
436 xElement.Add(xElement2);
438 XElement xElement3 =
new(
"Item");
440 xElement2.Add(xElement3);
442 XElement xElement4 =
new(
"Content");
443 xElement.Add(xElement4);
445 XElement xElement5 =
new(
"Item");
448 xElement4.Add(xElement5);
453 catch (Exception e) {
static Stream OpenFile(string path, OpenFileMode openFileMode)
static bool FileExists(string path)
static Action Deactivated
static Action< string > BlocksTextureDeleted
static Action< string > CharacterSkinDeleted
static void ReportExceptionToUser(string additionalMessage, Exception e)
static void ImportExternalContent(Stream stream, ExternalContentType type, string name, Action< string > success, Action< Exception > failure)
static void DeleteExternalContent(ExternalContentType type, string name)
static Action< string > FurniturePackDeleted
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static string PlatformString
static void Post(string address, Dictionary< string, string > parameters, Dictionary< string, string > headers, Stream data, CancellableProgress progress, Action< byte[]> success, Action< Exception > failure)
static bool IsInternetConnectionAvailable()
static MemoryStream UrlParametersToStream(Dictionary< string, string > values)
static void Get(string address, Dictionary< string, string > parameters, Dictionary< string, string > headers, CancellableProgress progress, Action< byte[]> success, Action< Exception > failure)
static Action< string > WorldDeleted
static string OriginalCommunityContentCachePath
static void SetAttributeValue(XElement node, string attributeName, object value)
static object GetAttributeValue(XElement node, string attributeName, Type type)
static XElement LoadXmlFromStream(Stream stream, Encoding encoding, bool throwOnError)
static XElement LoadXmlFromString(string data, bool throwOnError)
static void SaveXmlToStream(XElement node, Stream stream, Encoding encoding, bool throwOnError)