TextArgument

Namespace: Cake.Core
We found 10 examples in language CSharp for this search. You will see 28 fragments of code.



        private static ProcessArgumentBuilder AppendDisplayname(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (!string.IsNullOrWhiteSpace(settings.DisplayName))
            {
                builder.Append(new TextArgument("-displayname"));
                builder.Append(new QuotedArgument(new TextArgument(settings.DisplayName)));
            }

            return builder;
        }

        private static ProcessArgumentBuilder AppendDescription(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (!string.IsNullOrWhiteSpace(settings.Description))
            {
                builder.Append(new TextArgument("-description"));
                builder.Append(new QuotedArgument(new TextArgument(settings.Description)));
            }

            return builder;
        }

        private static ProcessArgumentBuilder AppendServiceName(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (!string.IsNullOrWhiteSpace(settings.ServiceName))
            {
                builder.Append(new TextArgument("-servicename"));
                builder.Append(new QuotedArgument(new TextArgument(settings.ServiceName)));
            }

            return builder;
        }

        private static ProcessArgumentBuilder AppendNetworkService(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (settings.NetworkService)
            {
                builder.Append(new TextArgument("--networkservice"));
            }

            return builder;
        }

        private static ProcessArgumentBuilder AppendLocalService(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (settings.LocalService)
            {
                builder.Append(new TextArgument("--localservice"));
            }

            return builder;
        }

        private static ProcessArgumentBuilder AppendLocalSystem(this ProcessArgumentBuilder builder, TopshelfSettings settings)
        {
            if (settings.LocalSystem)
            {
                builder.Append(new TextArgument("--localsystem"));
            }

            return builder;
        }


        protected override void ExecuteCommand(string[] args)
        {
            var text = textArgument.Value;
            var hasher = HashFactory.Crypto.SHA3.CreateKeccak256();
            var hash = hasher.ComputeBytes(Encoding.UTF8.GetBytes(text)).GetBytes();

            Console.WriteLine("Signature : {0}", Convert.ToBase64String(hash));
        }

using Cake.Core.IO.Arguments;

namespace Cake.Curl.Arguments
{
    /// <summary>
    /// Represents an argument that consists of
    /// a name and a value separated by a character.
    /// </summary>
    internal class NameValueArgument : ConcatenatedArgument
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NameValueArgument"/> class.
        /// </summary>
        /// <param name="name">The name part of the argument.</param>
        /// <param name="separator">The separator between the name and the value.</param>
        /// <param name="value">The value part of the argument.</param>
        public NameValueArgument(
            string name,
            string separator,
            string value)
            : base(
                new TextArgument(name),
                new TextArgument(separator),
                new TextArgument(value))
        {
        }
    }
}


            [Fact]
            public void ShouldAppendProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .AppendQuoted(new TextArgument("text arg"))
                    .RenderSafe();

                Assert.Equal("\"text arg\"", result);
            }

            [Fact]
            public void ShouldPrependProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .Append("last")
                    .PrependQuoted(new TextArgument("text arg"))
                    .RenderSafe();

                Assert.Equal("\"text arg\" last", result);
            }

            [Fact]
            public void ShouldAppendProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .AppendSecret(new TextArgument("text arg"))
                    .Render();

                Assert.Equal("text arg", result);
            }

            [Fact]
            public void ShouldPrependProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .Append("last")
                    .PrependSecret(new TextArgument("text arg"))
                    .Render();

                Assert.Equal("text arg last", result);
            }

            [Fact]
            public void ShouldAppendProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .AppendQuotedSecret(new TextArgument("text arg"))
                    .Render();

                Assert.Equal("\"text arg\"", result);
            }

            [Fact]
            public void ShouldPrependProcessArgument()
            {
                var result = new ProcessArgumentBuilder()
                    .Append("last")
                    .PrependQuotedSecret(new TextArgument("text arg"))
                    .Render();

                Assert.Equal("\"text arg\" last", result);
            }

using Cake.Core.IO.Arguments;

namespace Cake.Curl.Arguments
{
    /// <summary>
    /// Represents an argument that consists of
    /// a name and a secret value separated by a character.
    /// </summary>
    internal class NameSecretValueArgument : ConcatenatedArgument
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NameSecretValueArgument"/> class.
        /// </summary>
        /// <param name="name">The name part of the argument.</param>
        /// <param name="separator">The separator between the name and the value.</param>
        /// <param name="secretValue">The secret value part of the argument.</param>
        public NameSecretValueArgument(
            string name,
            string separator,
            string secretValue)
            : base(
                new TextArgument(name),
                new TextArgument(separator),
                new SecretArgument(new TextArgument(secretValue)))
        {
        }
    }
}


        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<RuntimeArgument>
                {
                    textArgument,
                    textWriterArgument
                });
        }

        protected override void Execute(CodeActivityContext context)
        {
            TextWriter writer = this.TextWriter.Get(context);
            if (writer == null)
            {
                writer = context.GetExtension<TextWriter>() ?? Console.Out;
            }
            Fx.Assert(writer != null, "Writer should fallback to Console.Out and never be null");
            writer.WriteLine(this.Text.Get(context));
        }

			#endregion Variables & Properties

			/* ----------------------------------------------- Functions */
			#region Functions
			public void CleanUp()
			{
				Mode = KindMode.SS6PU;

				Basic.CleanUp();
				PreCalcualation.CleanUp();
				ConfirmOverWrite.CleanUp();
				Collider.CleanUp();
				CheckVersion.CleanUp();

				RuleNameAsset.CleanUp();
				RuleNameAssetFolder.CleanUp();
				PackAttributeAnimation.CleanUp();
				PresetMaterial.CleanUp();
			}

			public bool Load()
			{
				Mode = (KindMode)(EditorPrefs.GetInt(PrefsKeyMode, (int)DefaultMode));

				Basic.Load();
				PreCalcualation.Load();
				ConfirmOverWrite.Load();
				Collider.Load();
				CheckVersion.Load();

				RuleNameAsset.Load();
				RuleNameAssetFolder.Load();
				PackAttributeAnimation.Load();
				PresetMaterial.Load();

				return(true);
			}

			public bool Save()
			{
				EditorPrefs.SetInt(PrefsKeyMode, (int)Mode);

				Basic.Save();
				PreCalcualation.Save();
				ConfirmOverWrite.Save();
				Collider.Save();
				CheckVersion.Save();

				RuleNameAsset.Save();
				RuleNameAssetFolder.Save();
				PackAttributeAnimation.Save();
				PresetMaterial.Save();

				return(true);
			}

			public string[] Export(	bool flagExportCommon,
									bool flagExportBasic,
									bool flagExportPrecalculation,
									bool flagExportCollider,
									bool flagExportConfirmOverWrite,
									bool flagExportCheckVersion,
									bool flagExportRuleNameAsset,
									bool flagExportRuleNameAssetFolder,
									bool flagPackAttributeAnimation,
									bool flagPresetMaterial
								)
			{
				string[] exportCommon = (true == flagExportCommon) ? ExportCommon() : null;
				string[] exportBasic = (true == flagExportBasic) ? Basic.Export() : null;
				string[] exportPrecalculation = (true == flagExportPrecalculation) ? PreCalcualation.Export() : null;
				string[] exportConfirmOverWrite = (true == flagExportConfirmOverWrite) ? ConfirmOverWrite.Export() : null;
				string[] exportCollider = (true == flagExportCollider) ? Collider.Export() : null;
				string[] exportCheckVersion = (true == flagExportCheckVersion) ? CheckVersion.Export() : null;
				string[] exportRuleNameAsset = (true == flagExportRuleNameAsset) ? RuleNameAsset.Export() : null;
				string[] exportRuleNameAssetFolder = (true == flagExportRuleNameAssetFolder) ? RuleNameAssetFolder.Export() : null;
				string[] exportPackAttributeAnimation = (true == flagPackAttributeAnimation) ? PackAttributeAnimation.Export() : null;
				string[] exportPresetMaterial = (true == flagPresetMaterial) ? PresetMaterial.Export() : null;

				int countCommon = (null != exportCommon) ? exportCommon.Length : 0;
				int countBasic = (null != exportBasic) ? exportBasic.Length : 0;
				int countPrecalculation = (null != exportPrecalculation) ? exportPrecalculation.Length : 0;
				int countConfirmOverWrite = (null != exportConfirmOverWrite) ? exportConfirmOverWrite.Length : 0;
				int countCollider = (null != exportCollider) ? exportCollider.Length : 0;
				int countCheckVersion = (null != exportCheckVersion) ? exportCheckVersion.Length : 0;
				int counttRuleNameAsset = (null != exportRuleNameAsset) ? exportRuleNameAsset.Length : 0;
				int counttRuleNameAssetFolder = (null != exportRuleNameAssetFolder) ? exportRuleNameAssetFolder.Length : 0;
				int countPackAttributeAnimation = (null != exportPackAttributeAnimation) ? exportPackAttributeAnimation.Length : 0;
				int countPresetMaterial = (null != exportPresetMaterial) ? exportPresetMaterial.Length : 0;

				int count = 0;
				count += countCommon;
				count += countBasic;
				count += countPrecalculation;
				count += countConfirmOverWrite;
				count += countCollider;
				count += countCheckVersion;
				count += counttRuleNameAsset;
				count += counttRuleNameAssetFolder;
				count += countPackAttributeAnimation;
				count += countPresetMaterial;

				string[] exportAll = new string[count];
				count = 0;
				for(int i=0; i<countCommon; i++)
				{
					exportAll[count] = exportCommon[i];
					count++;
				}
				for(int i=0; i<countBasic; i++)
				{
					exportAll[count] = exportBasic[i];
					count++;
				}
				for(int i=0; i<countPrecalculation; i++)
				{
					exportAll[count] = exportPrecalculation[i];
					count++;
				}
				for(int i=0; i<countConfirmOverWrite; i++)
				{
					exportAll[count] = exportConfirmOverWrite[i];
					count++;
				}
				for(int i=0; i<countCollider; i++)
				{
					exportAll[count] = exportCollider[i];
					count++;
				}
				for(int i=0; i<countCheckVersion; i++)
				{
					exportAll[count] = exportCheckVersion[i];
					count++;
				}

				for(int i=0; i<counttRuleNameAsset; i++)
				{
					exportAll[count] = exportRuleNameAsset[i];
					count++;
				}
				for(int i=0; i<counttRuleNameAssetFolder; i++)
				{
					exportAll[count] = exportRuleNameAssetFolder[i];
					count++;
				}
				for(int i=0; i<countPackAttributeAnimation; i++)
				{
					exportAll[count] = exportPackAttributeAnimation[i];
					count++;
				}
				for(int i=0; i<countPresetMaterial; i++)
				{
					exportAll[count] = exportPresetMaterial[i];
					count++;
				}

				return(exportAll);
			}

			public bool Import(string text)
			{
				string[] textArgument = LibraryEditor_SpriteStudio6.Utility.ExternalText.LineDecodeCommand(text);
				if((null == textArgument) || (0 >= textArgument.Length))
				{	/* Invalid */
					return(false);
				}

				if(true == ImportCommon(textArgument))
				{
					return(true);
				}
				if(true == Basic.Import(textArgument))
				{
					return(true);
				}
				if(true == PreCalcualation.Import(textArgument))
				{
					return(true);
				}
				if(true == ConfirmOverWrite.Import(textArgument))
				{
					return(true);
				}
				if(true == Collider.Import(textArgument))
				{
					return(true);
				}
				if(true == CheckVersion.Import(textArgument))
				{
					return(true);
				}

				if(true == RuleNameAsset.Import(textArgument))
				{
					return(true);
				}
				if(true == RuleNameAssetFolder.Import(textArgument))
				{
					return(true);
				}
				if(true == PackAttributeAnimation.Import(textArgument))
				{
					return(true);
				}
				if(true == PresetMaterial.Import(textArgument))
				{
					return(true);
				}

				return(false);
			}

			private string[] ExportCommon()
			{
				string[] textExport = new string[1];

				textExport[0] = LibraryEditor_SpriteStudio6.Utility.ExternalText.LineEncodeCommand(TextKeyMode, TextArgumentMode[(int)Mode]);

				return(textExport);
			}


        private string TextArgument(string[] args, ref int i)
        {
            if (args.Length < i + 2) throw new ArgumentException();
            string value = args[++i];

            if (value[0] == '-' || value[0] == '/') throw new ArgumentException();
            return value;
        }


        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<RuntimeArgument>
                {
                    textArgument,
                    textWriterArgument
                });
        }

        protected override void Execute(CodeActivityContext context)
        {
            TextWriter writer = this.TextWriter.Get(context);
            if (writer == null)
            {
                writer = context.GetExtension<TextWriter>() ?? Console.Out;
            }
            Fx.Assert(writer != null, "Writer should fallback to Console.Out and never be null");
            writer.WriteLine(this.Text.Get(context));
        }


        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<RuntimeArgument>
                {
                    textArgument,
                    textWriterArgument
                });
        }

        protected override void Execute(CodeActivityContext context)
        {
            TextWriter writer = this.TextWriter.Get(context);
            if (writer == null)
            {
                writer = context.GetExtension<TextWriter>() ?? Console.Out;
            }
            Fx.Assert(writer != null, "Writer should fallback to Console.Out and never be null");
            writer.WriteLine(this.Text.Get(context));
        }

Cake.Core.IO.Arguments.TextArgument : IProcessArgument

Constructors :

public TextArgument(String text = )

Methods :

public String Render()
public String RenderSafe()
public String ToString()
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods