Hi there,
Just so you know there is a Work Item related with the ability to execute an action over multiple accounts.
This will be implemented in next release.
In the meantime here are 3 different solutions for this "problem".
I would strongly advise to use solution number 2.
Previously you must have store the Token is some sort of collection.
Like before just iterate over your list of credentials and set the current credentials before performing your action.
Simplify your life and create an Extension method for credentials:
Please let me know if this solves your problem.
Linvi
Just so you know there is a Work Item related with the ability to execute an action over multiple accounts.
This will be implemented in next release.
In the meantime here are 3 different solutions for this "problem".
I would strongly advise to use solution number 2.
List<IOAuthCredentials> credentials = new List<IOAuthCredentials>();
Solution 1 : Update Store CredentialsPreviously you must have store the Token is some sort of collection.
Like before just iterate over your list of credentials and set the current credentials before performing your action.
foreach (var credential in credentials)
{
TwitterCredentials.Credentials = credential;
Tweet.PublishTweet("My Tweet");
}
Solution 2 : Use Exstension methodSimplify your life and create an Extension method for credentials:
public static class CredentialsExtensions
{
public static T ExecuteOperation<T>(this IOAuthCredentials credentials, Func<T> operation)
{
var initialCredentials = TwitterCredentials.Credentials;
TwitterCredentials.Credentials = credentials;
var result = operation();
TwitterCredentials.Credentials = initialCredentials;
return result;
}
public static void ExecuteOperation(this IOAuthCredentials credentials, Action operation)
{
var initialCredentials = TwitterCredentials.Credentials;
TwitterCredentials.Credentials = credentials;
operation();
TwitterCredentials.Credentials = initialCredentials;
}
}
Then iterate again like this:foreach (var credential in credentials)
{
credential.ExecuteOperation(() => Tweet.PublishTweet("My Tweet"));
}
Solution 3: Use a list of ILoggedUsersvar loggedUsers = new List<ILoggedUser>();
foreach (var loggedUser in loggedUsers)
{
loggedUser.PublishTweet("piloupe!");
}
The issue with this solution is that I have not provided any method to generate a LoggedUser from a set of credentials. It means that to create your list, you will have to iterate over your stored credentials set them and get User.GetLoggedUser().Please let me know if this solves your problem.
Linvi