Universal Windows Service Class Library

Trigger.Create Method 

Create a new instance of a specified implemented trigger class.

public static ITrigger Create(
   string typeString
);

Parameters

typeString
String containing the type of a specified trigger class.

Return Value

Object of the given trigger class or null.

Remarks

This function create a new instance of the given trigger class specified as type string.

Firstly the type of the trigger class will be searched in the executing assembly but if no matching type exists there all loaded assemblies will be searched if access is granted.

Exceptions

Exception TypeCondition
ArgumentNullExceptionThrown if no type was given.
TypeLoadExceptionMeans that the given type was not found in all loaded assemblies.

Example

// Try to create instance of a trigger and configure it
try
{
    ITrigger dailyTrigger = Trigger.Create("uws.Triggers.DailyTrigger");
    dailyTrigger.Configure(xmlElement);
    
    if (dailyTrigger.Start() == true)
    {
        Console.WriteLine("Trigger was started");
    }
    else
    {
        Console.WriteLine("Could not start trigger");
    }
}
catch (Exception ex)
{
    Console.WriteLine("Could not create new trigger. " + ex.Message);
}

See Also

Trigger Class | uws.Triggers Namespace | ITrigger