InputCommands ClassDelta Engine Documentation
Commands from a content file which trigger input events. View code on GitHub
Inheritance Hierarchy

System Object
  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

public class InputCommands : XmlContent

The InputCommands type exposes the following members.

Constructors

  NameDescription
Protected methodInputCommands
Initializes a new instance of the InputCommands class
Top
Methods

  NameDescription
Protected methodCreateDefault
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 .)
Public methodDispose (Inherited from ContentData.)
Protected methodDisposeData (Inherited from XmlContent.)
Public methodInternalCreateDefault (Inherited from ContentData.)
Protected methodLoadData (Overrides XmlContent LoadData(Stream).)
Protected methodStatic memberParseTriggers
Public methodToString (Inherited from ContentData.)
Top
Fields

  NameDescription
Protected fieldContentChanged (Inherited from ContentData.)
Top
Properties

  NameDescription
Protected propertyAllowCreationIfContentNotFound (Overrides ContentData AllowCreationIfContentNotFound.)
Public propertyData (Inherited from XmlContent.)
Public propertyIsDisposed (Inherited from ContentData.)
Public propertyMetaData (Inherited from ContentData.)
Public propertyName (Inherited from ContentData.)
Top
Remarks

Tests: DeltaEngine.Content.Xml.Tests.InputCommandsTests
Examples

3 unit tests call DeltaEngine.Content.Xml.InputCommands
[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