本文整理汇总了C#中Cloud类的典型用法代码示例。如果您正苦于以下问题:C# Cloud类的具体用法?C# Cloud怎么用?C# Cloud使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cloud类属于命名空间,在下文中一共展示了Cloud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateMatchWithMinimumArgs
public void ShouldCreateMatchWithMinimumArgs(Cloud cloud)
{
Login(cloud, gamer => {
gamer.Matches.Create(maxPlayers: 2)
.CompleteTestIfSuccessful();
});
}
示例2: ShouldListScoreOfFriends
public void ShouldListScoreOfFriends(Cloud cloud)
{
// Create 2 users
Login2NewUsers(cloud, (gamer1, gamer2) => {
// Post 1 score each
string board = RandomBoardName();
gamer1.Scores.Post(1000, board, ScoreOrder.HighToLow, "TestGamer1", false)
.ExpectSuccess(dummy => gamer2.Scores.Post(1500, board, ScoreOrder.HighToLow, "TestGamer2", false))
// We need to wait a bit else the results may be misleading
.ExpectSuccess(dummy => Wait<object>(1000))
// Ok so now the two friends are not friends, so the scores returned should not include the other
.ExpectSuccess(dummy => gamer1.Scores.ListFriendScores(board))
.ExpectSuccess(scores => {
Assert(scores.Count == 1, "Should have one score only");
Assert(scores[0].GamerInfo.GamerId == gamer1.GamerId, "Should contain my score");
// So let's become friends!
return gamer2.Community.AddFriend(gamer1.GamerId);
})
// And try again fetching scores
.ExpectSuccess(dummy => Wait<object>(1000))
.ExpectSuccess(friendResult => gamer1.Scores.ListFriendScores(board))
.ExpectSuccess(scoresWhenFriend => {
Assert(scoresWhenFriend.Count == 2, "Should have two scores only");
Assert(scoresWhenFriend[1].Rank == 2, "Second score should have rank 2");
CompleteTest();
});
});
}
示例3: ShouldCreateMatch
public void ShouldCreateMatch(Cloud cloud)
{
string matchDesc = "Test match";
Login(cloud, gamer => {
gamer.Matches.Create(
description: matchDesc,
maxPlayers: 2,
customProperties: Bundle.CreateObject("test", "value"),
shoe: Bundle.CreateArray(1, 2, 3))
.ExpectSuccess(match => {
Assert(match.Creator.GamerId == gamer.GamerId, "Match creator not set properly");
Assert(match.CustomProperties["test"] == "value", "Missing custom property");
Assert(match.Description == matchDesc, "Invalid match description");
Assert(match.Moves.Count == 0, "Should not have any move at first");
Assert(match.GlobalState.AsDictionary().Count == 0, "Global state should be empty initially");
Assert(match.LastEventId != null, "Last event should not be null");
Assert(match.MatchId != null, "Match ID shouldn't be null");
Assert(match.MaxPlayers == 2, "Should have two players");
Assert(match.Players.Count == 1, "Should contain only one player");
Assert(match.Players[0].GamerId == gamer.GamerId, "Should contain me as player");
Assert(match.Seed != 0, "A 31-bit seed should be provided");
Assert(match.Shoe.AsArray().Count == 0, "The shoe shouldn't be available until the match is finished");
Assert(match.Status == MatchStatus.Running, "The match status is invalid");
CompleteTest();
});
});
}
示例4: Render
public virtual void Render(Cloud cloud, Graphics g)
{
foreach (var block in cloud)
{
DrawWord(block.Data, g, block.LeftTop);
}
}
示例5: Start
// Use this for initialization
void Start () {
var cotc = FindObjectOfType<CotcGameObject> ();
if (cotc == null) {
throw new SystemException ("No Clan of the Cloud SDK object found on the scene");
}
// Log unhandled exceptions (.Done block without .Catch -- not called if there is any .Then)
Promise.UnhandledException += (object sender, ExceptionEventArgs e) => {
Debug.LogError("Unhandled exception: " + e.Exception.ToString());
};
// Promise.Debug_OutputAllExceptions = true;
// PlayerPrefs.DeleteAll();
// Initiate getting the main Cloud object
cotc.GetCloud().Done(cloud => {
Cloud = cloud;
// Retry failed HTTP requests once after 1 sec, then 5, finally abort.
Cloud.HttpRequestFailedHandler = (HttpRequestFailedEventArgs e) => {
int count = (int?) e.UserData ?? 0;
if (count == 0) e.RetryIn(1000);
else if (count == 1) e.RetryIn(5000);
else e.Abort();
e.UserData = ++count;
};
Debug.Log("Setup done");
// PostSampleScoresForTesting();
InitCloud();
});
Debug.Assert(ConfirmationDialog != null);
}
示例6: ShouldBeUsableToSearchForMatches
public void ShouldBeUsableToSearchForMatches(Cloud cloud)
{
Login2NewUsers(cloud, (gamer1, gamer2) => {
string queryStr = "public:true AND owner_id:" + gamer1.GamerId;
Match[] matches = new Match[2];
gamer1.Matches.Create(maxPlayers: 2)
.Then(match1 => {
Bundle matchProp = Bundle.CreateObject("public", true, "owner_id", gamer1.GamerId);
matches[0] = match1;
// Index the match
return cloud.Index("matches").IndexObject(match1.MatchId, matchProp, Bundle.Empty);
})
.Then(indexResult => {
// Create another match
return gamer1.Matches.Create(maxPlayers: 2);
})
.Then(match2 => {
// Index it
matches[1] = match2;
return cloud.Index("matches").IndexObject(match2.MatchId, Bundle.CreateObject("public", false), Bundle.Empty);
})
.Then(indexResult2 => {
// Check that we can find match1 by looking for public matches
return cloud.Index("matches").Search(queryStr);
})
.Then(found => {
Assert(found.Hits.Count == 1, "Should find one match");
Assert(found.Hits[0].ObjectId == matches[0].MatchId, "Should find one match");
})
.CompleteTestIfSuccessful();
});
}
示例7: Connect
public ProviderResponse<Cloud> Connect(Cloud cloud)
{
ProviderResponse<Cloud> response = new ProviderResponse<Cloud>();
Cloud local = cloud.DeepCopy();
IVcapClient client = new VcapClient(local);
try
{
VcapClientResult result = client.Login();
if (!result.Success)
throw new Exception(result.Message);
local.AccessToken = client.CurrentToken;
var applications = client.GetApplications();
var provisionedServices = client.GetProvisionedServices();
var availableServices = client.GetSystemServices();
local.Applications.Synchronize(new SafeObservableCollection<Application>(applications), new ApplicationEqualityComparer());
local.Services.Synchronize(new SafeObservableCollection<ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer());
local.AvailableServices.Synchronize(new SafeObservableCollection<SystemService>(availableServices), new SystemServiceEqualityComparer());
foreach (Application app in local.Applications)
{
var instances = GetInstances(local, app);
if (instances.Response != null)
app.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instances.Response), new InstanceEqualityComparer());
}
response.Response = local;
}
catch (Exception ex)
{
response.Message = ex.Message;
}
return response;
}
示例8: ShouldHavePaginationInTxHistory
public void ShouldHavePaginationInTxHistory(Cloud cloud)
{
LoginNewUser(cloud, gamer => {
// Run 3 transactions serially
gamer.Transactions.Post(Bundle.CreateObject("gold", 1))
.ExpectSuccess(dummy => gamer.Transactions.Post(Bundle.CreateObject("gold", 2, "silver", 10)))
.ExpectSuccess(dummy => gamer.Transactions.Post(Bundle.CreateObject("gold", 3)))
// All transactions have been executed. Default to page 1.
.ExpectSuccess(dummy => gamer.Transactions.History(limit: 2))
.ExpectSuccess(tx => {
// Even though there are three, only two results should be returned
Assert(tx.Count == 2, "Expected two entries in history");
// Then fetch the next page
Assert(!tx.HasPrevious, "Should not have previous page");
Assert(tx.HasNext, "Should have next page");
return tx.FetchNext();
})
.ExpectSuccess(tx => {
Assert(tx.Offset == 2, "Expected offset: 2");
Assert(tx.Count == 1, "Expected one value at page 2");
Assert(tx.HasPrevious, "Should have previous page");
Assert(!tx.HasNext, "Should not have next page");
return tx.FetchPrevious();
})
.ExpectSuccess(tx => {
Assert(tx.Count == 2, "Expected two entries in history");
Assert(!tx.HasPrevious, "Should not have previous page");
Assert(tx.HasNext, "Should have next page");
CompleteTest();
});
});
}
示例9: ShouldAddFriend
public void ShouldAddFriend(Cloud cloud)
{
// Use two test accounts
Login2NewUsers(cloud, (gamer1, gamer2) => {
// Expects friend status change event
Promise restOfTheTestCompleted = new Promise();
gamer1.StartEventLoop();
gamer1.Community.OnFriendStatusChange += (FriendStatusChangeEvent e) => {
Assert(e.FriendId == gamer2.GamerId, "Should come from P2");
Assert(e.NewStatus == FriendRelationshipStatus.Add, "Should have added me");
restOfTheTestCompleted.Done(CompleteTest);
};
// Add gamer1 as a friend of gamer2
gamer2.Community.AddFriend(gamer1.GamerId)
.ExpectSuccess(addResult => {
// Then list the friends of gamer1, gamer2 should be in it
return gamer1.Community.ListFriends();
})
.ExpectSuccess(friends => {
Assert(friends.Count == 1, "Expects one friend");
Assert(friends[0].GamerId == gamer2.GamerId, "Wrong friend ID");
restOfTheTestCompleted.Resolve();
});
});
}
示例10: InitializeData
protected override void InitializeData()
{
Messenger.Default.Send(new NotificationMessageAction<Cloud>(Messages.SetChangePasswordData, c => {
this.EMail = c.Email;
this.cloud = c;
}));
}
示例11: ShouldAssociateGodfather
public void ShouldAssociateGodfather(Cloud cloud)
{
Login2NewUsers(cloud, (gamer1, gamer2) => {
// Expects godchild event
Promise restOfTheTestCompleted = new Promise();
gamer1.StartEventLoop();
gamer1.Godfather.OnGotGodchild += (GotGodchildEvent e) => {
Assert(e.Gamer.GamerId == gamer2.GamerId, "Should come from player2");
Assert((object)e.Reward == (object)Bundle.Empty, "No reward should be associated");
restOfTheTestCompleted.Done(CompleteTest);
};
// P1 generates a code and associates P2 with it
gamer1.Godfather.GenerateCode()
// Use code
.ExpectSuccess(genCode => gamer2.Godfather.UseCode(genCode))
.ExpectSuccess(dummy => gamer2.Godfather.GetGodfather())
.ExpectSuccess(result => {
Assert(result.GamerId == gamer1.GamerId, "P1 should be godfather");
Assert(result.AsBundle().Root.Has("godfather"), "Underlying structure should be accessible");
return gamer1.Godfather.GetGodchildren();
})
.ExpectSuccess(result => {
Assert(result.Count == 1, "Should have only one godchildren");
Assert(result[0].GamerId == gamer2.GamerId, "P2 should be godchildren");
restOfTheTestCompleted.Resolve();
});
});
}
示例12: ShouldRunGameBatch
public void ShouldRunGameBatch(Cloud cloud)
{
cloud.Game.Batches.Run("test", Bundle.CreateObject("value", 3))
.ExpectSuccess(batchResult => {
Assert(batchResult["value"] == 6, "Result invalid (expected 3 x 2 = 6)");
CompleteTest();
});
}
示例13: InitializeData
protected override void InitializeData()
{
Messenger.Default.Send(new NotificationMessageAction<Cloud>(Messages.SetCreateServiceData,
(cloud) =>
{
this.cloud = cloud;
this.SystemServices.Synchronize(cloud.AvailableServices, new SystemServiceEqualityComparer());
}));
}
示例14: InitializeData
protected override void InitializeData()
{
Messenger.Default.Send(new NotificationMessageAction<Cloud>(Messages.SetRegisterAccountData,
(cloud) =>
{
this.cloud = cloud;
this.EMail = cloud.Email;
this.NewPassword = cloud.Password;
}));
}
示例15: ShouldRunGamerBatch
public void ShouldRunGamerBatch(Cloud cloud)
{
Login(cloud, gamer => {
gamer.Batches.Run("testGamer", Bundle.CreateObject("prefix", "Hello "))
.ExpectSuccess(batchResult => {
Assert(batchResult["message"] == "Hello [email protected]", "Returned value invalid (" + batchResult["message"] + ", check hook on server");
CompleteTest();
});
});
}