private void InitProperties() { _decay = new UnitOptionalProperty <int>(this, UnitDataType.Decay, k.decay, () => 255); OptionalProperties.Add(_decay); _tint = new UnitOptionalProperty <Color>(this, UnitDataType.Tint, k.tint, () => ED.Config.Tint); OptionalProperties.Add(_tint); _powerGridMax = new UnitProperty(this, AggregateField.powergrid_max, AggregateField.powergrid_max_modifier); AddProperty(_powerGridMax); _powerGrid = new PowerGridProperty(this); AddProperty(_powerGrid); _cpuMax = new UnitProperty(this, AggregateField.cpu_max, AggregateField.cpu_max_modifier); AddProperty(_cpuMax); _cpu = new CpuProperty(this); AddProperty(_cpu); _ammoReloadTime = new UnitProperty(this, AggregateField.ammo_reload_time, AggregateField.ammo_reload_time_modifier); AddProperty(_ammoReloadTime); _missileHitChance = new UnitProperty(this, AggregateField.missile_miss, AggregateField.missile_miss_modifier); AddProperty(_missileHitChance); _decayChance = new DecayChanceProperty(this); AddProperty(_decayChance); }
/// <summary> /// Initializes a new instance of the <see cref="SavedSearchesCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public SavedSearchesCommand(OAuthTokens tokens, OptionalProperties options) : base(HTTPVerb.GET, "saved_searches.json", tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } }
/// <summary> /// Initializes a new instance of the <see cref="DeleteStatusCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="id">The status id.</param> /// <param name="options">The options.</param> public DeleteStatusCommand(OAuthTokens tokens, decimal id, OptionalProperties options) : base( HttpMethod.Post, string.Format(CultureInfo.InvariantCulture, "statuses/destroy/{0}.json", id), tokens, options) { this.Id = id; }
/// <summary> /// Initializes a new instance of the <see cref="SuggestedUsersCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="categorySlug">The category slug.</param> /// <param name="options">The options.</param> public SuggestedUsersCommand(OAuthTokens tokens, string categorySlug, OptionalProperties options) : base(HTTPVerb.GET, string.Format("users/suggestions/{0}.json", categorySlug), tokens, options) { if (string.IsNullOrEmpty(categorySlug)) { throw new ArgumentNullException("categorySlug", "A category slug is required"); } this.Slug = categorySlug; }
/// <summary> /// Initializes a new instance of the <see cref="ShowUserCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="userId">The user id.</param> /// <param name="username">The username.</param> /// <param name="options">The options.</param> public ShowUserCommand(OAuthTokens tokens, decimal userId, string username, OptionalProperties options) : base(HTTPVerb.GET, "users/show.json", tokens, options) { if ((userId <= 0 && string.IsNullOrEmpty(username)) || (userId > 0 && !string.IsNullOrEmpty(username))) { throw new ArgumentException("Either userId or username must be supplied, but not both."); } this.UserId = userId; this.Username = username; }
/// <summary> /// Initializes a new instance of the <see cref="ShowStatusCommand"/> class. /// </summary> /// <param name="requestTokens">The request tokens.</param> /// <param name="statusId">The status id.</param> /// <param name="options">The options.</param> public ShowStatusCommand(OAuthTokens requestTokens, decimal statusId, OptionalProperties options) : base( HttpMethod.Get, string.Format(CultureInfo.InvariantCulture, "statuses/show/{0}.json", statusId), requestTokens, options) { if (statusId <= 0) { throw new ArgumentNullException("statusId"); } }
/// <summary> /// Initializes a new instance of the <see cref="DeleteSavedSearchCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="savedsearchId">The savedsearch id.</param> /// <param name="options">The options.</param> /// <remarks></remarks> public DeleteSavedSearchCommand(OAuthTokens tokens, decimal savedsearchId, OptionalProperties options) : base(HttpMethod.Post, string.Format(CultureInfo.InvariantCulture.NumberFormat, "saved_searches/destroy/{0}.json", savedsearchId), tokens, options) { if (savedsearchId <= 0) { throw new ArgumentException("Saved Search Id is required."); } if (tokens == null) { throw new ArgumentNullException("tokens"); } }
/// <summary> /// Initializes a new instance of the <see cref="ShowDirectMessageCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="id">The id.</param> /// <param name="options">The options.</param> /// <remarks></remarks> internal ShowDirectMessageCommand(OAuthTokens tokens, decimal id, OptionalProperties options) : base(HttpMethod.Get, string.Format("direct_messages/{0}.json", id), tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens", "The tokens parameter is required."); } if (id <= 0) { throw new ArgumentOutOfRangeException("id", "The id parameter must be greater than zero."); } }
/// <summary> /// Initializes a new instance of the <see cref="CreateFavoriteCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="statusId">The status id.</param> /// <param name="options">The options.</param> public CreateFavoriteCommand(OAuthTokens tokens, decimal statusId, OptionalProperties options) : base(HTTPVerb.POST, string.Format(CultureInfo.InvariantCulture.NumberFormat, "favorites/create/{0}.json", statusId), tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (statusId <= 0) { throw new ArgumentException("Status Id is required."); } }
public static bool SendDmMessage(string SenderScreenName, string ReciverScreenName, string Message, out RequestResult Result) { var vUser = GetUser(SenderScreenName); if (vUser == null) { Result = RequestResult.Unknown; return(false); } if (!Classes.AppSetting.UseProxy || string.IsNullOrWhiteSpace(vUser.ProxyAddress)) { OAuthTokens Oa = GetUserOAuthTokens(SenderScreenName); if (!CanSendMessage(AppSetting.Username, AppSetting.Password, ReciverScreenName, Message, SenderScreenName)) { Result = RequestResult.Unauthorized; return(false); } var omRes = TwitterDirectMessage.Send(Oa, ReciverScreenName, Message); if (omRes.Result == RequestResult.Unauthorized) { if (LoginUser(vUser.ScreenName, vUser.Name, vUser.ProxyAddress)) { return(SendDmMessage(SenderScreenName, ReciverScreenName, Message, out Result)); } else { DeleteUser(vUser); Result = RequestResult.NotAcceptable; return(false); } } Result = omRes.Result; return(Result == RequestResult.Success); } else { var Proxy = vUser.ProxyAddress; var option = new OptionalProperties(); option.Proxy = GetProxy(Proxy); OAuthTokens Oa = GetUserOAuthTokens(SenderScreenName); if (!CanSendMessage(AppSetting.Username, AppSetting.Password, ReciverScreenName, Message, SenderScreenName)) { Result = RequestResult.Unauthorized; return(false); } var omRes = TwitterDirectMessage.Send(Oa, ReciverScreenName, Message, null); Result = omRes.Result; return(Result == RequestResult.Success); } }
/// <summary> /// Initializes a new instance of the <see cref="DeleteDirectMessageCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="id">The status id.</param> /// <param name="options">The options.</param> public DeleteDirectMessageCommand(OAuthTokens tokens, decimal id, OptionalProperties options) : base(HttpMethod.Post, string.Format(CultureInfo.InvariantCulture, "direct_messages/destroy/{0}.json", id), tokens, options) { if (id <= 0) { throw new ArgumentException("The message id is invalid", "id"); } if (tokens == null) { throw new ArgumentNullException("tokens"); } this.Id = id; }
/// <summary> /// Initializes a new instance of the <see cref="CreateSavedSearchCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="query">The query.</param> /// <param name="options">The options.</param> public CreateSavedSearchCommand(OAuthTokens tokens, string query, OptionalProperties options) : base(HttpMethod.Post, "saved_searches/create.json", tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (String.IsNullOrEmpty(query)) { throw new ArgumentException("Query is required."); } this.Query = query; }
/// <summary> /// Initializes a new instance of the <see cref="SendDirectMessageCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="text">The message text.</param> /// <param name="options">The options.</param> private SendDirectMessageCommand(OAuthTokens tokens, string text, OptionalProperties options) : base(HTTPVerb.POST, "direct_messages/new.json", tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (string.IsNullOrEmpty(text)) { throw new ArgumentNullException("text"); } this.Text = text; }
/// <summary> /// Initializes a new instance of the <see cref="CreateListCommand"/> class. /// </summary> /// <param name="requestTokens">The request tokens.</param> /// <param name="name">The name.</param> /// <param name="options">The options.</param> /// <remarks></remarks> public CreateListCommand(OAuthTokens requestTokens, string name, OptionalProperties options) : base(HTTPVerb.POST, "lists/create.json", requestTokens, options) { if (Tokens == null) { throw new ArgumentNullException("requestTokens"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } this.Name = name; }
/// <summary> /// Initializes a new instance of the <see cref="CreateListMembershipCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="listId">The list id.</param> /// <param name="options">The options.</param> public CreateListMembershipCommand(OAuthTokens tokens, decimal listId, OptionalProperties options) : base(HTTPVerb.POST, "/lists/subscribers/create.json", tokens, options) { if (tokens == null || !tokens.HasBothTokens) { throw new ArgumentNullException("tokens"); } if (listId <= 0) { throw new ArgumentNullException("listId"); } this.listId = listId; }
/// <summary> /// Initializes a new instance of the <see cref="RetweetCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="statusId">The status id.</param> /// <param name="options">The options.</param> public RetweetCommand(OAuthTokens tokens, decimal statusId, OptionalProperties options) : base( HTTPVerb.POST, string.Format(CultureInfo.InvariantCulture, Path, statusId), tokens, options) { if (statusId <= 0) { throw new ArgumentException("Status ID is invalid", "statusId"); } if (tokens == null) { throw new ArgumentNullException("tokens"); } }
/// <summary> /// Initializes a new instance of the <see cref="UpdateProfileImageCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="image">The image.</param> /// <param name="options">The options.</param> public UpdateProfileImageCommand(OAuthTokens tokens, byte[] image, OptionalProperties options) : base(HTTPVerb.POST, "account/update_profile_image.json", tokens, options) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (image == null || image.Length == 0) { throw new ArithmeticException("Image data cannot be null or zero length."); } if (image.Length > 716800) { throw new ArithmeticException("Image cannot exceed 700Kb in size."); } this.imageData = image; this.Multipart = true; }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, 0, screenName, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Blocks the user and reports them for spam/abuse. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns>The user details.</returns> public static TwitterResponse<TwitterUser> ReportUser(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.ReportSpamCommand command = new Commands.ReportSpamCommand(tokens, userId, string.Empty, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Enables device notifications for updates from the specified user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse<TwitterUser> Follow(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.NotificationFollowCommand command = new Commands.NotificationFollowCommand(tokens, 0, screenName, options); return Core.CommandPerformer.PerformAction(command); }
/// <summary> /// Initializes a new instance of the <see cref="DestroyListSubscriber"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="listId">The list id.</param> /// <param name="options">The options.</param> /// <remarks></remarks> public DestroyListSubscriber(OAuthTokens tokens, decimal listId, OptionalProperties options) : base(HTTPVerb.POST, "lists/subscribers/destroy.json", tokens, options) { this.ListId = listId; }
/// <summary> /// Initializes a new instance of the <see cref="TwitterCommand<T>"/> class. /// </summary> /// <param name="method">The method.</param> /// <param name="endPoint">The end point.</param> /// <param name="tokens">The tokens.</param> /// <param name="optionalProperties">The optional properties.</param> protected TwitterCommand(HTTPVerb method, string endPoint, OAuthTokens tokens, OptionalProperties optionalProperties) { this.RequestParameters = new Dictionary <string, object>(); this.Verb = method; this.Tokens = tokens; this.OptionalProperties = optionalProperties ?? new OptionalProperties(); this.SetCommandUri(endPoint); }
/// <summary> /// Initializes a new instance of the <see cref="DeleteFriendshipCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="userId">The user id.</param> /// <param name="userName">The user name.</param> /// <param name="optionalProperties">The optional properties.</param> public DeleteFriendshipCommand(OAuthTokens tokens, decimal userId, string userName, OptionalProperties optionalProperties) : base(HTTPVerb.POST, Path, tokens, optionalProperties) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (userId <= 0 && string.IsNullOrEmpty(userName)) { throw new ArgumentException("User ID or screen name is required."); } this.UserName = userName; this.UserId = userId; }
/// <summary> /// Blocks the user specified as the authenticating user. Destroys a friendship to the blocked user if it exists. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns> /// The blocked user in the requested format when successful. /// </returns> public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, string.Empty, userId, options); return Core.CommandPerformer<TwitterUser>.PerformAction(command); }
/// <summary> /// Blocks the user specified as the authenticating user. Destroys a friendship to the blocked user if it exists. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns> /// The blocked user in the requested format when successful. /// </returns> public static TwitterResponse <TwitterUser> Create(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, screenName, -1, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Blocks the user specified as the authenticating user. Destroys a friendship to the blocked user if it exists. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns> /// The blocked user in the requested format when successful. /// </returns> public static TwitterResponse <TwitterUser> Create(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, string.Empty, userId, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Initializes a new instance of the <see cref="BlockingIdsCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public BlockingIdsCommand(OAuthTokens tokens, OptionalProperties options) : base(HttpMethod.Get, "blocks/blocking/ids.json", tokens, options) { }
/// <summary> /// Enables device notifications for updates from the specified user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse <TwitterUser> Follow(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.NotificationFollowCommand command = new Commands.NotificationFollowCommand(tokens, 0, screenName, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Initializes a new instance of the <see cref="AddListMemberCommand"/> class. /// </summary> /// <param name="requestTokens">The request tokens.</param> /// <param name="ownerUsername">The owner username.</param> /// <param name="listId">The list id.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> public AddListMemberCommand(OAuthTokens requestTokens, string ownerUsername, string listId, decimal userId, OptionalProperties options) : base(HTTPVerb.POST, string.Format(CultureInfo.CurrentCulture, "{0}/{1}/members.json", ownerUsername, listId), requestTokens, options) { if (requestTokens == null) { throw new ArgumentNullException("requestTokens"); } if (string.IsNullOrEmpty(ownerUsername)) { throw new ArgumentNullException("ownerUsername"); } if (string.IsNullOrEmpty(listId)) { throw new ArgumentNullException("listId"); } if (userId <= 0) { throw new ArgumentNullException("userId"); } this.UserId = userId; }
/// <summary> /// Returns an collection of user ids the authenticating user is blocking. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns>A collection of user ids.</returns> public static TwitterResponse<TwitterIdCollection> BlockingIds(OAuthTokens tokens, OptionalProperties options) { Commands.BlockingIdsCommand command = new Commands.BlockingIdsCommand(tokens, options); return Core.CommandPerformer<TwitterIdCollection>.PerformAction(command); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationFollowCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="screenName">Name of the screen.</param> /// <param name="options">The options.</param> public NotificationLeaveCommand(OAuthTokens tokens, decimal userId, string screenName, OptionalProperties options) : base(HTTPVerb.POST, "notifications/leave.json", tokens, options) { if (userId <= 0 && string.IsNullOrEmpty(screenName)) { throw new ArgumentNullException("userId", "User ID or Screen name must be supplied"); } this.UserId = userId; this.ScreenName = screenName; }
/// <summary> /// Blocks the user specified as the authenticating user. Destroys a friendship to the blocked user if it exists. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">The user's screen name.</param> /// <param name="options">The options.</param> /// <returns> /// The blocked user in the requested format when successful. /// </returns> public static TwitterResponse<TwitterUser> Create(OAuthTokens tokens, string screenName, OptionalProperties options) { Commands.CreateBlockCommand command = new Commands.CreateBlockCommand(tokens, screenName, -1, options); return Core.CommandPerformer<TwitterUser>.PerformAction(command); }
/// <summary> /// Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse <TwitterUser> Leave(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.NotificationLeaveCommand command = new Commands.NotificationLeaveCommand(tokens, userId, string.Empty, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Initializes a new instance of the <see cref="BlockingIdsCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> public BlockingIdsCommand(OAuthTokens tokens, OptionalProperties options) : base(HTTPVerb.GET, "blocks/blocking/ids.json", tokens, options) { }
/// <summary> /// Returns an collection of user ids the authenticating user is blocking. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="options">The options.</param> /// <returns>A collection of user ids.</returns> public static TwitterResponse <TwitterIdCollection> BlockingIds(OAuthTokens tokens, OptionalProperties options) { Commands.BlockingIdsCommand command = new Commands.BlockingIdsCommand(tokens, options); return(Core.CommandPerformer.PerformAction(command)); }
/// <summary> /// Initializes a new instance of the <see cref="DestroyBlockCommand"/> class. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="screenName">Name of the screen.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> public DestroyBlockCommand(OAuthTokens tokens, string screenName, decimal userId, OptionalProperties options) : base(HTTPVerb.POST, "blocks/destroy.json", tokens, options) { if (string.IsNullOrEmpty(screenName) && userId <= 0) { throw new ArgumentException("A screen name or user id is required."); } this.ScreenName = screenName; this.UserId = userId; }
/// <summary> /// Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful. /// </summary> /// <param name="tokens">The tokens.</param> /// <param name="userId">The user id.</param> /// <param name="options">The options.</param> /// <returns></returns> public static TwitterResponse<TwitterUser> Leave(OAuthTokens tokens, decimal userId, OptionalProperties options) { Commands.NotificationLeaveCommand command = new Commands.NotificationLeaveCommand(tokens, userId, string.Empty, options); return Core.CommandPerformer<TwitterUser>.PerformAction(command); }