Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add video dubbing client tool and API client sample code. #325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
namespace Microsoft.SpeechServices.CommonLib.CommandParser;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.


using System;
using System.Globalization;

[AttributeUsage(AttributeTargets.Field, Inherited = false)]
public sealed class ArgumentAttribute : Attribute
{
private readonly string flag;
private string description = string.Empty;
private string usagePlaceholder;
private bool optional;
private bool hidden;
private InOutType inoutType;
private string requiredModes;
private string optionalModes;

/// <summary>
/// Initializes a new instance of the <see cref="ArgumentAttribute"/> class.
/// </summary>
/// <param name="optionName">Flag string for this attribute.</param>
public ArgumentAttribute(string optionName)
{
if (optionName == null)
{
throw new ArgumentNullException(nameof(optionName));
}

this.flag = optionName;
}

/// <summary>
/// Gets The parse recognising flag.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Ignore.")]
public string OptionName
{
get { return this.flag.ToLower(CultureInfo.InvariantCulture); }
}

/// <summary>
/// Gets or sets Description will display in the PrintUsage method.
/// </summary>
public string Description
{
get
{
return this.description;
}

set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

this.description = value;
}
}

/// <summary>
/// Gets or sets In the PrintUsage method this will display a place hold for a parameter.
/// </summary>
public string UsagePlaceholder
{
get
{
return this.usagePlaceholder;
}

set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

this.usagePlaceholder = value;
}
}

/// <summary>
/// Gets or sets a value indicating whether (optional = true) means not necessarily in the command-line.
/// </summary>
public bool Optional
{
get { return this.optional; }
set { this.optional = value; }
}

/// <summary>
/// Gets or sets a value indicating whether (Hidden = true) means this option will not be printed in the command-line.
/// While one option is set with Hidden, the Optional must be true.
/// </summary>
public bool Hidden
{
get { return this.hidden; }
set { this.hidden = value; }
}

/// <summary>
/// Gets or sets The in/out type of argument.
/// </summary>
public InOutType InOutType
{
get { return this.inoutType; }
set { this.inoutType = value; }
}

/// <summary>
/// Gets or sets The modes require this argument.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Ignore.")]
public string RequiredModes
{
get
{
return this.requiredModes;
}

set
{
this.requiredModes = value?.ToLower(CultureInfo.InvariantCulture);
}
}

/// <summary>
/// Gets or sets The modes optionally require this argument.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Ignore.")]
public string OptionalModes
{
get
{
return this.optionalModes;
}

set
{
this.optionalModes = value?.ToLower(CultureInfo.InvariantCulture);
}
}

/// <summary>
/// Get required modes in an array.
/// </summary>
/// <returns>Mode array.</returns>
public string[] GetRequiredModeArray()
{
string[] modes = null;
if (!string.IsNullOrEmpty(this.requiredModes))
{
modes = this.requiredModes.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
}

return modes;
}

/// <summary>
/// Get optional modes in an array.
/// </summary>
/// <returns>Mode array.</returns>
public string[] GetOptionalModeArray()
{
string[] modes = null;
if (!string.IsNullOrEmpty(this.optionalModes))
{
modes = this.optionalModes.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
}

return modes;
}
}
Loading