static int Main(string[] args) { if (args.Length <= 0) { Console.WriteLine("Please supply an hmd properties file"); return(-1); } if (args.Length > 1) { Console.WriteLine("Too many arguments...please only supply an hmd properties file"); return(-1); } String hmdPropertiesFile = args[0]; HmdProperties hmdProperties = HmdFileParser.ParsePropertiesFile( hmdPropertiesFile, Path.GetDirectoryName(hmdPropertiesFile)); hmdProperties.ResolveChildParentReferences(); CodeGenerator codeGenerator = new CodeGenerator(CSharpLanguageGenerator.Instance, Console.Out, "DefaultHmdNamespace", "DefaultRootClassName", "HmdType"); codeGenerator.Generate(hmdProperties); return(0); }
public void Validate(HmdBlockID root, HmdProperties hmdProperties) { debugOutput = HmdDebug.DebugOutput; if (root == null) { throw new ArgumentNullException("root"); } if (hmdProperties == null) { throw new ArgumentNullException("hmdProperties"); } hmdProperties.ResolveChildParentReferences(); debugOutput.WriteLine("[Validating HMD file...]"); hmdProperties.PrintEnums(debugOutput); currentBlock = null; blockStack = new Stack <HmdBlockValidator>(); ValidateBlockID(root, hmdProperties.root, hmdProperties); debugOutput.WriteLine("[Done validating HMD file]"); }
public void TestConcreteExample() { // // Parse Properties File // TextReader propertiesReader = new System.IO.StringReader("%enum:ExecuteEnum Local Remote Ignore Unsupported;Script{%props:1;Source:enum(File Remote);File:0-1;ListenPort:0-1 int4;}RebootCommand {%props:1;Execute:1 enum(Ignore Unsupported Emulator);RemoteHost:0-1;RemotePort:0-1 int4;}UsbSwitchCommand { %props:1; Execute:1 enum ExecuteEnum; Platform:0-1 enum(Windows Linux); RemoteHost:0-1; RemotePort:0-1 int4;}TestCommands { %props:1; Execute:1 enum ExecuteEnum; RemoteHost:0-1; RemotePort:0-1 int4;}"); HmdProperties properties = HmdFileParser.ParsePropertiesFile(propertiesReader, null); properties.ResolveChildParentReferences(); properties.Print(Console.Out); HmdEnum hmdEnum; hmdEnum = properties.TryGetEnum("ExecuteEnum"); Assert.IsNotNull(hmdEnum); Assert.IsTrue(hmdEnum.IsValidEnumValue("local")); Assert.IsTrue(hmdEnum.IsValidEnumValue("remote")); Assert.IsTrue(hmdEnum.IsValidEnumValue("IGNORE")); Assert.IsTrue(hmdEnum.IsValidEnumValue("unsupported")); hmdEnum = properties.TryGetEnum("script.source"); Assert.IsNotNull(hmdEnum); Assert.IsTrue(hmdEnum.IsValidEnumValue("FILE")); Assert.IsTrue(hmdEnum.IsValidEnumValue("remote")); HmdBlockID fileRoot = new HmdBlockID("THE_ROOT!", null); HmdBlockID script = new HmdBlockID("script", fileRoot); Assert.IsNotNull(properties.GetProperties(script)); HmdValueID scriptSource = new HmdValueID("source", "file", script); Assert.IsNotNull(properties.GetProperties(scriptSource)); // // Parse Hmd File // TextReader hmdReader = new System.IO.StringReader("Script {Source:Remote;}RebootCommand {Execute:Unsupported;}UsbSwitchCommand {Execute:Unsupported;}TestCommands {Execute:Local;}"); HmdBlockID rootID = new HmdBlockID(String.Empty, null); HmdFileParser.Parse(rootID, hmdReader, "", null); //HmdValidator.ValidateStatic(rootID, properties); }