private static string GetVirtualFileContent(string filePath) { string fileName = Path.GetFileName(filePath); string[] strArray = Path.GetDirectoryName(filePath).Split(Path.DirectorySeparatorChar); Type type = typeof(VirtualFolders); for (int index = 0; type != (Type)null && index != strArray.Length; ++index) { if (!strArray[index].IsStringNoneOrEmpty()) { type = VirtualFolders.GetNestedDirectory(strArray[index], type); } } if (type != (Type)null) { foreach (MemberInfo field in type.GetFields()) { VirtualFileAttribute[] customAttributes = (VirtualFileAttribute[])field.GetCustomAttributes(typeof(VirtualFileAttribute), false); if (customAttributes[0].Name == fileName) { return(customAttributes[0].Content); } } } return(""); }
public static ParameterContainer LoadParametersFromClientProfile( string configurationName) { ParameterContainer parameters = new ParameterContainer(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(VirtualFolders.GetFileContent(BasePath.Name + "Parameters/ClientProfile.xml")); ParameterLoader.LoadParametersInto("ClientProfiles/" + xmlDocument.ChildNodes[0].Attributes["Value"].InnerText + "/" + configurationName + ".xml", parameters); return(parameters); }
public static ApplicationVersion FromParametersFile( ApplicationVersionGameType versionGameType) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(VirtualFolders.GetFileContent(BasePath.Name + "Parameters/Version.xml")); string versionAsString = ""; switch (versionGameType) { case ApplicationVersionGameType.Singleplayer: versionAsString = xmlDocument.ChildNodes[0].ChildNodes[0].Attributes["Value"].InnerText; break; case ApplicationVersionGameType.Multiplayer: versionAsString = xmlDocument.ChildNodes[0].ChildNodes[1].Attributes["Value"].InnerText; break; } return(ApplicationVersion.FromString(versionAsString, versionGameType)); }
public static void LoadParametersInto(string fileFullName, ParameterContainer parameters) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(VirtualFolders.GetFileContent(BasePath.Name + "Parameters/" + fileFullName)); foreach (XmlNode childNode1 in xmlDocument.FirstChild.ChildNodes) { if (childNode1.Name == "Parameters") { foreach (XmlNode childNode2 in childNode1.ChildNodes) { string innerText = childNode2.Attributes["Name"].InnerText; string str1; string str2; string str3 = !ParameterLoader.TryGetFromFile(childNode2, out str1) ? (!ParameterLoader.TryGetFromEnvironment(childNode2, out str2) ? (childNode2.Attributes["DefaultValue"] == null ? childNode2.Attributes["Value"].InnerText : childNode2.Attributes["DefaultValue"].InnerText) : str2) : str1; parameters.AddParameter(innerText, str3, true); } } } }
public static string GetFileContent(string filePath) => !VirtualFolders._useVirtualFolders ? File.ReadAllText(filePath) : VirtualFolders.GetVirtualFileContent(filePath);