コード例 #1
0
        /// <summary>
        /// Gets the value of the specified alias from the alias table.
        /// </summary>
        ///
        /// <param name="aliasName">
        /// The name of the alias value to retrieve.
        /// </param>
        ///
        /// <param name="scopeID">
        /// A scope identifier that is either one of the "special" scopes like
        /// "global", "script", "local", or "private, or a numeric ID of a relative scope
        /// to the current scope.
        /// </param>
        ///
        /// <returns>
        /// The AliasInfo representing the alias.
        /// </returns>
        ///
        /// <exception cref="ArgumentException">
        /// If <paramref name="scopeID"/> is less than zero, or not
        /// a number and not "script", "global", "local", or "private"
        /// </exception>
        ///
        /// <exception cref="ArgumentOutOfRangeException">
        /// If <paramref name="scopeID"/> is less than zero or greater than the number of currently
        /// active scopes.
        /// </exception>
        ///
        internal AliasInfo GetAliasAtScope(string aliasName, string scopeID)
        {
            AliasInfo result = null;

            if (String.IsNullOrEmpty(aliasName))
            {
                return(null);
            }

            SessionStateScope scope = GetScopeByID(scopeID);

            result = scope.GetAlias(aliasName);

            // Make sure the alias isn't private or if it is that the current
            // scope is the same scope the alias was retrieved from.

            if (result != null &&
                (result.Options & ScopedItemOptions.Private) != 0 &&
                scope != _currentScope)
            {
                result = null;
            }

            return(result);
        } // GetAliasAtScope
コード例 #2
0
        /// <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="name">
        /// The name of the item to retrieve.
        /// </param>
        /// <param name="alias">
        /// 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 name,
            out AliasInfo alias)
        {
            Diagnostics.Assert(!(name is FunctionLookupPath),
                               "name was scanned incorrect if we get here and it is a FunctionLookupPath");

            bool result = true;

            alias = scope.GetAlias(name.QualifiedName);

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

            if (alias == null ||
                ((alias.Options & ScopedItemOptions.Private) != 0 &&
                 scope != sessionState.CurrentScope))
            {
                result = false;
            }

            return(result);
        }
コード例 #3
0
        protected override bool GetScopeItem(SessionStateScope scope, VariablePath name, out AliasInfo alias)
        {
            bool flag = true;

            alias = scope.GetAlias(name.QualifiedName);
            return(((alias != null) && (((alias.Options & ScopedItemOptions.Private) == ScopedItemOptions.None) || (scope == base.sessionState.CurrentScope))) && flag);
        }