diff options
Diffstat (limited to 'Common/OpenSim.GenericConfig')
5 files changed, 291 insertions, 0 deletions
diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj new file mode 100644 index 0000000..df68722 --- /dev/null +++ b/Common/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/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build new file mode 100644 index 0000000..926e72c --- /dev/null +++ b/Common/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/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs b/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..de5f48d --- /dev/null +++ b/Common/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/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs new file mode 100644 index 0000000..62e3cbf --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs | |||
@@ -0,0 +1,109 @@ | |||
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 | private bool createdFile = false; | ||
16 | |||
17 | public XmlConfig(string filename) | ||
18 | { | ||
19 | fileName = filename; | ||
20 | } | ||
21 | |||
22 | public void LoadData() | ||
23 | { | ||
24 | doc = new XmlDocument(); | ||
25 | try | ||
26 | { | ||
27 | if (System.IO.File.Exists(fileName)) | ||
28 | { | ||
29 | XmlTextReader reader = new XmlTextReader(fileName); | ||
30 | reader.WhitespaceHandling = WhitespaceHandling.None; | ||
31 | doc.Load(reader); | ||
32 | reader.Close(); | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | createdFile = true; | ||
37 | rootNode = doc.CreateNode(XmlNodeType.Element, "Root", ""); | ||
38 | doc.AppendChild(rootNode); | ||
39 | configNode = doc.CreateNode(XmlNodeType.Element, "Config", ""); | ||
40 | rootNode.AppendChild(configNode); | ||
41 | } | ||
42 | |||
43 | } | ||
44 | catch (Exception e) | ||
45 | { | ||
46 | Console.WriteLine(e.Message); | ||
47 | return; | ||
48 | } | ||
49 | try | ||
50 | { | ||
51 | rootNode = doc.FirstChild; | ||
52 | if (rootNode.Name != "Root") | ||
53 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
54 | |||
55 | configNode = rootNode.FirstChild; | ||
56 | if (configNode.Name != "Config") | ||
57 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
58 | |||
59 | } | ||
60 | catch (Exception e) | ||
61 | { | ||
62 | Console.WriteLine(e.Message); | ||
63 | } | ||
64 | if (createdFile) | ||
65 | { | ||
66 | this.Commit(); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | public string GetAttribute(string attributeName) | ||
71 | { | ||
72 | string result = ""; | ||
73 | if (configNode.Attributes[attributeName] != null) | ||
74 | { | ||
75 | result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; | ||
76 | } | ||
77 | return result; | ||
78 | } | ||
79 | |||
80 | public bool SetAttribute(string attributeName, string attributeValue) | ||
81 | { | ||
82 | if (configNode.Attributes[attributeName] != null) | ||
83 | { | ||
84 | ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | XmlAttribute attri; | ||
89 | attri = doc.CreateAttribute(attributeName); | ||
90 | attri.Value = attributeValue; | ||
91 | configNode.Attributes.Append(attri); | ||
92 | } | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | public void Commit() | ||
97 | { | ||
98 | doc.Save(fileName); | ||
99 | } | ||
100 | |||
101 | public void Close() | ||
102 | { | ||
103 | configNode = null; | ||
104 | rootNode = null; | ||
105 | doc = null; | ||
106 | } | ||
107 | |||
108 | } | ||
109 | } | ||