public static bool IsRenderSettingStringValid(XDocument doc, string setting, XMLTypes type) { if (type != XMLTypes.String) { return(false); } var v = from nodes in doc.Descendants("Item") where nodes.Attribute("class").Value == "RenderSettings" select nodes; foreach (var item in v) { var v2 = from nodes in item.Descendants(GetStringForXMLType(type)) where nodes.Attribute("name").Value == setting select nodes; foreach (var item2 in v2) { return(true); } } return(false); }
public string GetXML(XMLTypes xml) { XmlDocument xmlProduct = new XmlDocument(); if (xml == XMLTypes.Product) { string xmlPath = HttpContext.Current.Server.MapPath("XMLDataSources/Product.xml"); xmlProduct.Load(xmlPath); } string json = JsonConvert.SerializeXmlNode(xmlProduct); return(json); }
//TODO: actually download the script assets instead of fixing the scripts lol. fixing the scripts won't work anyways because we don't support https natively. /* * public static void DownloadScriptFromNodes(string filepath, string itemClassValue) * { * string oldfile = File.ReadAllText(filepath); * string fixedfile = RemoveInvalidXmlChars(ReplaceHexadecimalSymbols(oldfile)); * XDocument doc = XDocument.Parse(fixedfile); * * try * { * var v = from nodes in doc.Descendants("Item") * where nodes.Attribute("class").Value == itemClassValue * select nodes; * * foreach (var item in v) * { * var v2 = from nodes in item.Descendants("Properties") * select nodes; * * foreach (var item2 in v2) * { * var v3 = from nodes in doc.Descendants("ProtectedString") * where nodes.Attribute("name").Value == "Source" * select nodes; * * foreach (var item3 in v3) * { * string newurl = "assetdelivery.roblox.com/v1/asset/?id="; * item3.Value.Replace("http://", "https://") * .Replace("?version=1&id=", "?id=") * .Replace("www.roblox.com/asset/?id=", newurl) * .Replace("www.roblox.com/asset?id=", newurl) * .Replace("assetgame.roblox.com/asset/?id=", newurl) * .Replace("assetgame.roblox.com/asset?id=", newurl) * .Replace("roblox.com/asset/?id=", newurl) * .Replace("roblox.com/asset?id=", newurl); * } * } * } * } * catch (Exception ex) * { * MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); * } * finally * { * doc.Save(filepath); * } * } * * public static void DownloadFromScript(string filepath) * { * string[] file = File.ReadAllLines(filepath); * * try * { * foreach (var line in file) * { * if (line.Contains("www.roblox.com/asset/?id=") || line.Contains("assetgame.roblox.com/asset/?id=")) * { * string newurl = "assetdelivery.roblox.com/v1/asset/?id="; * line.Replace("http://", "https://") * .Replace("?version=1&id=", "?id=") * .Replace("www.roblox.com/asset/?id=", newurl) * .Replace("www.roblox.com/asset?id=", newurl) * .Replace("assetgame.roblox.com/asset/?id=", newurl) * .Replace("assetgame.roblox.com/asset?id=", newurl) * .Replace("roblox.com/asset/?id=", newurl) * .Replace("roblox.com/asset?id=", newurl); * } * } * } * catch (Exception ex) * { * MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information); * } * finally * { * File.WriteAllLines(filepath, file); * } * }*/ public static string GetStringForXMLType(XMLTypes type) { switch (type) { case XMLTypes.Bool: return("bool"); case XMLTypes.Float: return("float"); case XMLTypes.Token: default: return("token"); } }
public DisplayService ParseXML(XMLTypes xmlTypes) { switch (xmlTypes) { case XMLTypes.OrderXML: return(new OrderXMLDisplayService()); case XMLTypes.FeedbackXML: return(new FeedbackXMLDisplayService()); case XMLTypes.ErrorXML: return(new ErrorXMLDisplayService()); default: throw new ApplicationException("XML cannot be created"); } }
public static string GetRenderSettings(XDocument doc, string setting, XMLTypes type) { var v = from nodes in doc.Descendants("Item") where nodes.Attribute("class").Value == "RenderSettings" select nodes; foreach (var item in v) { var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16")) where nodes.Attribute("name").Value == setting select nodes; foreach (var item2 in v2) { if (type != XMLTypes.Vector2Int16) { return(item2.Value); } else { string ValX = ""; string ValY = ""; var v3 = from nodes in item2.Descendants("X") select nodes; foreach (var item3 in v3) { ValX = item3.Value; } var v4 = from nodes in item2.Descendants("Y") select nodes; foreach (var item4 in v4) { ValY = item4.Value; } return(ValX + "x" + ValY); } } } return(""); }
public static string GetRenderSettings(XDocument doc, string setting, XMLTypes type) { var v = from nodes in doc.Descendants("Item") where nodes.Attribute("class").Value == "RenderSettings" select nodes; foreach (var item in v) { var v2 = from nodes in item.Descendants(GetStringForXMLType(type)) where nodes.Attribute("name").Value == setting select nodes; foreach (var item2 in v2) { return(item2.Value); } } return(""); }
public static void EditRenderSettings(XDocument doc, string setting, string value, XMLTypes type) { var v = from nodes in doc.Descendants("Item") where nodes.Attribute("class").Value == "RenderSettings" select nodes; foreach (var item in v) { var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16")) where nodes.Attribute("name").Value == setting select nodes; foreach (var item2 in v2) { if (type != XMLTypes.Vector2Int16) { item2.Value = value; } else { string[] vals = value.Split('x'); var v3 = from nodes in item2.Descendants("X") select nodes; foreach (var item3 in v3) { item3.Value = vals[0]; } var v4 = from nodes in item2.Descendants("Y") select nodes; foreach (var item4 in v4) { item4.Value = vals[1]; } } } } }