CreateInstance() public method

Creates an instance of the COM server.
public CreateInstance ( ) : void
return void
コード例 #1
0
        /// <summary>
        /// Returns a localized client for the specified locale id.
        /// </summary>
        /// <param name="identity">The identity.</param>
        /// <param name="localeId">The locales id.</param>
        /// <returns>A localized client.</returns>
        public ComClient GetLocalizedClient(IUserIdentity identity, int localeId)
        {
            // check if a logon is required.
            string userName = null;

            if (identity != null && identity.TokenType == UserTokenType.UserName)
            {
                userName = (identity.GetIdentityToken() as UserNameIdentityToken).UserName;
            }

            if (String.IsNullOrEmpty(userName) && localeId == ComUtils.LOCALE_SYSTEM_DEFAULT)
            {
                Utils.Trace("COM Client Selected: DEFAULT (no match for locale)");
                return(DefaultClient);
            }

            // create the key.
            StringBuilder buffer = new StringBuilder();

            buffer.Append(localeId);

            if (!String.IsNullOrEmpty(userName))
            {
                buffer.Append(':');
                buffer.Append(userName);
            }

            string key = buffer.ToString();

            if (m_localizedClients == null)
            {
                m_localizedClients = new Dictionary <string, ComClient>();
            }

            ComClient client = null;

            if (!m_localizedClients.TryGetValue(key, out client))
            {
                client              = CreateClient();
                client.Key          = key;
                client.LocaleId     = localeId;
                client.UserIdentity = identity;
                client.CreateInstance();
                m_localizedClients[key] = client;
            }

            // Utils.Trace("COM Client Seleted: {0}", key);
            return(client);
        }