本文整理汇总了C#中Resource.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Resource.ToString方法的具体用法?C# Resource.ToString怎么用?C# Resource.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryReserveResource
bool TryReserveResource(Resource res)
{
if (notReservedResourceNumber(res) > 0)
{
if (reservedResources.ContainsKey(res)){
reservedResources[res] += 1;
} else
{
reservedResources[res] = 1;
}
Debug.Log("Reserved " + reservedResources[res] + " of " + res.ToString());
return true;
}
return false;
}
示例2: ToStringShouldReturnResourceKey
public void ToStringShouldReturnResourceKey()
{
var resource = new Resource("My_resource", "Banana's are good");
resource.ToString().ShouldBe("My_resource");
}
示例3: GetResKey
uint GetResKey(Resource r, bool create)
{
if (r == null) return 0;
if ((object)r == (object)Statement.DefaultMeta) return 1;
object keyobj = GetResourceKey(r);
if (keyobj != null) return (uint)keyobj;
uint key = 0;
string stringval = null;
if (r is Literal) {
stringval = "L" + r.ToString();
} else if (r.Uri != null) {
stringval = "U" + r.Uri;
}
if (stringval != null) {
keyobj = db_value_to_id.Get(stringval);
if (keyobj != null) key = (uint)keyobj;
}
if (key == 0) {
if (!create) return 0;
lastid++;
key = lastid;
SetResourceKey(r, key);
if (stringval != null) {
db_id_to_value.Put(key, stringval);
db_value_to_id.Put(stringval, key);
}
}
return key;
}
示例4: TradeHelper
public TradeHelper(Resource _r, int _max, Vector2 position)
{
r = _r;
max = _max;
resource = new Visual(position, RSIZE, RSIZE, _r.ToString()).setBorder(false);
plus = new Button(position + new Vector2(RSIZE + MARGIN, 0), RSIZE, RSIZE, null, null, "plus", false);
minus = new Button(position + new Vector2((RSIZE + MARGIN) * 2, 0), RSIZE, RSIZE, null, null, "minus", false);
total = new Visual(position + new Vector2((RSIZE + MARGIN) * 3, 0), RSIZE, RSIZE, num.ToString(), "Font1", null, Color.Gray, "line", 0).setBorder(false);
setVisible(false);
}
示例5: S
string S(Resource r, string v) {
if (r == null) {
return v;
} else if (r is Literal) {
return r.ToString();
} else if (r.Uri != null) {
if (r.Uri.IndexOf('>') != -1)
throw new ArgumentException("Invalid URI: " + r.Uri);
return "<" + r.Uri + ">";
} else {
throw new ArgumentException("Blank node in select not supported.");
}
}
示例6: GetResource
/// <summary>
/// Give a player an amount of some resource
/// If there are no more cards in the pile an NoMoreCardsException is thrown
/// </summary>
/// <param name="player">The player to give resources to</param>
/// <param name="resource">The type of resource he receives</param>
/// <param name="quantity">The amount of the resource he receives (default 1)</param>
private void GetResource(Player player, Resource resource, int quantity = 1)
{
for (int i = 0; i < quantity; i++)
{
if (resourceBank[(int)resource] == 0) throw new NoMoreCardsException("Resource bank is out of " + resource.ToString());
player.Resources.Add(resource);
resourceBank[(int)resource]--;
}
}
示例7: GetHash
// Computes a hash for a resource used as its key in the database.
private string GetHash(Resource resource)
{
// TODO: Do this with fewer new object creations.
string data;
if (resource == Statement.DefaultMeta) {
data = "X" + DEFAULT_META_KEY;
} else if (resource is BNode) {
data = "B" + ((BNode)resource).GetGUID().ToString("N");
} else if (resource is Entity) {
data = "U" + resource.Uri.ToString();
} else if (resource is Literal) {
data = "L" + resource.ToString();
} else {
throw new Exception("Not reachable.");
}
byte[] bytedata = System.Text.Encoding.Unicode.GetBytes(data);
byte[] hash = sha.ComputeHash(bytedata);
return Convert.ToBase64String(hash);
}