本文整理汇总了C#中Constants类的典型用法代码示例。如果您正苦于以下问题:C# Constants类的具体用法?C# Constants怎么用?C# Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于命名空间,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CostForLineSwitch
internal double CostForLineSwitch(ILine from,
Constants.LineDirection fromDirection,
ILine to,
Constants.LineDirection toDirection)
{
double cost = double.MaxValue;
if ( fromDirection == Constants.LineDirection.Forward &&
toDirection == Constants.LineDirection.Forward )
{
cost = from.EndPoint.DistanceTo(to.StartPoint);
}
else if ( fromDirection == Constants.LineDirection.Forward &&
toDirection == Constants.LineDirection.Reverse )
{
cost = from.EndPoint.DistanceTo(to.EndPoint);
}
else if ( fromDirection == Constants.LineDirection.Reverse &&
toDirection == Constants.LineDirection.Forward )
{
cost = from.StartPoint.DistanceTo(to.StartPoint);
}
else if ( fromDirection == Constants.LineDirection.Reverse &&
toDirection == Constants.LineDirection.Reverse )
{
cost = from.StartPoint.DistanceTo(to.EndPoint);
}
return cost;
}
示例2: QrResultModel
public QrResultModel(Constants.ResultTypes resultType)
{
using (ResultsService service = new ResultsService())
{
Result = service.GetResultText(resultType);
}
}
示例3: MovePacket
public MovePacket(Objects.Client c, Constants.Direction direction)
: base(c)
{
Direction = direction;
switch (direction)
{
case Tibia.Constants.Direction.Down:
Type = OutgoingPacketType.MoveDown;
break;
case Tibia.Constants.Direction.Up:
Type = OutgoingPacketType.MoveUp;
break;
case Tibia.Constants.Direction.Right:
Type = OutgoingPacketType.MoveRight;
break;
case Tibia.Constants.Direction.Left:
Type = OutgoingPacketType.MoveLeft;
break;
case Tibia.Constants.Direction.DownLeft:
Type = OutgoingPacketType.MoveDownLeft;
break;
case Tibia.Constants.Direction.DownRight:
Type = OutgoingPacketType.MoveDownRight;
break;
case Tibia.Constants.Direction.UpLeft:
Type = OutgoingPacketType.MoveUpLeft;
break;
case Tibia.Constants.Direction.UpRight:
Type = OutgoingPacketType.MoveUpRight;
break;
}
Destination = PacketDestination.Server;
}
示例4: ThenTheFieldShouldBeHiglightedIn
public void ThenTheFieldShouldBeHiglightedIn(Constants.LoginFields fieldName, Constants.Colour colour)
{
var expectedRgbaColour = Utilities.GetRgbaColour(colour);
Assert.NotNull(expectedRgbaColour);
string actualColour;
switch (fieldName)
{
case Constants.LoginFields.Email:
{
actualColour = LoginPage.EmailValidationColor;
}
break;
case Constants.LoginFields.Password:
{
actualColour = LoginPage.PasswordValidationColor;
}
break;
default:
{
throw new AssertionException("No field name defined in test framework");
}
}
Assert.NotNull(expectedRgbaColour);
Assert.AreEqual(expectedRgbaColour, actualColour);
}
示例5: GameOptions
public GameOptions(string TeamOneName, string TeamTwoName, Constants.GameTypeEnumeration GameType, ushort GameLimit)
{
this.teamOneNameField = TeamOneName;
this.teamTwoNameField = TeamTwoName;
this.gameLimitField = GameLimit;
this.gameTypeField = GameType;
}
示例6: ThenIShouldBeOnTheInsightPage
public void ThenIShouldBeOnTheInsightPage(Constants.Page pageType)
{
string expectedPageTitle;
switch (pageType)
{
case Constants.Page.Main:
{
expectedPageTitle = Constants.PageTitle.Main;
}
break;
case Constants.Page.Login:
{
expectedPageTitle = Constants.PageTitle.Login;
}
break;
case Constants.Page.ForgotPassword:
{
expectedPageTitle = Constants.PageTitle.ForgotPassword;
}
break;
default:
{
throw new AssertionException(pageType + " not defined in the test framework!");
}
}
Assert.IsTrue(BasePage.GetCurrentPageTitle().StartsWith(expectedPageTitle), "Page title not as expected.");
}
示例7: FnMatch
private static bool FnMatch(string pattern, string path, Constants flags)
{
if (pattern.Length == 0)
{
return path.Length == 0;
}
var pathName = ((flags & Constants.PathName) != 0);
var noEscape = ((flags & Constants.NoEscape) != 0);
var regexPattern = PatternToRegex(pattern, pathName, noEscape);
if (regexPattern.Length == 0)
{
return false;
}
if (((flags & Constants.DotMatch) == 0) && path.Length > 0 && path[0] == '.')
{
// Starting dot requires an explicit dot in the pattern
if (regexPattern.Length < 4 || regexPattern[2] != '[' || regexPattern[3] != '.')
{
return false;
}
}
var options = RegexOptions.None;
if ((flags & Constants.IgnoreCase) != 0)
{
options |= RegexOptions.IgnoreCase;
}
var match = Regex.Match(path, regexPattern, options);
return match != null && match.Success && (match.Length == path.Length);
}
示例8: AssertLine
private static void AssertLine(ILine actual,
int expectedId,
double expectedX1,
double expectedY1,
double expectedX2,
double expectedY2,
bool isUnknown,
Constants.LineDirection direction)
{
Assert.AreEqual(expectedId,
actual.Id,
"Id");
Assert.AreEqual(expectedX1,
actual.X1,
"X1");
Assert.AreEqual(expectedY1,
actual.Y1,
"Y1");
Assert.AreEqual(expectedX2,
actual.X2,
"X2");
Assert.AreEqual(expectedY2,
actual.Y2,
"Y2");
Assert.AreEqual(isUnknown,
actual.IsUnknown,
"IsUnknown");
Assert.AreEqual(direction,
actual.RunDirection,
"RunDirection");
}
示例9: FloatingText
public FloatingText(String text, Constants.FloatingTextType type, Vector2 position)
{
this.text = text;
this.type = type;
this.position = position;
if (type == Constants.FloatingTextType.Emphasised)
{
velocity = Vector2.Zero;
textColor = Color.White;
scale = 1.3f;
}
else
{
int r = rand.Next(0, 100);
if (r <= 50)
{
velocity = new Vector2(2, -5);
acceleration = new Vector2(0.125f, 0.175f);
}
else
{
velocity = new Vector2(-2, -5);
acceleration = new Vector2(-0.125f, 0.175f);
}
}
}
示例10: Log
public static void Log(Constants.Log importance, string message)
{
#if !DEBUG
if (importance==Constants.Log.Verbose) return;
#endif
CKernel.NewLogMessage(importance,CKernel.Globalization[message]);
}
示例11: Log
public void Log(Constants.Level level, string loggerName, string message)
{
ILog log = LogManager.GetLogger(loggerName);
switch (level)
{
case Constants.Level.TRACE:
log.Trace(message);
break;
case Constants.Level.DEBUG:
log.Debug(message);
break;
case Constants.Level.INFO:
log.Info(message);
break;
case Constants.Level.WARN:
log.Warn(message);
break;
case Constants.Level.ERROR:
log.Error(message);
break;
case Constants.Level.FATAL:
log.Fatal(message);
break;
default:
throw new Exception(string.Format("Logger.Log - unknown level={0}", level));
}
}
示例12: ThenIShouldSeeAListOfAnalysisWithStarting
public void ThenIShouldSeeAListOfAnalysisWithStarting(Constants.SearchResultColoumnName coloumnName, string searchFilterText)
{
BasePage.WaitForAjax(10, true);
switch (coloumnName)
{
case Constants.SearchResultColoumnName.Id:
{
Assert.IsTrue(CreateComparisonPage.IsAnalysisIdStartsWith(searchFilterText),
"All analysis Id on list does not begin with " + searchFilterText);
}
break;
case Constants.SearchResultColoumnName.Name:
{
Assert.IsTrue(CreateComparisonPage.IsAnalysisNameStartsWith(searchFilterText),
"All analysis Name on list does not begin with " + searchFilterText);
}
break;
case Constants.SearchResultColoumnName.Definition:
{
Assert.IsTrue(CreateComparisonPage.IsAnalysisDefinitionStartsWith(searchFilterText),
"All analysis Definition on list does not begin with " + searchFilterText);
}
break;
default:
{
throw new AssertionException("Field not defined in test framework.");
}
}
}
示例13: TestEvent
public TestEvent(Constants.Event eventType, Constants.Phase phase, Constants.SubPhase subphase, string notes)
{
this.EventType = eventType;
this.Phase = phase;
this.SubPhase = subphase;
this.Notes = notes;
this.Time = DateTime.Now;
this.X = -1;
this.Y = -1;
this.Alt = false;
this.Ctrl = false;
this.Shift = false;
this.TargetString = string.Empty;
switch(this.SubPhase)
{
case Constants.SubPhase.FreePractice:
this.subphaseRepetitionNumber = Session.Instance.TimesInFreePractice;
break;
case Constants.SubPhase.ForcedPractice:
this.subphaseRepetitionNumber = Session.Instance.TimesInForcedPractice;
break;
case Constants.SubPhase.Verify:
this.subphaseRepetitionNumber = Session.Instance.TimesInVerify;
break;
default:
this.subphaseRepetitionNumber = 0;
break;
}
}
示例14: Connect
public void Connect(string username, string password, Constants.Server.Region region)
{
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password) || region == Constants.Server.Region.UNK)
throw new ArgumentException("Username, password or region is emtpy");
var address = _serverAddresses.Single(o => o.Key == region).Value;
XMPPClient.UserName = username;
XMPPClient.Password = _passPrefix + password;
XMPPClient.Server = address;
XMPPClient.Domain = _domain;
XMPPClient.Resource = "xiff";
XMPPClient.Port = 5223;
XMPPClient.UseTLS = true;
XMPPClient.UseOldStyleTLS = true;
XMPPClient.AutoAcceptPresenceSubscribe = false;
XMPPClient.AutomaticallyDownloadAvatars = false;
XMPPClient.RetrieveRoster = true;
XMPPClient.OnStateChanged += XMPPClient_OnStateChanged;
XMPPClient.OnRetrievedRoster += XMPPClient_OnRetrievedRoster;
XMPPClient.OnNewConversationItem += XMPPClient_OnNewConversationItem;
XMPPClient.Connect();
}
示例15: Get
public HttpResponseMessageWrapper<Constants> Get(HttpRequestMessage req)
{
// no need to authenticate
//HttpStatusCode code = ResourceHelper.AuthenticateUser(req, TaskStore);
//if (code != HttpStatusCode.OK)
// return new HttpResponseMessageWrapper<Constants>(req, code); // user not authenticated
TaskStore taskstore = TaskStore;
try
{
var actions = taskstore.Actions.OrderBy(a => a.SortOrder).ToList<TaskStoreServerEntities.Action>();
var colors = taskstore.Colors.OrderBy(c => c.ColorID).ToList<Color>();
var fieldTypes = taskstore.FieldTypes.OrderBy(ft => ft.FieldTypeID).ToList<FieldType>();
var listTypes = taskstore.ListTypes.Where(l => l.UserID == null).Include("Fields").ToList<ListType>(); // get the built-in listtypes
var priorities = taskstore.Priorities.OrderBy(p => p.PriorityID).ToList<Priority>();
var constants = new Constants() { Actions = actions, Colors = colors, FieldTypes = fieldTypes, ListTypes = listTypes, Priorities = priorities };
return new HttpResponseMessageWrapper<Constants>(req, constants, HttpStatusCode.OK);
}
catch (Exception)
{
// constants not found - return 404 Not Found
return new HttpResponseMessageWrapper<Constants>(req, HttpStatusCode.NotFound);
}
}