ForEachEnumeratorHost.CollectionEnumerator 属性

定义

获取或设置一个布尔值,该值指示宿主枚举器是否枚举对象集合或枚举集合。

public:
 property bool CollectionEnumerator { bool get(); void set(bool value); };
public bool CollectionEnumerator { get; set; }
member this.CollectionEnumerator : bool with get, set
Public Property CollectionEnumerator As Boolean

属性值

一个布尔值,指示枚举器正在循环访问的内容。

实现

示例

下面的代码示例创建一个ForEachEnumeratorHostForEachSMOEnumerator用于保存枚举器并显示主机属性。

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

namespace Microsoft.SqlServer.SSIS.Sample  
{  
    internal class EnumType  
    {  
        public const string SMOEnum = "Foreach SMO Enumerator";  
    }  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application app = new Application();  
            ForEachEnumeratorInfos infos = app.ForEachEnumeratorInfos;  
            ForEachEnumeratorInfo info = null;  

            foreach (ForEachEnumeratorInfo enumInfo in infos)  
            {  
                Console.Write("Available enumerators: {0}\n", enumInfo.Name);  
                if (enumInfo.Name == EnumType.SMOEnum)  
                {  
                    // Set the ForEachEnumeratorInfo variable  
                    // to the SMo enumerator, and use it   
                    // later in the CreateNew method.  
                    info = enumInfo;  
                }  
        }  
            ForEachEnumeratorHost enumH = info.CreateNew();  
            Console.WriteLine();  
            Console.WriteLine("Host InnerObject: " + enumH.InnerObject.ToString());  
            Console.WriteLine("CollectionEnumerator? {0}", enumH.CollectionEnumerator);  
            Console.WriteLine("CreationName: {0}",  enumH.CreationName);  
            Console.WriteLine("Description:  {0}", enumH.Description);  
            Console.WriteLine("Value of DelayValidation: {0}", enumH.DelayValidation);  
            Console.WriteLine("HostType:    {0}", enumH.HostType);  
            Console.WriteLine("ID:          {0}", enumH.ID);  
            Console.WriteLine("Name:        {0}", enumH.Name);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime.Enumerators.SMO  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace Microsoft.SqlServer.SSIS.Sample  
    Friend Class EnumType  
        Public const String SMOEnum = "Foreach SMO Enumerator"  
    End Class  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   
            Dim infos As ForEachEnumeratorInfos =  app.ForEachEnumeratorInfos   
            Dim info As ForEachEnumeratorInfo =  Nothing   

            Dim enumInfo As ForEachEnumeratorInfo  
            For Each enumInfo In infos  
                Console.Write("Available enumerators: {0}\n", enumInfo.Name)  
                If enumInfo.Name = EnumType.SMOEnum Then  
                    ' Set the ForEachEnumeratorInfo variable  
                    ' to the SMo enumerator, and use it   
                    ' later in the CreateNew method.  
                    info = enumInfo  
                End If  
            Next  
            Dim enumH As ForEachEnumeratorHost =  info.CreateNew()   
            Console.WriteLine()  
            Console.WriteLine("Host InnerObject: " + enumH.InnerObject.ToString())  
            Console.WriteLine("CollectionEnumerator? {0}", enumH.CollectionEnumerator)  
            Console.WriteLine("CreationName: {0}",  enumH.CreationName)  
            Console.WriteLine("Description:  {0}", enumH.Description)  
            Console.WriteLine("Value of DelayValidation: {0}", enumH.DelayValidation)  
            Console.WriteLine("HostType:    {0}", enumH.HostType)  
            Console.WriteLine("ID:          {0}", enumH.ID)  
            Console.WriteLine("Name:        {0}", enumH.Name)  
        End Sub  
    End Class  
End Namespace  

示例输出:

可用枚举器:Foreach 文件枚举器

可用枚举器:Foreach 项枚举器

可用枚举器:Foreach ADO 枚举器

可用枚举器:Foreach ADO.NET 架构行集枚举器

可用枚举器:Foreach From Variable Enumerator

可用枚举器:Foreach NodeList 枚举器

可用枚举器:Foreach SMO 枚举器

主机 InnerObject:Microsoft.SqlServer.Dts.Runtime.Enumerators.SMO.ForEachSMOEnumerator

CollectionEnumerator? 错误

CreationName: Microsoft.SqlServer.Dts.Runtime.Enumerators.SMO.ForEachSMOEnumerator, Microsoft.SqlServer.ForEachSMOEnumerator, Version=10.0.000.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91

说明:

DelayValidation 的值:False

HostType:ForEachEnumerator

ID: {C91BA4D0-6AD4-4BEE-A7C4-9A737880773E}

名称: {C91BA4D0-6AD4-4BEE-A7C4-9A737880773E}

注解

true 指示枚举器正在循环访问集合集合。 如果 false,枚举器将循环访问对象的集合。

适用于