当前位置: 首页>>代码示例>>C#>>正文


C# List.ToImmutableArray方法代码示例

本文整理汇总了C#中List.ToImmutableArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToImmutableArray方法的具体用法?C# List.ToImmutableArray怎么用?C# List.ToImmutableArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.ToImmutableArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildMethod

        public SymbolImplementation BuildMethod(SourceMethodDefinitionSymbol methodSymbol)
        {
            var methodBody = methodSymbol.Syntax.Body;
            var symbolTable = (ISymbolTable) methodSymbol.Parent;

            _rootScope = new SymbolScope(symbolTable);
            _currentScope = _rootScope;

            var symbolContext = methodSymbol;
            var implementationNode = methodBody;

            var statements = new List<BoundStatement>();
            var statementBuilder = new StatementBinder(this, symbolContext, _diagnostics);

            if (symbolContext.Parameters != null)
            {
                int parameterCount = symbolContext.Parameters.Length;
                for (int paramIndex = 0; paramIndex < parameterCount; paramIndex++)
                    _currentScope.AddSymbol(symbolContext.Parameters[paramIndex]);
            }

            foreach (var statementNode in implementationNode.Statements)
            {
                var statement = statementBuilder.BuildStatement(statementNode);
                if (statement != null)
                    statements.Add(statement);
            }

            return new SymbolImplementation(statements.ToImmutableArray(), _rootScope);
        }
开发者ID:pminiszewski,项目名称:HlslTools,代码行数:30,代码来源:ImplementationBinder.cs

示例2: GetTypesToRemove

		internal static ImmutableArray<TypeToRemove> GetTypesToRemove(
			this SyntaxNode @this, SemanticModel model, 
			string documentFileNameWithoutExtension)
		{
			var typesToRemove = new List<TypeToRemove>();
			TypeDeclarationSyntax typeToPreserve = null;

			var typeNodes = @this.DescendantNodes(_ => true)
				.OfType<TypeDeclarationSyntax>();

			foreach(var typeNode in typeNodes)
			{
				var type = model.GetDeclaredSymbol(typeNode) as ITypeSymbol;

				if(type.ContainingType == null)
				{
					if(type.Name != documentFileNameWithoutExtension)
					{
						typesToRemove.Add(new TypeToRemove(
							typeNode, type));
					}
					else
					{
						typeToPreserve = typeNode;
					}
				}
			}

			return typesToRemove.ToImmutableArray();
		}
开发者ID:JasonBock,项目名称:CompilerAPIBook,代码行数:30,代码来源:SyntaxNodeExtensions.cs

示例3: ComputePathFromRoot

                private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
                {
                    var path = new List<int>();
                    var root = _tree.GetRoot();

                    while (node != root)
                    {
                        for (; node.Parent != null; node = node.Parent)
                        {
                            var index = GetChildIndex(node);
                            path.Add(index);
                        }

                        // if we were part of structure trivia, continue searching until we get to the true root
                        if (node.IsStructuredTrivia)
                        {
                            var trivia = node.ParentTrivia;
                            var triviaIndex = GetTriviaIndex(trivia);
                            path.Add(triviaIndex);
                            var tokenIndex = GetChildIndex(trivia.Token);
                            path.Add(tokenIndex);
                            node = trivia.Token.Parent;
                            continue;
                        }
                        else if (node != root)
                        {
                            throw new InvalidOperationException(CSharpWorkspaceResources.Node_does_not_descend_from_root);
                        }
                    }

                    path.Reverse();
                    return path.ToImmutableArray();
                }
开发者ID:Rickinio,项目名称:roslyn,代码行数:33,代码来源:CSharpSyntaxTreeFactory.PathSyntaxReference.cs

示例4: Parse

        private ImmutableArray<TodoCommentDescriptor> Parse(string data)
        {
            if (string.IsNullOrWhiteSpace(data))
            {
                return ImmutableArray<TodoCommentDescriptor>.Empty;
            }

            var tuples = data.Split('|');
            var result = new List<TodoCommentDescriptor>(tuples.Length);

            foreach (var tuple in tuples)
            {
                if (string.IsNullOrWhiteSpace(tuple))
                {
                    continue;
                }

                var pair = tuple.Split(':');

                if (pair.Length != 2 || string.IsNullOrWhiteSpace(pair[0]))
                {
                    continue;
                }

                int priority;
                if (!int.TryParse(pair[1], NumberStyles.None, CultureInfo.InvariantCulture, out priority))
                {
                    continue;
                }

                result.Add(new TodoCommentDescriptor(pair[0].Trim(), priority));
            }

            return result.ToImmutableArray();
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:35,代码来源:TodoCommentTokens.cs

示例5: CalculateMerkleRoot

        public static UInt256 CalculateMerkleRoot(ImmutableArray<Transaction> transactions, out ImmutableArray<ImmutableArray<byte>> merkleTree)
        {
            var workingMerkleTree = new List<ImmutableArray<byte>>();

            var hashes = transactions.Select(tx => tx.Hash.ToByteArray().ToImmutableArray()).ToList();

            workingMerkleTree.AddRange(hashes);
            while (hashes.Count > 1)
            {
                workingMerkleTree.AddRange(hashes);

                // ensure row is even length
                if (hashes.Count % 2 != 0)
                    hashes.Add(hashes.Last());

                // pair up hashes in row ({1, 2, 3, 4} into {{1, 2}, {3, 4}}) and then hash the pairs
                // the result is the next row, which will be half the size of the current row
                hashes =
                    Enumerable.Range(0, hashes.Count / 2)
                    .Select(i => hashes[i * 2].AddRange(hashes[i * 2 + 1]))
                    //.AsParallel().AsOrdered().WithExecutionMode(ParallelExecutionMode.ForceParallelism).WithDegreeOfParallelism(10)
                    .Select(pair => Crypto.DoubleSHA256(pair.ToArray()).ToImmutableArray())
                    .ToList();
            }
            Debug.Assert(hashes.Count == 1);

            merkleTree = workingMerkleTree.ToImmutableArray();
            return new UInt256(hashes[0].ToArray());
        }
开发者ID:holinov,项目名称:BitSharp,代码行数:29,代码来源:DataCalculator.cs

示例6: ArenaBehavior

        internal ArenaBehavior(World world, List<Team> teams)
        {
            Requires.NotNull(world, nameof(world));
            Requires.NotNull(teams, nameof(teams));

            this.world = world;
            this.teams = teams.ToImmutableArray();
        }
开发者ID:Lucrecious,项目名称:Battle-Team,代码行数:8,代码来源:ArenaBehavior.cs

示例7: ConcurrentAccess

        public void ConcurrentAccess()
        {
            var source =
@"class A
{
    B F;
    D P { get; set; }
    void M(A a, B b, S s, I i) { }
    delegate void D(S s);
    class B { }
    struct S { }
    interface I { }
}
class B
{
    A M<T, U>() where T : A where U : T, I { return null; }
    event D E;
    delegate void D(S s);
    struct S { }
    interface I { }
}";

            var compilation0 = CreateCompilationWithMscorlib(source, options: TestOptions.DebugDll);
            var compilation1 = compilation0.WithSource(source);

            var builder = new List<Symbol>();
            var type = compilation1.GetMember<NamedTypeSymbol>("A");
            builder.Add(type);
            builder.AddRange(type.GetMembers());
            type = compilation1.GetMember<NamedTypeSymbol>("B");
            builder.Add(type);
            builder.AddRange(type.GetMembers());
            var members = builder.ToImmutableArray();
            Assert.True(members.Length > 10);

            for (int i = 0; i < 10; i++)
            {
                var matcher = new CSharpSymbolMatcher(
                    null,
                    compilation1.SourceAssembly,
                    default(EmitContext),
                    compilation0.SourceAssembly,
                    default(EmitContext),
                    null);

                var tasks = new Task[10];
                for (int j = 0; j < tasks.Length; j++)
                {
                    int startAt = i + j + 1;
                    tasks[j] = Task.Run(() =>
                    {
                        MatchAll(matcher, members, startAt);
                        Thread.Sleep(10);
                    });
                }
                Task.WaitAll(tasks);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:58,代码来源:SymbolMatcherTests.cs

示例8: FormattingOptions

        /// <summary>
        /// Updates the general options.
        /// </summary>
        /// <param name="disableRuleGroups">
        /// The rules that can be turned off for the formatter.
        /// </param>
        /// <param name="tabSize">
        /// How big in spaces the indents are when you format
        /// </param>
        /// <param name="indentSize">
        /// How big in spaces the indents are when you press tab,
        /// </param>
        /// <param name="usingTabs">
        /// Whether or not Keep Tabs is on or off.
        /// </param>
        public FormattingOptions(
            List<DisableableRules> disableRuleGroups,
            uint tabSize, uint indentSize, bool usingTabs)
        {
            Requires.NotNull(disableRuleGroups, nameof(disableRuleGroups));

            this.TabSize = tabSize;
            this.IndentSize = indentSize;
            this.UsingTabs = usingTabs;
            this.RuleGroupsToDisable = disableRuleGroups.ToImmutableArray();
            this.OptionalRuleMap = new OptionalRuleMap(this.RuleGroupsToDisable);
        }
开发者ID:Strongc,项目名称:VSLua,代码行数:27,代码来源:FormattingOptions.cs

示例9: BindTypedefStatement

        private BoundNode BindTypedefStatement(TypedefStatementSyntax declaration)
        {
            var boundType = Bind(declaration.Type, x => BindType(x, null));

            var boundDeclarations = new List<BoundTypeAlias>();
            foreach (var declarator in declaration.Declarators)
            {
                boundDeclarations.Add(Bind(declarator, x => BindTypeAlias(x, boundType.TypeSymbol)));
            }

            return new BoundTypedefStatement(boundDeclarations.ToImmutableArray());
        }
开发者ID:tgjones,项目名称:HlslTools,代码行数:12,代码来源:Binder.Declarations.cs

示例10: IntrinsicSemantics

        static IntrinsicSemantics()
        {
            var allSemantics = new List<SemanticSymbol>();

            // D3D10
            allSemantics.Add(new SemanticSymbol("SV_ClipDistance", "Clip distance data. SV_ClipDistance values are each assumed to be a float32 signed distance to a plane. Primitive setup only invokes rasterization on pixels for which the interpolated plane distance(s) are >= 0. Multiple clip planes can be implemented simultaneously, by declaring multiple component(s) of one or more vertex elements as the SV_ClipDistance. The combined clip and cull distance values are at most D3D#_CLIP_OR_CULL_DISTANCE_COUNT components in at most D3D#_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT registers.", true, SemanticUsages.AllShaders & ~SemanticUsages.VertexShaderInput, IntrinsicTypes.Float));
            allSemantics.Add(new SemanticSymbol("SV_CullDistance", "Cull distance data. When component(s) of vertex Element(s) are given this label, these values are each assumed to be a float32 signed distance to a plane. Primitives will be completely discarded if the plane distance(s) for all of the vertices in the primitive are < 0. Multiple cull planes can be used simultaneously, by declaring multiple component(s) of one or more vertex elements as the SV_CullDistance. The combined clip and cull distance values are at most D3D#_CLIP_OR_CULL_DISTANCE_COUNT components in at most D3D#_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT registers.", true, SemanticUsages.AllShaders & ~SemanticUsages.VertexShaderInput, IntrinsicTypes.Float));
            allSemantics.Add(new SemanticSymbol("SV_Coverage", "A mask that can be specified on input, output, or both of a pixel shader.\n\nFor SV_Coverage on a pixel shader, OUTPUT is supported on ps_4_1 or higher.\n\nFor SV_Coverage on a pixel shader, INPUT requires ps_5_0 or higher.", false, SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_Depth", "Depth buffer data.", false, SemanticUsages.AllShaders, IntrinsicTypes.Float));
            allSemantics.Add(new SemanticSymbol("SV_DepthGreaterEqual", "Tests whether the value is greater than or equal to the depth data value.", true, SemanticUsages.PixelShaderOutput));
            allSemantics.Add(new SemanticSymbol("SV_DepthLessEqual", "Tests whether the value is less than or equal to the depth data value.", true, SemanticUsages.PixelShaderOutput));
            allSemantics.Add(new SemanticSymbol("SV_DispatchThreadID", "Defines the global thread offset within the Dispatch call, per dimension of the group. (read only)", false, SemanticUsages.ComputeShaderInput, IntrinsicTypes.Uint3));
            allSemantics.Add(new SemanticSymbol("SV_DomainLocation", "Defines the location on the hull of the current domain point being evaluated. (read only)", false, SemanticUsages.DomainShaderInput, IntrinsicTypes.Float2, IntrinsicTypes.Float3));
            allSemantics.Add(new SemanticSymbol("SV_GroupID", "Defines the group offset within a Dispatch call, per dimension of the dispatch call. (read only)", false, SemanticUsages.ComputeShaderInput, IntrinsicTypes.Uint3));
            allSemantics.Add(new SemanticSymbol("SV_GroupIndex", "Provides a flattened index for a given thread within a given group. (read only)", false, SemanticUsages.ComputeShaderInput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_GroupThreadID", "Defines the thread offset within the group, per dimension of the group. (read only)", false, SemanticUsages.ComputeShaderInput, IntrinsicTypes.Uint3));
            allSemantics.Add(new SemanticSymbol("SV_GSInstanceID", "Defines the instance of the geometry shader. The instance is needed as a geometry shader can be invoked up to 32 times on the same geometry primitive.", false, SemanticUsages.GeometryShaderInput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_InnerCoverage", "Represents underestimated conservative rasterization information (i.e. whether a pixel is guaranteed-to-be-fully covered).", false, SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput));
            allSemantics.Add(new SemanticSymbol("SV_InsideTessFactor", "Defines the tessellation amount within a patch surface.", false, SemanticUsages.HullShaderOutput | SemanticUsages.DomainShaderInput, IntrinsicTypes.Float, IntrinsicTypes.Float2));
            allSemantics.Add(new SemanticSymbol("SV_InstanceID", "Per-instance identifier automatically generated by the runtime.", false, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("SV_IsFrontFace", "Specifies whether a triangle is front facing. For lines and points, IsFrontFace has the value true. The exception is lines drawn out of triangles (wireframe mode), which sets IsFrontFace the same way as rasterizing the triangle in solid mode.", false, SemanticUsages.GeometryShaderOutput | SemanticUsages.PixelShaderInput, IntrinsicTypes.Bool));
            allSemantics.Add(new SemanticSymbol("SV_OutputControlPointID", "Defines the index of the control point ID being operated on by an invocation of the main entry point of the hull shader.", false, SemanticUsages.HullShaderInput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_Position", "When SV_Position is declared for input to a shader, it can have one of two interpolation modes specified: linearNoPerspective or linearNoPerspectiveCentroid, where the latter causes centroid-snapped xyzw values to be provided when multisample antialiasing. When used in a shader, SV_Position describes the pixel location. Available in all shaders to get the pixel center with a 0.5 offset.", false, SemanticUsages.VertexShaderOutput | SemanticUsages.GeometryShaderInput | SemanticUsages.GeometryShaderOutput | SemanticUsages.PixelShaderInput, IntrinsicTypes.Float4));
            allSemantics.Add(new SemanticSymbol("SV_PrimitiveID", "Per-primitive identifier automatically generated by the runtime.", false, SemanticUsages.GeometryShaderOutput | SemanticUsages.PixelShaderOutput | SemanticUsages.GeometryShaderInput | SemanticUsages.PixelShaderInput | SemanticUsages.HullShaderInput | SemanticUsages.DomainShaderInput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_RenderTargetArrayIndex", "Render-target array index. Applied to geometry shader output and indicates the render target array slice that the primitive will be drawn to by the pixel shader. SV_RenderTargetArrayIndex is only valid if the render target is an array resource. This semantic applies only to primitives, if a primitive has more than one vertex the value from the leading vertex will be used.\nThis value also indicates which array slice of a depthstencilview is used for read / write purposes.", false, SemanticUsages.GeometryShaderOutput | SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_SampleIndex", "Sample frequency index data.", false, SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_StencilRef", "Represents the current pixel shader stencil reference value.", false, SemanticUsages.PixelShaderOutput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_Target", "The output value that will be stored in a render target. The index indicates which of the 8 possibly bound render targets to write to.", true, SemanticUsages.PixelShaderOutput, IntrinsicTypes.Float));
            allSemantics.Add(new SemanticSymbol("SV_TessFactor", "Defines the tessellation amount on each edge of a patch. Available for writing in the hull shader and reading in the domain shader.", false, SemanticUsages.HullShaderOutput | SemanticUsages.DomainShaderInput, IntrinsicTypes.Float2, IntrinsicTypes.Float3, IntrinsicTypes.Float4));
            allSemantics.Add(new SemanticSymbol("SV_VertexID", "Per-vertex identifier automatically generated by the runtime.", false, SemanticUsages.VertexShaderInput, IntrinsicTypes.Uint));
            allSemantics.Add(new SemanticSymbol("SV_ViewportArrayIndex", "Viewport array index. Applied to geometry shader output and indicates which viewport to use for the primitive currently being written out. The primitive will be transformed and clipped against the viewport specified by the index before it is passed to the rasterizer. This semantic applies only to primitives, if a primitive has more than one vertex the value from the leading vertex will be used.", false, SemanticUsages.GeometryShaderOutput | SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput, IntrinsicTypes.Uint));

            // D3D9
            allSemantics.Add(new SemanticSymbol("BINORMAL", "Binormal.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("BLENDINDICES", "Blend indices.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("BLENDWEIGHT", "Blend weights.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("COLOR", "Diffuse or specular color.", true, SemanticUsages.VertexShaderInput | SemanticUsages.VertexShaderOutput | SemanticUsages.PixelShaderInput | SemanticUsages.PixelShaderOutput));
            allSemantics.Add(new SemanticSymbol("NORMAL", "Normal vector.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("POSITION", "Used as input: Vertex position in object space.\nUsed as output: Position of a vertex in homogenous space. Compute position in screen-space by dividing (x,y,z) by w. Every (D3D9) vertex shader must write out a parameter with this semantic.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("POSITIONT", "Transformed vertex position.", false, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("PSIZE", "Point size.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("TANGENT", "Tangent.", true, SemanticUsages.VertexShaderInput));
            allSemantics.Add(new SemanticSymbol("TEXCOORD", "Texture coordinates", true, SemanticUsages.VertexShaderInput | SemanticUsages.VertexShaderOutput | SemanticUsages.PixelShaderInput));
            allSemantics.Add(new SemanticSymbol("FOG", "Vertex fog.", false, SemanticUsages.VertexShaderOutput));
            allSemantics.Add(new SemanticSymbol("PSIZE", "Point size.", true, SemanticUsages.VertexShaderOutput | SemanticUsages.PixelShaderInput));
            allSemantics.Add(new SemanticSymbol("TESSFACTOR", "Tessellation factor.", true, SemanticUsages.VertexShaderOutput));
            allSemantics.Add(new SemanticSymbol("VFACE", "Floating-point scalar that indicates a back-facing primitive. A negative value faces backwards, while a positive value faces the camera.\nNote  This semantic is available in Direct3D 9 Shader Model 3.0. For Direct3D 10 and later, use SV_IsFrontFace instead.", false, SemanticUsages.PixelShaderInput));
            allSemantics.Add(new SemanticSymbol("VPOS", "The pixel location (x,y) in screen space.", false, SemanticUsages.PixelShaderInput));
            allSemantics.Add(new SemanticSymbol("DEPTH", "Depth.", true, SemanticUsages.PixelShaderOutput));

            AllSemantics = allSemantics.ToImmutableArray();
        }
开发者ID:Samana,项目名称:HlslTools,代码行数:52,代码来源:IntrinsicSemantics.cs

示例11: Agent

 public Agent(string assignment, Book book)
     : base("Agent", assignment, book)
 {
     var careers = new List<NormalCareer>
     {
         new Corporate(book),
         new Worker(book),
         new Colonist(book),
         new Thief(book),
         new Enforcer(book),
         new Pirate(book)
     };
     m_Careers = careers.ToImmutableArray();
 }
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:14,代码来源:Agent.cs

示例12: TestProvider

		internal static async Task TestProvider(string file, string fileName,
			Func<Solution, ProjectId, Solution> modifySolution,
			Func<ImmutableArray<CodeAction>, Task> handleActions)
		{
			var code = File.ReadAllText(file);
			var document = TestHelpers.CreateDocument(code, fileName, modifySolution);
			var actions = new List<CodeAction>();
			var actionRegistration = new Action<CodeAction>(action => actions.Add(action));
			var context = new CodeRefactoringContext(document, new TextSpan(0, 1),
				actionRegistration, new CancellationToken(false));

			var provider = new ExtractTypesToFilesCodeRefactoringProvider();
			await provider.ComputeRefactoringsAsync(context);
			await handleActions(actions.ToImmutableArray());
		}
开发者ID:JasonBock,项目名称:CompilerAPIBook,代码行数:15,代码来源:TestHelpers.cs

示例13: FindRenameLocationsAsync

            public async Task<IInlineRenameLocationSet> FindRenameLocationsAsync(OptionSet optionSet, CancellationToken cancellationToken)
            {
                var references = new List<InlineRenameLocation>();

                var renameLocations = await _renameInfo.FindRenameLocationsAsync(
                    renameInStrings: optionSet.GetOption(RenameOptions.RenameInStrings),
                    renameInComments: optionSet.GetOption(RenameOptions.RenameInComments),
                    cancellationToken: cancellationToken).ConfigureAwait(false);

                references.AddRange(renameLocations.Select(
                    ds => new InlineRenameLocation(ds.Document, ds.TextSpan)));

                return new InlineRenameLocationSet(
                    _renameInfo, _document.Project.Solution,
                    references.ToImmutableArray());
            }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:16,代码来源:XamlEditorInlineRenameService.cs

示例14: ProcessLine

        private static ImmutableArray<Cell> ProcessLine(string line, int x)
        {
            var cells = new List<Cell>();

            for (var y = 0; y < line.Length; y++)
            {
                var value = line[y];

                if (value != ' ')
                {
                    cells.Add(new Cell(new Point(x, y), value));
                }
            }

            return cells.ToImmutableArray();
        }
开发者ID:JasonBock,项目名称:IronBefunge,代码行数:16,代码来源:Parser.cs

示例15: GetUnsentEmails

        public ImmutableArray<AlaCarteAssignmentModel> GetUnsentEmails()
        {
            if (SpinWait.SpinUntil(() => Interlocked.CompareExchange(ref operating, 1, 0) != 0, TimeSpan.FromSeconds(30)))
            {
                try
                {
                    bool alreadyOpen = Connection.State == ConnectionState.Open;
                    if (!alreadyOpen)
                        Connection.Open();
                    try
                    {
                        IList<Exception> exceptions = null;
                        IList<AlaCarteAssignmentModel> emails = new List<AlaCarteAssignmentModel>();
                        using (var command = CreateCommand(Connection))
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                try
                                {
                                    var email = Load(reader);
                                    emails.Add(email);
                                }
                                catch(Exception ex)
                                {
                                    (exceptions ?? (exceptions = new List<Exception>(1))).Add(ex);
                                }
                            }
                        }

                        return emails.ToImmutableArray();
                    }
                    finally
                    {
                        if (!alreadyOpen && Connection != null)
                            Connection.Close();
                    }
                }
                finally
                {
                    Interlocked.CompareExchange(ref operating, 0, 1);
                }
            }
            return ImmutableArray<AlaCarteAssignmentModel>.Empty;
        }
开发者ID:zeldafreak,项目名称:Area51,代码行数:45,代码来源:NotificationEmailDb.cs


注:本文中的List.ToImmutableArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。