StreamLink for Silverlight
CreateSubject Method (listener, subjectName, parameters)
StreamLink for SilverlightCaplin.StreamLinkIStreamLinkProviderCreateSubject(ICommandListener, String, ICreateParameters)
Creates a subject (data item) on the Liberator.
Declaration Syntax
C#Visual BasicVisual C++
void CreateSubject(
	ICommandListener listener,
	string subjectName,
	ICreateParameters parameters
)
Sub CreateSubject ( _
	listener As ICommandListener, _
	subjectName As String, _
	parameters As ICreateParameters _
)
void CreateSubject(
	ICommandListener^ listener, 
	String^ subjectName, 
	ICreateParameters^ parameters
)
Parameters
listener (ICommandListener)
The listener that will receive the results of the create subject command.
subjectName (String)
The name of the subject to be created. For example "/FX/EURUSD".
parameters (ICreateParameters)
The parameters of the subject creation command. To obtain an ICreateParameters object, first obtain the IParametersFactory associated with the IStreamLinkProvider. Then call the CreateCreateParameters(SubjectType) method on the IParametersFactory supplying the required SubjectType (data item type); this will return a valid ICreateParameters object.
Remarks

A subject can only be created if the following conditions are met:

  • The name supplied in the subjectName parameter is not in a namespace owned by a DataSource. For example if a DataSource owns the namespace "/FX/EUR*", StreamLink cannot create a subject with the name "/FX/EURUSD".
  • The user account under which StreamLink is logged in to the Liberator allows write access to the directory where the subject is to be created.
  • The directory exists.

When this method is called checks are made to ensure that the message length will not exceed the maximum message length for the current connection type.

The maximum length of both Type 2 and Type 3 connections can be determined by HttpBodyLength()()(). If the connection type is type 2 or 3 then an ArgumentException will be thrown. See the exception section.

If StreamLink is not currently connected and there is a chance that a message may exceed the maximum size a warning will be logged.

Examples
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using Caplin.StreamLink;
using Caplin.StreamLink.Authentication;
using Caplin.StreamLink.Command;

namespace StreamLinkExamples.Commands
{
    /// <summary>
    /// Create a Subject example
    /// </summary>
    public class CreateASubject
    {
        /// <summary>
        /// Example of how to create a new Record subject on the Liberator.
        /// </summary>
        public static void CreateASubjectExample()
        {
            IStreamLink myStreamLink = new StreamLink();
            myStreamLink.CredentialsProvider = new PasswordCredentialsProvider("admin", "admin");

            ICreateParameters createParameters =
                myStreamLink.StreamLinkProvider.ParametersFactory.CreateCreateParameters(SubjectType.Record);

            // listener called when the command has finished executing
            ICommandListener listener = new ExampleCommandListener();

            // Create command call with be queued
            myStreamLink.StreamLinkProvider.CreateSubject(listener, "Subject", createParameters);

            // Create subject call will be dequeued and executed.
            myStreamLink.StreamLinkProvider.Connect();
        }
    }
}
Exceptions
ExceptionCondition
ArgumentExceptionIf the present connection is a Type 2 or Type 3 connection and the parameters passed would lead to the message length exceeding the HttpBodyLength()()() to Liberator being exceeded.

Assembly: Caplin.StreamLink.Silverlight (Module: Caplin.StreamLink.Silverlight) Version: 5.0.21.0 (5.0.21.0)