/// <summary> /// Adds a record topic with supplied metadata and optional initial content. /// /// This example shows details being created and would be fine when creating topics that are all different, but /// if creating many record topics with the same details, then it is far more efficient to pre-create the /// details. /// </summary> /// <param name="topicPath">The full topic path.</param> /// <param name="metadata">The pre-created record metadata.</param> /// <param name="initialValue">The optional initial value for the topic which must have been created to match /// the supplied metadata.</param> /// <param name="context">The context passed back to the callback when the topic is created.</param> /// <param name="callback">To notify the result of the operation.</param> public void AddRecordTopic(string topicPath, IMContent metadata, IContent initialValue, string context, ITopicControlAddContextCallback <string> callback) { var details = topicControl.CreateDetailsBuilder <IRecordTopicDetailsBuilder>().Metadata(metadata).Build(); topicControl.AddTopic(topicPath, details, initialValue, context, callback); }
/// <summary> /// Add a record topic from a list of initial values. /// /// This demonstrates the simplest mechanism for adding a record topic by supplying values that both the /// metadata and the initial values are derived from. /// </summary> /// <param name="topicPath">The full topic path.</param> /// <param name="initialValues">The initial values for the topic fields which will also be used to derive the /// metadata definition of the topic.</param> /// <param name="context">This will be passed back to the callback when reporting success or failure of the /// topic add.</param> /// <param name="callback">To notify the result of the operation.</param> /// <returns></returns> public ITopicDetails AddRecordTopic(string topicPath, List <string> initialValues, string context, ITopicControlAddContextCallback <string> callback) { return(topicControl.AddTopicFromValue(topicPath, Diffusion.Content.NewBuilder <IRecordContentBuilder>().PutFields(initialValues.ToArray()).Build(), context, callback)); }
/// <summary> /// Adds a topic with the type derived from the value. /// /// This uses the simple convenience method for adding topics where the topic type and metadata are derived /// from a supplied value which can be any object. For example, an integer would result in a single value topic /// of type 'integer'. /// </summary> /// <typeparam name="T">The value type.</typeparam> /// <param name="topicPath">The full topic path.</param> /// <param name="initialValue">An optional initial value for the topic.</param> /// <param name="context">This will be passed back to the callback when reporting success or failure of the /// topic add.</param> /// <param name="callback">To notify the result of the operation.</param> /// <returns>The topic details used to add the topic.</returns> public ITopicDetails AddTopicForValue <T>( string topicPath, T initialValue, string context, ITopicControlAddContextCallback <string> callback) { return(topicControl.AddTopicFromValue(topicPath, initialValue, context, callback)); }
/// <summary> /// Adds a new conversion rate in terms of base currency and target currency. /// /// The bid and ask rates are entered as strings which may be a decimal value; this will be parsed and /// validated, rounding to 5 decimal places. If a zero-length string ("") is supplied, the rate will be set to /// 'empty' and clients will receive a zero-length string in the initial load. /// </summary> /// <param name="currency">The base currency (e.g. GBP).</param> /// <param name="targetCurrency">The target current (e.g. USD).</param> /// <param name="bid">The 'bid' rate.</param> /// <param name="ask">The 'ask' rate.</param> /// <param name="callback">A callback which will be called to report the outcome. The context in the callback /// wil be currency/target currency (e.g. "GBP/USD").</param> public void AddRate(string currency, string targetCurrency, string bid, string ask, ITopicControlAddContextCallback <string> callback) { topicControl.AddTopic(RateTopicName(currency, targetCurrency), topicDetails, CreateRateContent(bid, ask), string.Format("{0}/{1}", currency, targetCurrency), callback); }
/// <summary> /// Add a new rates topic. /// </summary> /// <param name="currency">the base currency</param> /// <param name="values">the full map of initial rates values</param> /// <param name="callback"> reports outcome</param> public void AddRates(string currency, IDictionary <string, string> values, ITopicControlAddContextCallback <string> callback) { topicControl.AddTopic(RateTopicName(currency), TopicType.JSON, MapToJSON(values), currency, callback); }
/// <summary> /// Adds a new conversion rate in terms of base currency and target currency. /// /// The bid and ask rates are entered as strings which may be a decimal value; this will be parsed and /// validated, rounding to 5 decimal places. If a zero-length string ("") is supplied, the rate will be set to /// 'empty' and clients will receive a zero-length string in the initial load. /// </summary> /// <param name="currency">The base currency (e.g. GBP).</param> /// <param name="targetCurrency">The target current (e.g. USD).</param> /// <param name="bid">The 'bid' rate.</param> /// <param name="ask">The 'ask' rate.</param> /// <param name="callback">A callback which will be called to report the outcome. The context in the callback /// wil be currency/target currency (e.g. "GBP/USD").</param> public void AddRate( string currency, string targetCurrency, string bid, string ask, ITopicControlAddContextCallback<string> callback ) { topicControl.AddTopic( RateTopicName( currency, targetCurrency ), topicDetails, CreateRateContent( bid, ask ), string.Format( "{0}/{1}", currency, targetCurrency ), callback ); }
/// <summary> /// Add a new rates topic. /// </summary> /// <param name="currency">the base currency</param> /// <param name="values">the full map of initial rates values</param> /// <param name="callback"> reports outcome</param> public void AddRates( string currency, IDictionary<string, string> values, ITopicControlAddContextCallback<string> callback ) { topicControl.AddTopic( RateTopicName( currency ), TopicType.JSON, MapToJSON( values ), currency, callback ); }