50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System;
|
|
namespace SPSolutions.SharePoint.Administration
|
|
{
|
|
public class CommandLineParameterInteger : CommandLineParameter
|
|
{
|
|
private int? m_integerValue;
|
|
private bool? m_hasIntegerValue;
|
|
public int IntegerValue
|
|
{
|
|
get
|
|
{
|
|
if (!this.m_integerValue.HasValue)
|
|
{
|
|
this.ParseIntegerValue();
|
|
}
|
|
return this.m_integerValue.Value;
|
|
}
|
|
}
|
|
public bool HasIntegerValue
|
|
{
|
|
get
|
|
{
|
|
if (!this.m_hasIntegerValue.HasValue)
|
|
{
|
|
this.ParseIntegerValue();
|
|
}
|
|
return this.m_integerValue.HasValue;
|
|
}
|
|
}
|
|
public CommandLineParameterInteger(string name, bool isRequired) : this(name, isRequired, 0)
|
|
{
|
|
}
|
|
public CommandLineParameterInteger(string name, bool isRequired, int defaultValue) : base(name, isRequired, defaultValue.ToString(), new CommandLineParameterIntegerValidator(), string.Empty)
|
|
{
|
|
}
|
|
private void ParseIntegerValue()
|
|
{
|
|
int value;
|
|
if (int.TryParse(base.Value, out value))
|
|
{
|
|
this.m_integerValue = new int?(value);
|
|
this.m_hasIntegerValue = new bool?(true);
|
|
return;
|
|
}
|
|
this.m_integerValue = new int?(0);
|
|
this.m_hasIntegerValue = new bool?(false);
|
|
}
|
|
}
|
|
}
|