Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed xml schema test.
  • Loading branch information
kellyelton committed Mar 20, 2011
1 parent 30f7ce9 commit 8ae0cd8
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 3 deletions.
55 changes: 52 additions & 3 deletions ocust/ocust/DeepGameScan.xaml.cs
@@ -1,5 +1,9 @@
using System.Windows;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ocust.Structure;

namespace ocust
{
Expand All @@ -13,12 +17,57 @@ public DeepGameScan()
InitializeComponent();
}

private void echo(String s)
{
ListBoxItem li = new ListBoxItem();
li.Foreground = Brushes.Black;
li.Content = s;
listBox1.Items.Add(li);
}

private void echo(string s, Brush c)
{
ListBoxItem li = new ListBoxItem();
li.Foreground = c;
li.Content = s;
listBox1.Items.Add(li);
}

private void btnStart_Click(object sender, RoutedEventArgs e)
{
btnStart.IsEnabled = false;
listBox1.Items.Clear();
echo("Game File Location Correct :" + App.Game.Filename, Brushes.Green);
echo("Set File Locations Correct", Brushes.Green);
echo("Unzipping game file");
App.Unzip_Files();

listBox1.Items.Add("Game File Location Correct :" + App.Game.Filename);
listBox1.Items.Add("Set File Locations Correct");
Octgn.Game g = new Octgn.Game(Octgn.Definitions.GameDef.FromO8G(App.Game.Filename));
echo("Loading Relationship File...");
App.Load_Relationships();
echo("Verifying Relationship file targets...");
foreach (Relationship r in App.Relationships)
{
string checkloc = App.UnzipPath + r.Target.Replace("/", "\\");
if (File.Exists(checkloc))
{
echo(" " + "Target: " + r.Target + " Exists.", Brushes.Green);
}
else
{
echo(" " + "Target: " + r.Target + " Doesn't Exist!", Brushes.Red);
}
}
echo("Done Verifying Relationship File Targets.");
//XmlStuff x = new XmlStuff();
//if (x.validateXml(App.UnzipPath + "\\" + App.gameFilePrefix + ".xml"))
//{
// echo(App.gameFilePrefix + ".xml Is valid.");
//}
//else
//{
// echo(App.gameFilePrefix + ".xml is corrupt, you should redownload this file.", Brushes.Red);
//}

btnStart.IsEnabled = true;
}
Expand Down
2 changes: 2 additions & 0 deletions ocust/ocust/GameSelect.xaml.cs
Expand Up @@ -11,6 +11,7 @@ public partial class GameSelect : Page
public GameSelect()
{
InitializeComponent();
App.Game = gameSelector.Game;
//MessageBox.Show(gameSelector.Game.Filename);
}

Expand All @@ -27,6 +28,7 @@ private void btnNext_Click(object sender, RoutedEventArgs e)

private void btnDeepScan_Click(object sender, RoutedEventArgs e)
{
App.Game = gameSelector.Game;
NavigationService.Navigate(new DeepGameScan());
}
}
Expand Down
64 changes: 64 additions & 0 deletions ocust/ocust/XmlStuff.cs
@@ -0,0 +1,64 @@
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;

namespace ocust
{
public class XmlStuff
{
public bool m_Success = true;

public bool validateXml(String infile)
{
//First we create the xmltextreader
XmlTextReader xmlr = new XmlTextReader(infile);
//We pass the xmltextreader into the xmlvalidatingreader
//'This will validate the xml doc with the schema file
//'NOTE the xml file it self points to the schema file
XmlValidatingReader xmlvread = new XmlValidatingReader(xmlr);
//
// // ' Set the validation event handler
xmlvread.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
m_Success = true; //'make sure to reset the success var
//
// //' Read XML data
while (xmlvread.Read()) { }

//'Close the reader.
xmlvread.Close();

//'The validationeventhandler is the only thing that would set m_Success to false
return m_Success;
}

public void ValidationCallBack(Object sender, ValidationEventArgs args)
{
//'Display the validation error. This is only called on error
m_Success = false; //'Validation failed
//writertbox("Validation error: " + args.Message);
App.addDebugLine("Validation Error: " + args.Message);
}

public bool validateSchema(String infilename)
{
//this function will validate the schema file (xsd)

XmlSchema myschema;
m_Success = true; //'make sure to reset the success var
StreamReader sr = new StreamReader(infilename);
try
{
//sr = new StreamReader(infilename);
myschema = XmlSchema.Read(sr, new ValidationEventHandler(ValidationCallBack));
//'This compile statement is what ususally catches the errors
myschema.Compile(new ValidationEventHandler(ValidationCallBack));
}
finally
{
sr.Close();
}
return m_Success;
}
}
}
1 change: 1 addition & 0 deletions ocust/ocust/ocust.csproj
Expand Up @@ -164,6 +164,7 @@
<DependentUpon>Splash.xaml</DependentUpon>
</Compile>
<Compile Include="Structure\Relationship.cs" />
<Compile Include="XmlStuff.cs" />
<Page Include="DebugWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

0 comments on commit 8ae0cd8

Please sign in to comment.