本文整理匯總了C#中System.Result.failed方法的典型用法代碼示例。如果您正苦於以下問題:C# Result.failed方法的具體用法?C# Result.failed怎麽用?C# Result.failed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Result
的用法示例。
在下文中一共展示了Result.failed方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Operate
protected void Operate( object sender, EventArgs args )
{
Planet planet = getPlanet();
Result result = null;
try {
string operation = GetVar("currentOperation");
string resource = GetVar("resource");
string quantityToOperate = quantity.Text;
quantity.Text = "";
switch(operation) {
case "sell":
result = Chronos.Trade.Market.Sell(planet, resource, int.Parse(quantityToOperate));
break;
case "buy":
result = Chronos.Trade.Market.Buy(planet, resource, int.Parse(quantityToOperate));
break;
default:
throw new Exception();
}
} catch {
result = new Result();
result.failed( new InvalidOperation() );
} finally {
operationReport.ResultSet = result;
}
}
示例2: demolish
/// <summary>Comando de build de um recurso</summary>
private void demolish( ResourceManager planet )
{
if( planet is Planet ) {
Planet p = (Planet) planet;
if( p.IsInBattle ) {
Result result = new Result();
result.failed( new PlanetInBattle() );
QueueError.ResultSet = result;
return;
}
if( p.BuilingsDemolished > 2 ) {
Result result = new Result();
//result.failed( new CanNotDemolish() );
QueueError.ResultSet = result;
return;
}
++p.BuilingsDemolished;
}
int curr = planet.getResourceCount(Category, resource);
if( quantity <= curr ) {
planet.take(Category, resource, quantity);
}
}