本文整理汇总了C#中Utility类的典型用法代码示例。如果您正苦于以下问题:C# Utility类的具体用法?C# Utility怎么用?C# Utility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utility类属于命名空间,在下文中一共展示了Utility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testLandOn
public void testLandOn()
{
Utility util = new Utility();
//Create two players
Player p1 = new Player("Bill");
Player p2 = new Player("Fred", 1500);
string msg;
//test landon normally with no rent payable
msg = util.landOn(ref p1);
Console.WriteLine(msg);
//set owner to p1
util.setOwner(ref p1);
//move p2 so that utility rent can be calculated
p2.move();
//p2 lands on util and should pay rent
msg = util.landOn(ref p2);
Console.WriteLine(msg);
//check that correct rent has been paid
decimal balance = 1500 - (6 * p2.getLastMove());
Assert.AreEqual(balance, p2.getBalance());
}
示例2: Start
void Start()
{
if (!instance)
instance = this;
else
Debug.LogError ("Utility not an instance");
}
示例3: btnUpdate_Click
protected void btnUpdate_Click(object sender, EventArgs e)
{
FeedRepository rfeed = new FeedRepository();
Utility Util = new Utility();
Feed feed = new Feed();
feed.Author = Author.Value;
feed.Title = title.Value;
feed.Summary = Summary.Value;
feed.Description = Description.Value;
feed.Link = Link.Value;
feed.CategoryID = Int16.Parse(CategoryName.SelectedValue);
feed.FeedID = Int32.Parse(FeedID.Value);
feed.isValid = Int16.Parse(FeedState.SelectedValue);
feed.DisplayIn = "";
for (int i = 0; i < CheckBoxDisplayIn.Items.Count; i++)
{
if (CheckBoxDisplayIn.Items[i].Selected)
{
if (feed.DisplayIn.Length > 0)
feed.DisplayIn += ",";
feed.DisplayIn += CheckBoxDisplayIn.Items[i].Value;
}
}
if (feed.DisplayIn.Length == 0)
feed.DisplayIn = "-1";
rfeed.Update(feed);
feed = null;
Util = null;
rfeed = null;
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Utility utility = new Utility();
WDSUser user = new WDSUser();
user.ID = user.GetID(HttpContext.Current.User.Identity.Name);
user = user.Read(user);
if (utility.GetSettings("On Demand") == "Disabled")
{
secure.Visible = false;
secureMsg.Text = "On Demand Mode Has Been Globally Disabled";
secureMsg.Visible = true;
}
else if (user.OndAccess == "0")
{
secure.Visible = false;
secureMsg.Text = "On Demand Mode Has Been Disabled For This Account";
secureMsg.Visible = true;
}
else
{
secure.Visible = true;
secureMsg.Visible = false;
}
if (!IsPostBack)
{
ddlImage.DataSource = Utility.PopulateImagesDdl();
ddlImage.DataBind();
ddlImage.Items.Insert(0, "Select Image");
}
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//Instantiate utility object
Utility Util = new Utility();
LyricoftheDay Lyric = LyricoftheDay.GetInstance();
Lyric.FillUp();
RanCat.NavigateUrl = "~/category.aspx?catid=" + Lyric.CatID;
RanCat.Text = Lyric.Category;
RanCat.ToolTip = "Xem danh mục " + Lyric.Category;
rdetails.NavigateUrl = "~/lyricdetail.aspx?id=" + Lyric.ID;
rdetails.Text = "Đọc thêm...";
rdetails.ToolTip = "Chi tiêt hợp âm " + Lyric.LyricName;
lbrecname.Text = Lyric.LyricName;
lbingred.Text = Util.FormatText(Lyric.Ingredients);
lbinstruct.Text = Util.FormatText(Lyric.Instructions);
lbhits.Text = Lyric.Hits.ToString();
lblrating.Text = Lyric.Rating;
lbvotes.Text = Lyric.NoRates.ToString();
rateimage.ImageUrl = Utility.GetStarImage(Lyric.Rating);
Util = null;
}
示例6: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
LoanDSTableAdapters.FinancialsTableAdapter financials = new LoanDSTableAdapters.FinancialsTableAdapter();
if (!(type == "update"))
{
financials.InsertFinancials(MySessionManager.ClientID,
MySessionManager.AppID,
ddMonth.Text,
ddlYear.Text,
txtSales.Text,
txtCostOfSales.Text,
txtGrossProfit.Text,
txtAdminCost.Text,
txtNetProfit.Text,
MySessionManager.CurrentUser.UserID);
}
else if (type == "update")
{
financials.UpdateFinancials(ddMonth.Text,
ddlYear.Text,
txtSales.Text,
txtCostOfSales.Text,
txtGrossProfit.Text,
txtAdminCost.Text,
txtNetProfit.Text,
MySessionManager.CurrentUser.UserID,
id);
}
Utility util = new Utility();
Page.Response.Redirect(util.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "fiedit"));
}
}
示例7: btnChange_Click
protected void btnChange_Click(object sender, EventArgs e)
{
Utility utl = new Utility();
//get user level after compair passwords
string userLevel = utl.checkLoggin(Session["user"].ToString(), txtCurPas.Text);
if (userLevel != "error")
{
if (txtNewPass.Text == txtConfPass.Text)
{
//assigning encripted password form text box & Encript
Encriptor enc = new Encriptor();
string password = enc.encript(txtConfPass.Text.ToString());
//DB_Connect.InsertQuery("UPDATE users_mast SET USER_PASSWORD='" + password + "' WHERE USER_USERNAME='test'");
DB_Connect.InsertQuery("UPDATE users_mast SET USER_PASSWORD='" + password + "' WHERE USER_USERNAME='" + Session["user"].ToString() + "'");
lblstatus.Text = "Password Changed.";
}
else
{
lblstatus.Text = "Passwords Doesnt Match";
}
}
else
{
lblstatus.Text = "Current Password Invalid";
}
}
示例8: Execute
public CommandExecutionResult Execute(OpenQA.Selenium.IWebDriver driver)
{
try
{
int timeout = 10;
bool isFound = false;
if (!string.IsNullOrEmpty(Value))
{
Target = Target + "|text=" + Value;
}
IWebElement[] elements;
try
{
isFound= new Utility().WaitingForElement(driver, Target, timeout);
}
catch (StaleElementReferenceException ex)
{
//retrying
isFound = new Utility().WaitingForElement(driver, Target, timeout);
}
if (!isFound)
return new CommandExecutionResult { CommandResult = CommandResult.CannotFindElement, Message = string.Format("Cannot find target:{0} value:{1}", Target, Value) };
return new CommandExecutionResult { CommandResult = CommandResult.Success, Message = string.Empty };
}
catch (TimeoutException ex)
{
return new CommandExecutionResult { CommandResult = CommandResult.TimedOut, Message = ex.Message };
}
catch (Exception ex)
{
return new CommandExecutionResult { CommandResult = CommandResult.Failed, Message = ex.Message };
}
}
示例9: ActiveUtility
/// <summary>
/// Constructor for an ActiveUtility object
/// </summary>
/// <param name="utility">A VTankObject Utility</param>
public ActiveUtility(Utility utility)
{
this.utility = utility;
this.duration = (int)utility.duration;
this.creationTime = Clock.GetTimeMilliseconds();
this.expirationTime = this.creationTime + this.duration*1000;
}
示例10: i_PrivmsgEvent
void i_PrivmsgEvent( Utility.Net.Chat.IRC.User source, string destination, string message )
{
if( message.ToLower( ).StartsWith( ".bopr" ) )
{
i.IrcPrivmsg( destination, source.Nickname + ": I have checked " + pos + " / " + total + " blocked IP addresses so far." );
}
}
示例11: Execute
public CommandExecutionResult Execute(OpenQA.Selenium.IWebDriver driver)
{
try
{
if (!string.IsNullOrEmpty(Value))
{
Target = Target + "|text=" + Value;
}
IWebElement[] elements;
try
{
elements = new Utility(1).GetTargetElements(driver, Target);
}
catch (StaleElementReferenceException ex)
{
//retrying
elements = new Utility(1).GetTargetElements(driver, Target);
}
if (elements.Length > 1)
return new CommandExecutionResult { CommandResult = CommandResult.ResultYieldedMoreThanOne, Message = string.Format("More than one element found for target:{0} value:{1}", Target, Value) };
if (elements.Length == 1)
return new CommandExecutionResult { CommandResult = CommandResult.CannotFindElement, Message = string.Format("Cannot find target:{0} value:{1}", Target, Value) };
return new CommandExecutionResult { CommandResult = CommandResult.Success, Message = string.Empty };
}
catch (TimeoutException ex)
{
return new CommandExecutionResult { CommandResult = CommandResult.TimedOut, Message = ex.Message };
}
catch (Exception ex)
{
return new CommandExecutionResult { CommandResult = CommandResult.Failed, Message = ex.Message };
}
}
示例12: checkin
public void checkin()
{
Utility settings = new Utility();
HttpContext postedContext = HttpContext.Current;
HttpFileCollection Files = postedContext.Request.Files;
string serverKey = settings.Decode((string)postedContext.Request.Form["serverKey"]);
if (serverKey == settings.GetSettings("Server Key"))
{
string mac = settings.Decode((string)postedContext.Request.Form["mac"]);
string result = null;
try
{
using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
{
NpgsqlCommand cmd = new NpgsqlCommand("client_checkin", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new NpgsqlParameter("@mac", mac));
conn.Open();
result = cmd.ExecuteScalar() as string;
}
}
catch (Exception ex)
{
result = "Could Not Check In. Check The Exception Log For More Info";
Logger.Log(ex.ToString());
}
HttpContext.Current.Response.Write(result);
}
else
{
Logger.Log("Incorrect Key For Client Checkin Was Provided");
}
}
示例13: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//Instantiate utility object
Utility Util = new Utility();
//Instantiate recipe of the day database field
RecipeoftheDay Recipe = new RecipeoftheDay();
Recipe.fillup();
RanCat.NavigateUrl = "category.aspx?catid=" + Recipe.CatID;
RanCat.Text = Recipe.Category;
RanCat.ToolTip = "Browse " + Recipe.Category + " category";
rdetails.NavigateUrl = "recipedetail.aspx?id=" + Recipe.ID;
rdetails.Text = "Read more...";
rdetails.ToolTip = "Read full details of " + Recipe.RecipeName + " recipe";
lbrecname.Text = Recipe.RecipeName;
lbingred.Text = Util.FormatText(Recipe.Ingredients);
lbinstruct.Text = Util.FormatText(Recipe.Instructions);
lbhits.Text = Recipe.Hits.ToString();
lblrating.Text = Recipe.Rating;
lbvotes.Text = Recipe.NoRates.ToString();
rateimage.ImageUrl = Utility.GetStarImage(Recipe.Rating);
//Release allocated memory
Util = null;
Recipe = null;
}
示例14: Map
void IUtilityCommand.Run(Utility utility, string[] args)
{
var modData = Game.ModData = utility.ModData;
map = new Map(modData, modData.ModFiles.OpenPackage(args[1], new Folder(".")));
Console.WriteLine("Resizing map {0} from {1} to {2},{3}", map.Title, map.MapSize, width, height);
map.Resize(width, height);
var forRemoval = new List<MiniYamlNode>();
foreach (var kv in map.ActorDefinitions)
{
var actor = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());
var location = actor.InitDict.Get<LocationInit>().Value(null);
if (!map.Contains(location))
{
Console.WriteLine("Removing actor {0} located at {1} due being outside of the new map boundaries.".F(actor.Type, location));
forRemoval.Add(kv);
}
}
foreach (var kv in forRemoval)
map.ActorDefinitions.Remove(kv);
map.Save((IReadWritePackage)map.Package);
}
示例15: Window_Edit
public Window_Edit(object Id, Utility.EditMode mode)
{
this.Id = Id;
this.mode = mode;
InitializeComponent();
switch (mode)
{
case Utility.EditMode.CUSTOMER:
foreach (GetCustomerFromIdResult it in Utility.database.GetCustomerFromId((string)Id))
{
TextBox_Name.Text = it.Name;
TextBox_Description.Text = it.Description;
}
break;
case Utility.EditMode.MODEL:
foreach (GetModelFromIdResult it in Utility.database.GetModelFromId((string)Id))
{
TextBox_Name.Text = it.Name;
TextBox_Description.Text = it.Description;
}
break;
case Utility.EditMode.COMPONENT:
foreach (GetComponentFromComponentIdResult it in Utility.database.GetComponentFromComponentId((string) Id))
{
TextBox_Name.Text = it.Name;
TextBox_Description.Text = it.Description;
}
break;
}
}