我需要在SSO中存储可配置的值,并在运行时在自定义管道组件中检索它们
对此有任何帮助......
答案 0 :(得分:3)
有关在SSO中存储值的帮助,请参阅this post。
就在管道组件中检索它们,您可以创建一个辅助函数。这样的事情会起作用:
using System;
using System.Collections;
using System.Collections.Specialized;
using Microsoft.BizTalk.SSOClient.Interop;
/// <summary>
/// Contains helper methods for using SSO as a config store.
/// </summary>
public static class SSOConfigHelper
{
/// <summary>
/// Can be set to anything
/// </summary>
private static string idenifierGUID = "ConfigProperties";
/// <summary>
/// Read method helps get configuration data
/// </summary>
/// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
/// <param name="propName">The property name to read</param>
/// <returns>
/// The value of the property stored in the given affiliate application of this component.
/// </returns>
public static string Read(string appName, string propName)
{
try
{
SSOConfigStore ssoStore = new SSOConfigStore();
ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
object propertyValue = null;
appMgmtBag.Read(propName, out propertyValue, 0);
return (string)propertyValue;
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(e.Message);
throw;
}
}
}
// The code above uses this propertybag
public class ConfigurationPropertyBag : IPropertyBag
{
/// <summary>
/// The properties
/// </summary>
private HybridDictionary properties;
/// <summary>
/// Initializes a new instance of the ConfigurationPropertyBag class
/// </summary>
internal ConfigurationPropertyBag()
{
this.properties = new HybridDictionary();
}
#region IPropertyBag Members
/// <summary>
/// Implements IPropertyBag read
/// </summary>
/// <param name="propName">IPropertyBag propName</param>
/// <param name="ptrVar">IPropertyBag ptrVar</param>
/// <param name="errorLog">IPropertyBag errLog</param>
public void Read(string propName, out object ptrVar, int errorLog)
{
ptrVar = this.properties[propName];
}
/// <summary>
/// Implements IPropertyBag write
/// </summary>
/// <param name="propName">IPropertyBag propName</param>
/// <param name="ptrVar">IPropertyBag ptrVar</param>
public void Write(string propName, ref object ptrVar)
{
this.properties.Add(propName, ptrVar);
}
#endregion
/// <summary>
/// Searches for property key
/// </summary>
/// <param name="key">key of kv pair</param>
/// <returns>true if key found</returns>
public bool Contains(string key)
{
return this.properties.Contains(key);
}
/// <summary>
/// Removes property
/// </summary>
/// <param name="key">key of kv pair</param>
public void Remove(string key)
{
this.properties.Remove(key);
}
}
(如果它对您有所帮助,请同时推荐链接的帖子)
答案 1 :(得分:1)