IndexOfRubySetup() static private method

static private IndexOfRubySetup ( ScriptRuntimeSetup runtimeSetup ) : int
runtimeSetup Microsoft.Scripting.Hosting.ScriptRuntimeSetup
return int
Ejemplo n.º 1
0
        /// <summary>
        /// Adds a new Ruby setup into the given runtime setup unless Ruby setup is already there.
        /// Returns the newly created setup or the existing one.
        /// If non-null <paramref name="newSetupInitializer"/> is given and a new setup is created runs the initializer on the new setup instance.
        /// </summary>
        public static LanguageSetup /*!*/ AddRubySetup(this ScriptRuntimeSetup /*!*/ runtimeSetup, Action <LanguageSetup /*!*/> newSetupInitializer)
        {
            ContractUtils.RequiresNotNull(runtimeSetup, "runtimeSetup");

            LanguageSetup langSetup;
            int           index = Ruby.IndexOfRubySetup(runtimeSetup);

            if (index == -1)
            {
                langSetup = Ruby.CreateRubySetup();
                if (newSetupInitializer != null)
                {
                    newSetupInitializer(langSetup);
                }
                runtimeSetup.LanguageSetups.Add(langSetup);
            }
            else
            {
                langSetup = runtimeSetup.LanguageSetups[index];
            }
            return(langSetup);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves IronRuby setup from the script runtime setup.
        /// </summary>
        /// <param name="runtimeSetup">Runtime setup.</param>
        /// <returns>IronRuby setup or <c>null</c> if the runtime setup doesn't contain one.</returns>
        public static LanguageSetup GetRubySetup(this ScriptRuntimeSetup /*!*/ runtimeSetup)
        {
            int index = Ruby.IndexOfRubySetup(runtimeSetup);

            return((index != -1) ? runtimeSetup.LanguageSetups[index] : null);
        }