/// <summary>
        /// Derived classes override this method to return their
        /// particular type of scoped item.
        /// </summary>
        /// <param name="scope">
        /// The scope to look the item up in.
        /// </param>
        /// <param name="path">
        /// The name of the item to retrieve.
        /// </param>
        /// <param name="script">
        /// The scope item that the derived class should return.
        /// </param>
        /// <returns>
        /// True if the scope item was found or false otherwise.
        /// </returns>
        protected override bool GetScopeItem(
            SessionStateScope scope,
            VariablePath path,
            out FunctionInfo script)
        {
            Diagnostics.Assert(path is FunctionLookupPath,
                               "name was scanned incorrect if we get here and it is not a FunctionLookupPath");

            bool result = true;

            _name = path.IsFunction ? path.UnqualifiedPath : path.QualifiedName;

            script = scope.GetFunction(_name);

            if (script != null)
            {
                bool       isPrivate;
                FilterInfo filterInfo = script as FilterInfo;
                if (filterInfo != null)
                {
                    isPrivate = (filterInfo.Options & ScopedItemOptions.Private) != 0;
                }
                else
                {
                    isPrivate = (script.Options & ScopedItemOptions.Private) != 0;
                }

                // If the function is private and the lookup scope
                // isn't the current scope, claim that the function
                // doesn't exist so that the lookup continues.

                if (isPrivate &&
                    scope != sessionState.CurrentScope)
                {
                    result = false;
                }
                else
                {
                    // Now check the visibility of the variable...
                    SessionState.ThrowIfNotVisible(_origin, script);
                }
            }
            else
            {
                result = false;
            }

            return(result);
        }
Exemple #2
0
        protected override bool GetScopeItem(
            SessionStateScope scope,
            ScopedItemLookupPath path,
            out FunctionInfo script)
        {
            bool flag = true;

            this.name = path.ToString();
            if (path.IsScopedItem)
            {
                this.name = path.LookupPath.NamespaceSpecificString;
            }
            script = scope.GetFunction(this.name);
            if (script != null)
            {
                if ((!(script is FilterInfo filterInfo) ? (script.Options & ScopedItemOptions.Private) != ScopedItemOptions.None : (filterInfo.Options & ScopedItemOptions.Private) != ScopedItemOptions.None) && scope != this.sessionState.CurrentScope)
                {
                    flag = false;
                }
                else
                {
                    SessionState.ThrowIfNotVisible(this._origin, (object)script);
                }
            }