1: /*
2: Copyright (c) 2010 <a href="http://www.gutgames.com">James Craig</a>
3:
4: Permission is hereby granted, free of charge, to any person obtaining a copy
5: of this software and associated documentation files (the "Software"), to deal
6: in the Software without restriction, including without limitation the rights
7: to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8: copies of the Software, and to permit persons to whom the Software is
9: furnished to do so, subject to the following conditions:
10:
11: The above copyright notice and this permission notice shall be included in
12: all copies or substantial portions of the Software.
13:
14: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20: THE SOFTWARE.*/
21:
22: #region Usings
23: using System;
24: using System.Text;
25: using System.Xml;
26: #endregion
27:
28: namespace Utilities.FileFormats.RSD
29: {
30: /// <summary>
31: /// Basic helper for RSD
32: /// </summary>
33: public class RSD
34: {
35: #region Constructor
36:
37: /// <summary>
38: /// Constructor
39: /// </summary>
40: public RSD()
41: {
42: APIs = new APIs();
43: }
44:
45: /// <summary>
46: /// Constructor
47: /// </summary>
48: /// <param name="FileContent">Content of the RSD file</param>
49: public RSD(string FileContent)
50: {
51: XmlDocument Document = new XmlDocument();
52: Document.LoadXml(FileContent);
53: foreach (XmlNode Children in Document.ChildNodes)
54: {
55: if (Children.Name.Equals("RSD", StringComparison.CurrentCultureIgnoreCase))
56: {
57: foreach (XmlNode Child in Children.ChildNodes)
58: {
59: if (Child.Name.Equals("service", StringComparison.CurrentCultureIgnoreCase))
60: {
61: foreach (XmlNode ServiceChild in Child.ChildNodes)
62: {
63: if (ServiceChild.Name.Equals("engineName", StringComparison.CurrentCultureIgnoreCase))
64: {
65: EngineName = ServiceChild.InnerText;
66: }
67: else if (ServiceChild.Name.Equals("engineLink", StringComparison.CurrentCultureIgnoreCase))
68: {
69: EngineLink = ServiceChild.InnerText;
70: }
71: else if (ServiceChild.Name.Equals("homePageLink", StringComparison.CurrentCultureIgnoreCase))
72: {
73: HomePageLink = ServiceChild.InnerText;
74: }
75: else if (ServiceChild.Name.Equals("apis", StringComparison.CurrentCultureIgnoreCase))
76: {
77: APIs = new APIs((XmlElement)ServiceChild);
78: }
79: }
80: }
81: }
82: }
83: }
84: }
85: #endregion
86:
87: #region Public Properties
88: /// <summary>
89: /// Engine name
90: /// </summary>
91: public string EngineName { get; set; }
92:
93: /// <summary>
94: /// Link to the engine
95: /// </summary>
96: public string EngineLink { get; set; }
97:
98: /// <summary>
99: /// Link to the home page
100: /// </summary>
101: public string HomePageLink { get; set; }
102:
103: /// <summary>
104: /// API definitions
105: /// </summary>
106: public APIs APIs { get; set; }
107:
108: #endregion
109:
110: #region Public Overridden Functions
111:
112: /// <summary>
113: /// Outputs the RSD file
114: /// </summary>
115: /// <returns>return the properly formatted RSD file</returns>
116: public override string ToString()
117: {
118: StringBuilder Builder = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><rsd version=\"1.0\"><service><engineName>");
119: Builder.Append(EngineName).Append("</engineName><engineLink>").Append(EngineLink).Append("</engineLink><homePageLink>")
120: .Append(HomePageLink).Append("</homePageLink>");
121: Builder.Append(APIs.ToString());
122: Builder.Append("</service></rsd>");
123: return Builder.ToString();
124: }
125:
126: #endregion
127: }
128: }