WriteLine.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / WriteLine.cs / 1305376 / WriteLine.cs

                            //---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------

namespace System.Activities.Statements 
{
    using System; 
    using System.ComponentModel; 
    using System.IO;
    using System.Runtime; 
    using System.Activities.Validation;
    using System.Collections.Generic;
    using System.Windows.Markup;
    using System.Collections.ObjectModel; 

    [ContentProperty("Text")] 
    public sealed class WriteLine : CodeActivity 
    {
        public WriteLine() 
        {
        }

        [DefaultValue(null)] 
        public InArgument TextWriter
        { 
            get; 
            set;
        } 

        [DefaultValue(null)]
        public InArgument Text
        { 
            get;
            set; 
        } 

        protected override void CacheMetadata(CodeActivityMetadata metadata) 
        {
            RuntimeArgument textArgument = new RuntimeArgument("Text", typeof(string), ArgumentDirection.In);
            metadata.Bind(this.Text, textArgument);
 
            RuntimeArgument textWriterArgument = new RuntimeArgument("TextWriter", typeof(TextWriter), ArgumentDirection.In);
            metadata.Bind(this.TextWriter, textWriterArgument); 
 
            metadata.SetArgumentsCollection(
                new Collection 
                {
                    textArgument,
                    textWriterArgument
                }); 
        }
 
        protected override void Execute(CodeActivityContext context) 
        {
            TextWriter writer = this.TextWriter.Get(context); 
            if (writer == null)
            {
                writer = context.GetExtension() ?? Console.Out;
            } 
            Fx.Assert(writer != null, "Writer should fallback to Console.Out and never be null");
            writer.WriteLine(this.Text.Get(context)); 
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK