Beispiel #1
0
        internal virtual byte[] getGreeting(ISession session, string features)
        {
            int bufferSize = "<greeting></greeting>".Length;
            int profileCount = 0;

            profileCount = profileListeners.Count;

            System.Collections.IEnumerator e = profileListeners.Keys.GetEnumerator();

            //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"'
            while (e.MoveNext())
            {
                //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"'
                bufferSize += ((string) e.Current).Length + "<profile>".Length;
            }

            bufferSize++;

            System.Text.StringBuilder sb = new System.Text.StringBuilder(bufferSize);

            // Create Greeting
            // Wish I could reset these.
            System.Collections.IEnumerator f = profileListeners.Keys.GetEnumerator();

            sb.Append("<greeting");

            if (((object) localize != null) && !localize.Equals(core.StringConstants.LOCALIZE_DEFAULT))
            {
                sb.Append(" localize='");
                sb.Append(localize);
                sb.Append('\'');
            }

            if ((object) features != null)
            {
                sb.Append(" features='");
                sb.Append(features);
                sb.Append('\'');
            }

            sb.Append('>');

            //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"'
            while (f.MoveNext())
            {

                // make sure this profile wants to be advertised
                try
                {
                    //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073"'
                    string profileName = (string) f.Current;
                    InternalProfile profile = (InternalProfile) profileListeners[profileName];
                    bool callAdvertise = false;
                    SessionTuningProperties sessionTuning = session.getTuningProperties();

                    // check the standard tuning settings first
                    for (int i = 0; i < SessionTuningProperties.STANDARD_PROPERTIES.Length; i++)
                    {

                        if ((profile.tuning != null) && (sessionTuning != null) && (profile.tuning.getProperty(SessionTuningProperties.STANDARD_PROPERTIES[i]) != null) && (sessionTuning.getProperty(SessionTuningProperties.STANDARD_PROPERTIES[i]) != null))
                        {
                            callAdvertise = true;
                        }
                    }

                    if ((profile.tuning == null) || (callAdvertise && profile.listener.AdvertiseProfile(session)))
                    {
                        sb.Append("<profile uri='");
                        sb.Append(profileName);
                        sb.Append("' />");
                    }
                }
                catch (BEEPException x)
                {
                    Console.Error.WriteLine(x.ToString());

                    continue;
                }
            }

            sb.Append("</greeting>");

            return System.Text.Encoding.ASCII.GetBytes(sb.ToString());
        }