Commands from a content file which trigger input events.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Content ContentData
DeltaEngine.Content.Xml XmlContent
DeltaEngine.Content.Xml InputCommands
Namespace: DeltaEngine.Content.Xml
Assembly: DeltaEngine.Content.Xml (in DeltaEngine.Content.Xml.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The InputCommands type exposes the following members.
Constructors
Name | Description | |
---|---|---|
InputCommands | Initializes a new instance of the InputCommands class |
Methods
Name | Description | |
---|---|---|
CreateDefault |
Creates a simple DefaultCommands.xml file in memory and passes it to Command.Register.
Trigger types cannot be created directly here because we have no dependency to Input here.
For better performance with MockResolver the same code is duplicated there, just faster.
View code on GitHub (Overrides ContentData CreateDefault .) | |
Dispose | (Inherited from ContentData.) | |
DisposeData | (Inherited from XmlContent.) | |
InternalCreateDefault | (Inherited from ContentData.) | |
LoadData | (Overrides XmlContent LoadData(Stream).) | |
ParseTriggers | ||
ToString | (Inherited from ContentData.) |
Fields
Name | Description | |
---|---|---|
ContentChanged | (Inherited from ContentData.) |
Properties
Name | Description | |
---|---|---|
AllowCreationIfContentNotFound | (Overrides ContentData AllowCreationIfContentNotFound.) | |
Data | (Inherited from XmlContent.) | |
IsDisposed | (Inherited from ContentData.) | |
MetaData | (Inherited from ContentData.) | |
Name | (Inherited from ContentData.) |
Remarks
Examples
[Test, CloseAfterFirstFrame] public void TestInputCommands() { var inputCommands = ContentLoader.Load<InputCommands>("DefaultCommands"); Assert.AreEqual("DefaultCommands", inputCommands.Name); Assert.IsTrue(inputCommands.InternalAllowCreationIfContentNotFound); }
[Test, CloseAfterFirstFrame] public void LogErrorIfTriggerTypeDoesNotExist() { var logger = new MockLogger(); Assert.Throws<Command.UnableToRegisterCommandWithoutTriggers>( () => ContentLoader.Load<NoDataInputCommands>("NoDataInputCommands").InternalCreateDefault()); Assert.IsTrue(logger.LastMessage.Contains(NonTriggerTypeName), logger.LastMessage); Assert.IsTrue(logger.LastMessage.Contains("MissingMethodException"), logger.LastMessage); logger.Dispose(); }
[Test, CloseAfterFirstFrame, Timeout(5000)] public void CreateDefaultInputCommandsIfContentNotFound() { var inputCommands = ContentLoader.Load<NotExistingInputCommands>("NotExistingInputCommands"); inputCommands.InternalCreateDefault(); foreach (var commandData in inputCommands.Data.Children) { Assert.IsNotEmpty(commandData.Name); Assert.IsNull(commandData.Value); } var exitCommand = new Command(Command.Exit, (Action)null); List<Trigger> triggers = exitCommand.GetTriggers(); Assert.AreEqual(1, triggers.Count); Assert.AreEqual("KeyTrigger", triggers[0].GetShortNameOrFullNameIfNotFound()); }
See Also