Search Results for

    Show / Hide Table of Contents

    Class Generators

    Factory methods for constructing finite stream generators.

    Inheritance
    System.Object
    Generators
    Namespace: Microsoft.Psi
    Assembly: Microsoft.Psi.dll
    Syntax
    public static class Generators : object

    Methods

    View Source

    Once<T>(Pipeline, T, String)

    Generates stream containing a single message, and keeps the stream open afterwards.

    Declaration
    public static IProducer<T> Once<T>(Pipeline pipeline, T value, string name = "Once")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T value

    The value to publish.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of value to publish.

    Remarks

    The generated stream stays open until the pipeline is shut down.

    View Source

    Range(Pipeline, Int32, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)

    Generates a stream of a finite range of integer values published at a regular interval.

    Declaration
    public static IProducer<int> Range(Pipeline pipeline, int start, int count, TimeSpan interval, DateTime? alignDateTime = null, bool keepOpen = false, string name = "Range")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    System.Int32 start

    The starting value.

    System.Int32 count

    The number of messages to publish.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with the specified time.

    System.Boolean keepOpen

    Indicates whether the stream should be kept open after the specified number of messages have been posted.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<System.Int32>

    A stream of consecutive integers.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    View Source

    Repeat<T>(Pipeline, T, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)

    Generates a finite stream of constant values published at a regular interval.

    Declaration
    public static IProducer<T> Repeat<T>(Pipeline pipeline, T value, int count, TimeSpan interval, DateTime? alignmentDateTime = null, bool keepOpen = false, string name = "Repeat")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T value

    The value to publish.

    System.Int32 count

    The number of messages to publish.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignmentDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the specified alignment time.

    System.Boolean keepOpen

    Indicates whether the stream should be kept open after the specified number of messages have been posted.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline. The generated stream closes once the specified number of messages has been published.

    View Source

    Repeat<T>(Pipeline, T, TimeSpan, Nullable<DateTime>, String)

    Generates an infinite stream of constant values published at a regular interval.

    Declaration
    public static IProducer<T> Repeat<T>(Pipeline pipeline, T value, TimeSpan interval, DateTime? alignmentDateTime = null, string name = "Repeat")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T value

    The value to publish.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignmentDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the specified alignment time.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    View Source

    Return<T>(Pipeline, T, String)

    Generates stream containing a single message, and closes the stream afterwards.

    Declaration
    public static IProducer<T> Return<T>(Pipeline pipeline, T value, string name = "Return")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T value

    The value to publish.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream containing one value of type T.

    Type Parameters
    Name Description
    T

    The type of value to publish.

    Remarks

    The generated stream closes after the message is published.

    View Source

    Sequence<T>(Pipeline, T, Func<T, T>, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)

    Generates a finite stream of values published at a regular interval from a user-provided function.

    Declaration
    public static IProducer<T> Sequence<T>(Pipeline pipeline, T initialValue, Func<T, T> generateNext, int count, TimeSpan interval, DateTime? alignmentDateTime = null, bool keepOpen = false, string name = "Sequence")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T initialValue

    The initial value.

    Func<T, T> generateNext

    The function that generates a new value based on the previous value.

    System.Int32 count

    The number of messages to publish.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignmentDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the specified alignment time.

    System.Boolean keepOpen

    Indicates whether the stream should be kept open after all messages in the sequence have been posted.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    View Source

    Sequence<T>(Pipeline, T, Func<T, T>, TimeSpan, Nullable<DateTime>, String)

    Generates an infinite stream of values published at a regular interval from a user-provided function.

    Declaration
    public static IProducer<T> Sequence<T>(Pipeline pipeline, T initialValue, Func<T, T> generateNext, TimeSpan interval, DateTime? alignmentDateTime = null, string name = "Sequence")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    T initialValue

    The initial value.

    Func<T, T> generateNext

    The function that generates a new value based on the previous value.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignmentDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the specified alignment time.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    View Source

    Sequence<T>(Pipeline, IEnumerable<T>, TimeSpan, Nullable<DateTime>, Boolean, String)

    Generates a stream of values published at a regular interval from a specified enumerable.

    Declaration
    public static IProducer<T> Sequence<T>(Pipeline pipeline, IEnumerable<T> enumerable, TimeSpan interval, DateTime? alignmentDateTime = null, bool keepOpen = false, string name = "Sequence")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    IEnumerable<T> enumerable

    The sequence to publish.

    TimeSpan interval

    The desired time interval between consecutive messages. Defaults to 1 tick.

    System.Nullable<DateTime> alignmentDateTime

    If non-null, this parameter specifies a time to align the generator messages with. If the parameter is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the specified alignment time.

    System.Boolean keepOpen

    Indicates whether the stream should be kept open after all messages in the sequence have been posted.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    View Source

    Sequence<T>(Pipeline, IEnumerable<(T, DateTime)>, Nullable<DateTime>, Boolean, String)

    Generates a stream of values from a specified enumerable that provides the values and corresponding originating times.

    Declaration
    public static IProducer<T> Sequence<T>(Pipeline pipeline, IEnumerable<(T, DateTime)> enumerable, DateTime? startTime = null, bool keepOpen = false, string name = "Sequence")
    Parameters
    Type Name Description
    Pipeline pipeline

    The pipeline to add the component to.

    IEnumerable<System.ValueTuple<T, DateTime>> enumerable

    An enumerable sequence of (data, originating time) pairs.

    System.Nullable<DateTime> startTime

    The explicit start time of the data in the enumeration. Supply this parameter when the enumeration contains data values with absolute originating times (e.g. [value, time] pairs read from a file), and you want to propose a pipeline replay time to take this into account. Otherwise, pipeline playback will be determined by the prevailing replay descriptor (taking into account any other components in the pipeline which may have proposed replay times).

    System.Boolean keepOpen

    Indicates whether the stream should be kept open after all the messages in the enumerable have been posted.

    System.String name

    An optional name for the stream generator.

    Returns
    Type Description
    IProducer<T>

    A stream of values of type T.

    Type Parameters
    Name Description
    T

    The type of data in the sequence.

    Remarks

    When the pipeline is in replay mode, the timing of the messages complies with the speed of the pipeline.

    • View Source
    In This Article
    • Methods
      • Once<T>(Pipeline, T, String)
      • Range(Pipeline, Int32, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)
      • Repeat<T>(Pipeline, T, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)
      • Repeat<T>(Pipeline, T, TimeSpan, Nullable<DateTime>, String)
      • Return<T>(Pipeline, T, String)
      • Sequence<T>(Pipeline, T, Func<T, T>, Int32, TimeSpan, Nullable<DateTime>, Boolean, String)
      • Sequence<T>(Pipeline, T, Func<T, T>, TimeSpan, Nullable<DateTime>, String)
      • Sequence<T>(Pipeline, IEnumerable<T>, TimeSpan, Nullable<DateTime>, Boolean, String)
      • Sequence<T>(Pipeline, IEnumerable<(T, DateTime)>, Nullable<DateTime>, Boolean, String)
    Back to top Privacy & Cookies | Terms Of Use | Trademarks | © Microsoft
    Generated by DocFX