diff options
Diffstat (limited to '')
4 files changed, 262 insertions, 0 deletions
diff --git a/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj new file mode 100644 index 0000000..98e813e --- /dev/null +++ b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj | |||
@@ -0,0 +1,93 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{E88EF749-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.GenericConfig.Xml</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.GenericConfig.Xml</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | </ItemGroup> | ||
70 | <ItemGroup> | ||
71 | <ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj"> | ||
72 | <Name>OpenSim.Framework</Name> | ||
73 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | ||
74 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
75 | <Private>False</Private> | ||
76 | </ProjectReference> | ||
77 | </ItemGroup> | ||
78 | <ItemGroup> | ||
79 | <Compile Include="XmlConfig.cs"> | ||
80 | <SubType>Code</SubType> | ||
81 | </Compile> | ||
82 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
83 | <SubType>Code</SubType> | ||
84 | </Compile> | ||
85 | </ItemGroup> | ||
86 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
87 | <PropertyGroup> | ||
88 | <PreBuildEvent> | ||
89 | </PreBuildEvent> | ||
90 | <PostBuildEvent> | ||
91 | </PostBuildEvent> | ||
92 | </PropertyGroup> | ||
93 | </Project> | ||
diff --git a/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build new file mode 100644 index 0000000..f34e4ac --- /dev/null +++ b/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build | |||
@@ -0,0 +1,42 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenSim.GenericConfig.Xml" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenSim.GenericConfig.Xml" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="XmlConfig.cs" /> | ||
15 | <include name="Properties/AssemblyInfo.cs" /> | ||
16 | </sources> | ||
17 | <references basedir="${project::get-base-directory()}"> | ||
18 | <lib> | ||
19 | <include name="${project::get-base-directory()}" /> | ||
20 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
21 | </lib> | ||
22 | <include name="System.dll" /> | ||
23 | <include name="System.Xml.dll" /> | ||
24 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
25 | </references> | ||
26 | </csc> | ||
27 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
28 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
29 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
30 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
31 | <include name="*.dll"/> | ||
32 | <include name="*.exe"/> | ||
33 | </fileset> | ||
34 | </copy> | ||
35 | </target> | ||
36 | <target name="clean"> | ||
37 | <delete dir="${bin.dir}" failonerror="false" /> | ||
38 | <delete dir="${obj.dir}" failonerror="false" /> | ||
39 | </target> | ||
40 | <target name="doc" description="Creates documentation."> | ||
41 | </target> | ||
42 | </project> | ||
diff --git a/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs b/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..de5f48d --- /dev/null +++ b/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.GenericConfig")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenSim.GenericConfig")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim.GenericConfig/Xml/XmlConfig.cs b/OpenSim.GenericConfig/Xml/XmlConfig.cs new file mode 100644 index 0000000..39321cc --- /dev/null +++ b/OpenSim.GenericConfig/Xml/XmlConfig.cs | |||
@@ -0,0 +1,92 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Xml; | ||
5 | using OpenSim.Framework.Interfaces; | ||
6 | |||
7 | namespace OpenSim.GenericConfig | ||
8 | { | ||
9 | public class XmlConfig : IGenericConfig | ||
10 | { | ||
11 | private XmlDocument doc; | ||
12 | private XmlNode rootNode; | ||
13 | private XmlNode configNode; | ||
14 | private string fileName; | ||
15 | |||
16 | public XmlConfig(string filename) | ||
17 | { | ||
18 | fileName = filename; | ||
19 | } | ||
20 | |||
21 | public void LoadData() | ||
22 | { | ||
23 | doc = new XmlDocument(); | ||
24 | try | ||
25 | { | ||
26 | XmlTextReader reader = new XmlTextReader(fileName); | ||
27 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
28 | doc.Load(reader); | ||
29 | reader.Close(); | ||
30 | } | ||
31 | catch (Exception e) | ||
32 | { | ||
33 | Console.WriteLine(e.Message); | ||
34 | return; | ||
35 | } | ||
36 | try | ||
37 | { | ||
38 | rootNode = doc.FirstChild; | ||
39 | if (rootNode.Name != "Root") | ||
40 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
41 | |||
42 | configNode = rootNode.FirstChild; | ||
43 | if (configNode.Name != "Config") | ||
44 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
45 | |||
46 | } | ||
47 | catch (Exception e) | ||
48 | { | ||
49 | Console.WriteLine(e.Message); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | public string GetAttribute(string attributeName) | ||
54 | { | ||
55 | string result = ""; | ||
56 | if (configNode.Attributes[attributeName] != null) | ||
57 | { | ||
58 | result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; | ||
59 | } | ||
60 | return result; | ||
61 | } | ||
62 | |||
63 | public bool SetAttribute(string attributeName, string attributeValue) | ||
64 | { | ||
65 | if (configNode.Attributes[attributeName] != null) | ||
66 | { | ||
67 | configNode.Attributes.GetNamedItem(attributeName).Value = attributeValue; | ||
68 | } | ||
69 | else | ||
70 | { | ||
71 | XmlAttribute attri; | ||
72 | attri = doc.CreateAttribute(attributeName); | ||
73 | attri.Value = attributeValue; | ||
74 | configNode.Attributes.Append(attri); | ||
75 | } | ||
76 | return true; | ||
77 | } | ||
78 | |||
79 | public void Commit() | ||
80 | { | ||
81 | doc.Save(fileName); | ||
82 | } | ||
83 | |||
84 | public void Close() | ||
85 | { | ||
86 | configNode = null; | ||
87 | rootNode = null; | ||
88 | doc = null; | ||
89 | } | ||
90 | |||
91 | } | ||
92 | } | ||