本文整理汇总了C#中Utility类的典型用法代码示例。如果您正苦于以下问题:C# Utility类的具体用法?C# Utility怎么用?C# Utility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utility类属于命名空间,在下文中一共展示了Utility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:lukesUbuntu,项目名称:c-sharp-monopoly-game-console-,代码行数:28,代码来源:_UtilityTest.cs
示例2: Start
void Start()
{
if (!instance)
instance = this;
else
Debug.LogError ("Utility not an instance");
}
开发者ID:SirBrott,项目名称:TwinStickAction,代码行数:7,代码来源:Utility.cs
示例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;
}
开发者ID:ranukhandelwal,项目名称:EC,代码行数:32,代码来源:EditFeed.aspx.cs
示例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");
}
}
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:31,代码来源:ondemand.aspx.cs
示例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;
}
开发者ID:mangmaytinh,项目名称:vguitar,代码行数:28,代码来源:lyricoftheday.ascx.cs
示例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"));
}
}
开发者ID:infosystemproject2014,项目名称:microfinance,代码行数:34,代码来源:financial.ascx.cs
示例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";
}
}
开发者ID:neonmax,项目名称:sims,代码行数:33,代码来源:Profile.aspx.cs
示例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 };
}
}
开发者ID:ngocluu263,项目名称:WebAuto,代码行数:34,代码来源:WaitForElementPresentCommand.cs
示例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;
}
开发者ID:summer-of-software,项目名称:vtank,代码行数:11,代码来源:ActiveUtility.cs
示例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." );
}
}
开发者ID:akhilkashok,项目名称:boprbot,代码行数:7,代码来源:IrcController.cs
示例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 };
}
}
开发者ID:ngocluu263,项目名称:WebAuto,代码行数:34,代码来源:AssertElementNotPresentCommand.cs
示例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");
}
}
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:34,代码来源:ClientSvc.asmx.cs
示例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;
}
开发者ID:dineshkummarc,项目名称:WorldRecipe-CS,代码行数:31,代码来源:recipeoftheday.ascx.cs
示例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);
}
开发者ID:pchote,项目名称:OpenRA,代码行数:25,代码来源:ResizeMapCommand.cs
示例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;
}
}
开发者ID:hkhoi,项目名称:Woody,代码行数:31,代码来源:Window_Edit.xaml.cs
示例16: Map
void IUtilityCommand.Run(Utility utility, string[] args)
{
// HACK: The engine code assumes that Game.modData is set.
var modData = Game.ModData = utility.ModData;
var actorType = args[1];
string mapPath = null;
Map map = null;
if (args.Length == 3)
{
try
{
mapPath = args[2];
map = new Map(modData, modData.ModFiles.OpenPackage(mapPath, new Folder(".")));
}
catch (InvalidDataException)
{
Console.WriteLine("Could not load map '{0}'.", mapPath);
Environment.Exit(2);
}
}
var fs = map ?? modData.DefaultFileSystem;
var topLevelNodes = MiniYaml.Load(fs, modData.Manifest.Rules, map == null ? null : map.RuleDefinitions);
var result = topLevelNodes.FirstOrDefault(n => n.Key == actorType);
if (result == null)
{
Console.WriteLine("Could not find actor '{0}' (name is case-sensitive).", actorType);
Environment.Exit(1);
}
Console.WriteLine(result.Value.Nodes.WriteToString());
}
开发者ID:OpenRA,项目名称:OpenRA,代码行数:35,代码来源:OutputActorMiniYamlCommand.cs
示例17: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Master.IsInMembership("User"))
Response.Redirect("~/views/dashboard/dash.aspx?access=denied");
ddlGroupImage.DataSource = Utility.PopulateImagesDdl();
ddlGroupImage.DataBind();
ddlGroupImage.Items.Insert(0, "Select Image");
ddlGroupKernel.DataSource = Utility.GetKernels();
ddlGroupKernel.DataBind();
ListItem itemKernel = ddlGroupKernel.Items.FindByText("3.18.1-WDS");
if (itemKernel != null)
ddlGroupKernel.SelectedValue = "3.18.1-WDS";
else
ddlGroupKernel.Items.Insert(0, "Select Kernel");
ddlGroupBootImage.DataSource = Utility.GetBootImages();
ddlGroupBootImage.DataBind();
ListItem itemBootImage = ddlGroupBootImage.Items.FindByText("initrd.gz");
if (itemBootImage != null)
ddlGroupBootImage.SelectedValue = "initrd.gz";
else
ddlGroupBootImage.Items.Insert(0, "Select Boot Image");
lbScripts.DataSource = Utility.GetScripts();
lbScripts.DataBind();
Utility utility = new Utility();
if (utility.GetSettings("Default Host View") == "all")
PopulateGrid();
}
}
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:35,代码来源:create.aspx.cs
示例18: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["access"] as string == "denied")
lblDenied.Text = "You Are Not Authorized To View That Page";
Utility utility = new Utility();
}
开发者ID:cocoon,项目名称:crucibleWDS,代码行数:7,代码来源:dash.aspx.cs
示例19: AddFinalUpdateDelegate
public void AddFinalUpdateDelegate(Utility.BaseFunction x)
{
if (!this.lxFinalUpdateDelegates.Contains(x))
{
this.lxFinalUpdateDelegates.Add(x);
}
}
开发者ID:ancientgods,项目名称:SoG,代码行数:7,代码来源:EntityMaster.cs
示例20: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
int ID =int.Parse(Request.QueryString["SID"].ToString());
var Sdetail = SRepo.GetSchedulePromotionById(ID);
if (Sdetail != null)
{
lblUPI.Text = Sdetail.UpiCode;
lbltitle.Text = Sdetail.Title;
lblSMSContent.Text = Sdetail.SMSContent;
ltrWebContent.Text = Sdetail.WebContent;
lblStartDate.Text = string.Format("{0:d}", Sdetail.StartDate);
lblEndDate.Text = string.Format("{0:d}",Sdetail.EndDate);
lblAdmin.Text = SRepo.GetAdministratorName(Sdetail.AdministratorId);
string phoneList = SRepo.GetSchedulePromotionById(ID).PhoneNumbers;
phoneList = string.Format("'{0}'", phoneList);
phoneList = phoneList.Replace(",", "','");
string sql = "SELECT a.FullName as CustomerName,a.UpiCode, a.Phone, b.FullName,s.PositionName FROM [Customer] as a LEFT JOIN [CustomerSupervisor] as b on a.Id=b.CustomerId left join [SupervisorPosition] as s on b.PositionId=s.Id where a.Phone in (" + phoneList + ")";
Utility utility = new Utility();
SchedulePhoneNumbers.DataSource = utility.GetList(sql);
Utility.SetCurrentMenu("mPromotion");
}
}
}
开发者ID:groshugo,项目名称:unitedpharma,代码行数:27,代码来源:DetailSchedulePromotionManagement.aspx.cs
注:本文中的Utility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论