Поделиться через


VariableDispenser.GetVariables Method

Locks the variables that are in the read-only list and the read/write list.

Пространство имен: Microsoft.SqlServer.Dts.Runtime
Сборка: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Синтаксис

'Декларация
Public Sub GetVariables ( _
    ByRef variables As Variables _
)
public void GetVariables (
    ref Variables variables
)
public:
void GetVariables (
    Variables^% variables
)
public void GetVariables (
    /** @ref */ Variables variables
)
JScript не поддерживает передачу аргументов типа, содержащего значение, по ссылке.

Параметры

  • variables
    The collection that contains all the variables found in the read-only list and the read/write list.

Замечания

Изменения образцов кода17 июля 2006 г.

Call this method to lock all the variables previously added to the read-only list or the read/write list.

If the call succeeds, the lists are freed and the requested variables are combined into a single collection, with each variable locked for the access specified. To unlock the variables, release the variable collection using Unlock on the Variables collection.

If the call fails, the lists remain, but the variables are not locked.

ms191051.note(ru-ru,SQL.90).gifПримечание.
It is desirable to maintain a lock on the variable for the minimum amount of time required. This allows other components and tasks to acquire locks and facilitates sharing of the variables.

Пример

The following code example creates a VariableDispenser and adds two system variables to the list that is locked for reading. Then the GetVariables is called to lock both variables in the collection, and the lists are freed and made available for new variables.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace Microsoft.SqlServer.SSIS.Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            Package pkg = new Package();
            Variables vars = null;
            VariableDispenser variableDispenser = pkg.VariableDispenser;
            variableDispenser.LockForRead("System::PackageName");
            variableDispenser.LockForRead("System::OfflineMode");
            variableDispenser.GetVariables(ref vars);           
            // Verify that the variable is locked before unlocking.
            Console.WriteLine("Variables are locked? {0}", vars.Locked);
            foreach (Variable myVar in vars)
            {
                Console.WriteLine("Name        {0}", myVar.Name);
                Console.WriteLine("Description {0}", myVar.Description);
                Console.WriteLine();
            }
            // Use Contains to determine whether indexing can be used.
            Boolean pkgName = variableDispenser.Contains("PackageName");
            String qName = variableDispenser.GetQualifiedName("PackageName");
            Console.WriteLine("Contains is valid?       {0}", pkgName);
            Console.WriteLine("Fully qualified name is: {0}", qName);

            vars.Unlock();

            Console.WriteLine("Variables are locked? {0}", vars.Locked);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
 
Namespace Microsoft.SqlServer.SSIS.Sample
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim pkg As Package =  New Package() 
            Dim vars As Variables =  Nothing 
            Dim variableDispenser As VariableDispenser =  pkg.VariableDispenser 
            variableDispenser.LockForRead("System::PackageName")
            variableDispenser.LockForRead("System::OfflineMode")
            variableDispenser.GetVariables( vars)
            ' Verify that the variable is locked before unlocking.
            Console.WriteLine("Variables are locked? {0}", vars.Locked)
            Dim myVar As Variable
            For Each myVar In vars
                Console.WriteLine("Name        {0}", myVar.Name)
                Console.WriteLine("Description {0}", myVar.Description)
                Console.WriteLine()
            Next
            ' Use Contains to determine whether indexing can be used.
            Dim pkgName As Boolean =  variableDispenser.Contains("PackageName") 
            Dim qName As String =  variableDispenser.GetQualifiedName("PackageName") 
            Console.WriteLine("Contains is valid?       {0}", pkgName)
            Console.WriteLine("Fully qualified name is: {0}", qName)

            vars.Unlock()

            Console.WriteLine("Variables are locked? {0}", vars.Locked)
        End Sub
    End Class
End Namespace

Sample Output:

Variables are locked? True

Name OfflineMode

Description The offline mode currently set for the package

Name PackageName

Description The package name

Contains is valid? True

Fully qualified name is: System::PackageName

Variables are locked? False

Синхронизация потоков

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Платформы

Платформы разработки

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

Целевые платформы

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

См. также

Справочник

VariableDispenser Class
VariableDispenser Members
Microsoft.SqlServer.Dts.Runtime Namespace