├── .gitignore ├── LICENSE ├── README.md ├── images ├── net-iron-c.png ├── net-iron-core.png ├── net-iron-mq.png ├── net-iron-w.png └── products.png └── src ├── Demo.IronSharp ├── App.config ├── Demo.IronSharp.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Tests │ ├── IntegrationTests.cs │ └── LongRunningIntegrationTests.cs └── packages.config ├── IronSharp.Core ├── Abstract │ ├── IIdCollection.cs │ ├── IInspectable.cs │ ├── IIronSharpConfig.cs │ ├── IMsg.cs │ ├── IPagingFilter.cs │ ├── IRequestHelpersContainer.cs │ ├── IRestClientRequest.cs │ ├── ITokenContainer.cs │ └── IValueSerializer.cs ├── Attributes │ └── QueueNameAttribute.cs ├── Config │ ├── HttpClientOptions.cs │ ├── IronClientConfig.cs │ ├── IronDotConfigManager.cs │ ├── IronSharpConfig.cs │ └── KeystoneClientConfig.cs ├── Constants │ ├── AuthHeaderLocation.cs │ └── IronProduct.cs ├── Content │ ├── iron.json │ └── web.config.transform ├── DateTimeHelpers.cs ├── DefaultValueSerializer.cs ├── Exceptions │ ├── IronSharpException.cs │ ├── MaximumRetryAttemptsExceededException.cs │ └── RestResponseException.cs ├── ExponentialBackoff.cs ├── Extensions │ ├── ExtensionsForDictionary.cs │ ├── ExtensionsForIInspectable.cs │ ├── ExtensionsForIMsg.cs │ └── ExtensionsForString.cs ├── IronSharp.Core.csproj ├── IronSharp.Core.csproj.DotSettings ├── IronSharp.Core.nuspec ├── JSON.cs ├── JsonContent.cs ├── MqRestClient.cs ├── Properties │ └── AssemblyInfo.cs ├── RestClient.cs ├── Types │ ├── HttpRequestMessageBuilder.cs │ ├── IronTokenContainer.cs │ ├── Keystone.cs │ ├── KeystoneContainer.cs │ ├── PagingFilter.cs │ ├── ResponseMsg.cs │ ├── RestClientRequest.cs │ └── RestResponse.cs └── packages.config ├── IronSharp.Extras.ProtoBufSerializers ├── ExtensionsForISharpConfig.cs ├── IronSharp.Extras.ProtoBufSerializers.csproj ├── ModelSerializerContext.cs ├── Properties │ └── AssemblyInfo.cs ├── ProtoBufConfig.cs ├── ProtoBufValueSerializer.cs └── packages.config ├── IronSharp.Extras.ServiceStackSerializers ├── ExtensionsForISharpConfig.cs ├── IronSharp.Extras.ServiceStackSerializers.2013.10.55.845.nupkg ├── IronSharp.Extras.ServiceStackSerializers.csproj ├── IronSharp.Extras.ServiceStackSerializers.nuspec ├── Properties │ └── AssemblyInfo.cs ├── ServiceStackJsonSerializer.cs ├── ServiceStackTypeSerializer.cs ├── ServiceStackXmlSerializer.cs └── packages.config ├── IronSharp.IronCache ├── CacheClient.cs ├── CacheIncrementResult.cs ├── CacheInfo.cs ├── CacheItem.cs ├── CacheItemOptions.cs ├── Client.cs ├── IronCacheCloudHosts.cs ├── IronCacheRestClient.cs ├── IronSharp.IronCache.csproj ├── IronSharp.IronCache.nuspec ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── IronSharp.IronMQ ├── Alert.cs ├── AlertCollection.cs ├── AlertDirection.cs ├── AlertType.cs ├── Client.cs ├── IronMqCloudHosts.cs ├── IronMqRestClient.cs ├── IronSharp.IronMQ.csproj ├── IronSharp.IronMQ.nuspec ├── MessageCollection.cs ├── MessageContainer.cs ├── MessageIdCollection.cs ├── MessageIdContainer.cs ├── MessageOptions.cs ├── MqPagingFilter.cs ├── Properties │ └── AssemblyInfo.cs ├── PushInfo.cs ├── PushStatus.cs ├── PushType.cs ├── QueueClient.cs ├── QueueContainer.cs ├── QueueDeadletterInfo.cs ├── QueueInfo.cs ├── QueueMessage.cs ├── QueueMessageContext.cs ├── QueuesInfo.cs ├── ReservedMessageIdCollection.cs ├── Subscriber.cs ├── SubscriberCollection.cs └── packages.config ├── IronSharp.IronWorker ├── Client.cs ├── Code │ ├── CodeClient.cs │ ├── CodeInfo.cs │ ├── CodeInfoCollection.cs │ ├── RevisionCollection.cs │ └── WorkerOptions.cs ├── IronSharp.IronWorker.csproj ├── IronSharp.IronWorker.csproj.DotSettings ├── IronSharp.IronWorker.nuspec ├── IronWorkCloudHosts.cs ├── IronWorkerRestClient.cs ├── PriorityOption.cs ├── Properties │ └── AssemblyInfo.cs ├── Schedules │ ├── ScheduleBuilder.cs │ ├── ScheduleClient.cs │ ├── ScheduleIdCollection.cs │ ├── ScheduleInfo.cs │ ├── ScheduleInfoCollection.cs │ ├── ScheduleOptions.cs │ ├── ScheduleOptionsBuilder.cs │ ├── SchedulePayload.cs │ ├── SchedulePayloadCollection.cs │ └── TimeUnit.cs ├── TaskPriority.cs ├── TaskStates.cs ├── Tasks │ ├── TaskClient.cs │ ├── TaskId.cs │ ├── TaskIdCollection.cs │ ├── TaskInfo.cs │ ├── TaskInfoCollection.cs │ ├── TaskListFilter.cs │ ├── TaskOptions.cs │ ├── TaskPayload.cs │ ├── TaskPayloadCollection.cs │ ├── TaskProgress.cs │ └── TaskWebhookResponse.cs └── packages.config ├── IronSharp.sln ├── IronSharp.sln.DotSettings └── SolutionInfo.cs /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | *.nupkg 84 | 85 | # Windows Azure Build Output 86 | csx 87 | *.build.csdef 88 | 89 | # Windows Store app package directory 90 | AppPackages/ 91 | 92 | # Others 93 | [Bb]in 94 | [Oo]bj 95 | sql 96 | TestResults 97 | [Tt]est[Rr]esult* 98 | *.Cache 99 | ClientBin 100 | [Ss]tyle[Cc]op.* 101 | ~$* 102 | *.dbmdl 103 | Generated_Code #added for RIA/Silverlight projects 104 | 105 | # Backup & report files from converting an old project file to a newer 106 | # Visual Studio version. Backup files are not needed, because we have git ;-) 107 | _UpgradeReport_Files/ 108 | Backup*/ 109 | UpgradeLog*.XML 110 | 111 | src/*/lib/*.dll 112 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Jeremy Bell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /images/net-iron-c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/images/net-iron-c.png -------------------------------------------------------------------------------- /images/net-iron-core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/images/net-iron-core.png -------------------------------------------------------------------------------- /images/net-iron-mq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/images/net-iron-mq.png -------------------------------------------------------------------------------- /images/net-iron-w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/images/net-iron-w.png -------------------------------------------------------------------------------- /images/products.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/images/products.png -------------------------------------------------------------------------------- /src/Demo.IronSharp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Demo.IronSharp/Demo.IronSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B} 8 | Exe 9 | Properties 10 | Demo.IronSharpConsole 11 | Demo.IronSharpConsole 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll 38 | 39 | 40 | ..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll 41 | 42 | 43 | False 44 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {1a6cc922-40a5-440a-868d-757fcdb08622} 62 | IronSharp.Core 63 | 64 | 65 | {2603e861-09ab-482e-bf28-41d8b0b1b20b} 66 | IronSharp.IronCache 67 | 68 | 69 | {d891a220-aa6f-4d0c-b012-b25875787ba0} 70 | IronSharp.IronMQ 71 | 72 | 73 | {4fa5bf5d-c543-404e-89ec-c3bff90acf6b} 74 | IronSharp.IronWorker 75 | 76 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /src/Demo.IronSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("Demo.IronSharp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Demo.IronSharp")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly: Guid("668efe21-f96d-4736-8de1-d34d47b7a416")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Demo.IronSharp/Tests/IntegrationTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | using IronSharp.Core; 6 | using IronSharp.IronMQ; 7 | using NUnit.Framework; 8 | 9 | namespace Demo.IronSharpConsole.Tests 10 | { 11 | [TestFixture] 12 | class IntegrationTests 13 | { 14 | private IronMqRestClient ironMq; 15 | 16 | private QueueClient queue; 17 | 18 | [SetUp] 19 | public void Init() 20 | { 21 | // Put your ".iron.json" file to home directory, eg. C:\Users\YourUsername 22 | ironMq = Client.New(); 23 | queue = ironMq.Queue(GetQueueName()); 24 | queue.Clear(); 25 | 26 | // Or config the client here: 27 | // ironMq = Client.New(new IronClientConfig 28 | // { 29 | // ProjectId = "xxxxxxxxxxxxxxxxxxxxxxxx", 30 | // Token = "yyyyyyyyyyyyyyyyyyyy", 31 | // Host = "host-of-ironmq.com", 32 | // ApiVersion = 3, 33 | // Port = 80, 34 | // Scheme = Uri.UriSchemeHttp 35 | // }); 36 | } 37 | 38 | [TearDown] 39 | public void After() 40 | { 41 | queue.Delete(); 42 | } 43 | 44 | [Test] 45 | public void PostMessage() 46 | { 47 | string messageId = queue.Post("some data"); 48 | Assert.IsTrue(Regex.IsMatch(messageId, "^[a-f0-9]{19}$")); 49 | } 50 | 51 | [Test] 52 | public void ReserveMessage() 53 | { 54 | queue.Post("one"); 55 | 56 | var msg = queue.Reserve(); 57 | Assert.AreEqual(19, msg.Id.Length); 58 | Assert.IsTrue(Regex.IsMatch(msg.ReservationId, "^[a-f0-9]{32}$")); 59 | } 60 | 61 | [Test] 62 | public void ReserveMessages() 63 | { 64 | for (int i = 0; i < 2; i++) 65 | queue.Post(i.ToString()); 66 | 67 | var messagesContainer = queue.Reserve(3); 68 | foreach (var message in messagesContainer.Messages) 69 | { 70 | Assert.AreEqual(19, message.Id.Length); 71 | Assert.IsTrue(Regex.IsMatch(message.ReservationId, "^[a-f0-9]{32}$")); 72 | } 73 | } 74 | 75 | [Test] 76 | public void ClearQueue() 77 | { 78 | queue.Post("one"); 79 | var cleared = queue.Clear(); 80 | Assert.IsTrue(cleared); 81 | Assert.AreEqual(queue.Info().Size, 0); 82 | } 83 | 84 | [Test] 85 | public void DeleteReservedMessage() 86 | { 87 | PostTwoMessages(); 88 | var message = queue.Reserve(); 89 | var deleted = message.Delete(); 90 | Assert.IsTrue(deleted); 91 | Assert.AreEqual(queue.Info().Size, 1); 92 | } 93 | 94 | [Test] 95 | public void DeleteReservedMessageViaQueue() 96 | { 97 | PostTwoMessages(); 98 | var message = queue.Reserve(); 99 | var deleted = queue.DeleteMessage(message.Id, message.ReservationId); 100 | Assert.IsTrue(deleted); 101 | Assert.AreEqual(queue.Info().Size, 1); 102 | } 103 | 104 | [Test] 105 | public void DeleteNotReservedMessage() 106 | { 107 | queue.Post("one"); 108 | var messageId = queue.Post("two"); 109 | var deleted = queue.Delete(messageId); 110 | Assert.IsTrue(deleted); 111 | Assert.AreEqual(1, queue.Info().Size); 112 | } 113 | 114 | [Test] 115 | public void DeleteNotReservedMessageViaQueue() 116 | { 117 | var messageId = queue.Post("one"); 118 | queue.Post("two"); 119 | var deleted = queue.DeleteMessage(messageId); 120 | Assert.IsTrue(deleted); 121 | Assert.AreEqual(1, queue.Info().Size); 122 | } 123 | 124 | [Test] 125 | public void UpdateQueue() 126 | { 127 | var expectedTimeout = 66; 128 | var expectedExpiration = 3333; 129 | queue.Update(new QueueInfo { MessageTimeout = expectedTimeout, MessageExpiration = expectedExpiration }); 130 | 131 | var actualQueueInfo = queue.Info(); 132 | Assert.AreEqual(expectedTimeout, actualQueueInfo.MessageTimeout); 133 | Assert.AreEqual(expectedExpiration, actualQueueInfo.MessageExpiration); 134 | } 135 | 136 | [Test] 137 | public void DeleteQueue() 138 | { 139 | var q = ironMq.Queue(GetQueueName()); 140 | q.Post("one"); 141 | var deleted = q.Delete(); 142 | Assert.IsTrue(deleted); 143 | Assert.IsNull(q.Info()); 144 | } 145 | 146 | [Test] 147 | public void GetMessageById() 148 | { 149 | var expectedBody = "testGetById"; 150 | var messageId = queue.Post(expectedBody); 151 | Assert.AreEqual(expectedBody,queue.Get(messageId).Body); 152 | } 153 | 154 | [Test] 155 | public void PeekMessage() 156 | { 157 | var firstMessageId = queue.Post("one"); 158 | queue.Post("two"); 159 | var peekedMessage = queue.PeekNext(); 160 | Assert.AreEqual(firstMessageId, peekedMessage.Id); 161 | } 162 | 163 | [Test] 164 | public void ReleaseMessage() 165 | { 166 | queue.Post("one"); 167 | var msg = queue.Reserve(); 168 | var released = msg.Release(); 169 | Assert.IsTrue(released); 170 | Assert.AreEqual(msg.Id,queue.Reserve().Id); 171 | } 172 | 173 | [Test] 174 | public void DeleteMessages() 175 | { 176 | PostTwoMessages(); 177 | var messages = queue.Reserve(2); 178 | queue.Delete(messages); 179 | Assert.AreEqual(0, queue.Info().Size); 180 | } 181 | 182 | [Test] 183 | public void CreatePushQueue() 184 | { 185 | var q = ironMq.Queue(GetQueueName()); 186 | var pushInfo = GenerateSubscribers(1); 187 | q.Update(new QueueInfo { PushType = PushType.Multicast, PushInfo = pushInfo}); 188 | 189 | Assert.AreEqual(PushType.Multicast, q.Info().PushType); 190 | } 191 | 192 | [Test] 193 | public void AddSubscribers() 194 | { 195 | var q = ironMq.Queue(GetQueueName()); 196 | var pushInfo = GenerateSubscribers(2); 197 | q.Update(new QueueInfo { PushType = PushType.Multicast, PushInfo = pushInfo }); 198 | var actualPushInfo = q.Info().PushInfo; 199 | 200 | Assert.AreEqual(pushInfo.Subscribers.Count, actualPushInfo.Subscribers.Count); 201 | Assert.AreEqual(pushInfo.Subscribers[0].Url, actualPushInfo.Subscribers[0].Url); 202 | Assert.AreEqual(pushInfo.Subscribers[1].Url, actualPushInfo.Subscribers[1].Url); 203 | } 204 | 205 | private void PostTwoMessages() 206 | { 207 | queue.Post("one"); 208 | queue.Post("two"); 209 | } 210 | 211 | private String GetQueueName() 212 | { 213 | return String.Format("queue{0}", DateTime.Now.Ticks); 214 | } 215 | 216 | private PushInfo GenerateSubscribers(int count) 217 | { 218 | var subscribes = new List(); 219 | for(int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IIdCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public interface IIdCollection 6 | { 7 | IEnumerable GetIds(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IInspectable.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public interface IInspectable 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IIronSharpConfig.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public interface IIronSharpConfig 4 | { 5 | IronSharpConfig SharpConfig { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IMsg.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public interface IMsg 4 | { 5 | /// 6 | /// Gets the information message 7 | /// 8 | string Message { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IPagingFilter.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public interface IPagingFilter 4 | { 5 | /// 6 | /// The 0-based page to view. The default is 0. 7 | /// 8 | int Page { get; set; } 9 | 10 | /// 11 | /// The number of queues to return per page. The default is 30, the maximum is 100. 12 | /// 13 | int PerPage { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IRequestHelpersContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.Linq; 5 | using System.Net.Http.Headers; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace IronSharp.Core.Abstract 10 | { 11 | interface IRequestHelpersContainer 12 | { 13 | Uri BuildUri(IronClientConfig config, string path, NameValueCollection query); 14 | 15 | void SetOathQueryParameterIfRequired(IRestClientRequest request, string token); 16 | 17 | void SetOauthHeaderIfRequired(IronClientConfig config, IRestClientRequest request, HttpRequestHeaders headers); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IRestClientRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Net.Http; 3 | 4 | namespace IronSharp.Core 5 | { 6 | public interface IRestClientRequest 7 | { 8 | HttpContent Content { get; set; } 9 | 10 | string EndPoint { get; set; } 11 | 12 | NameValueCollection Query { get; set; } 13 | 14 | HttpMethod Method { get; set; } 15 | 16 | string Accept { get; set; } 17 | 18 | AuthTokenLocation AuthTokenLocation { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/ITokenContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace IronSharp.Core 8 | { 9 | public interface ITokenContainer 10 | { 11 | String getToken(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Abstract/IValueSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public interface IValueSerializer 6 | { 7 | string Generate(object value); 8 | 9 | object Parse(string value, Type type); 10 | 11 | T Parse(string value); 12 | } 13 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Attributes/QueueNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.Core.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class, Inherited = true)] 6 | public sealed class QueueNameAttribute : Attribute 7 | { 8 | public QueueNameAttribute(string name) 9 | { 10 | Name = name; 11 | } 12 | 13 | public string Name { get; private set; } 14 | 15 | public static string GetName() 16 | { 17 | Type type = typeof(T); 18 | object[] customAttributes = type.GetCustomAttributes(typeof(QueueNameAttribute), true); 19 | return customAttributes.Length > 0 ? ((QueueNameAttribute) customAttributes[0]).Name : type.FullName; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Config/HttpClientOptions.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public static class HttpClientOptions 4 | { 5 | static HttpClientOptions() 6 | { 7 | EnableRetry = true; 8 | RetryLimit = 4; 9 | } 10 | 11 | public static bool EnableRetry { get; set; } 12 | 13 | public static int RetryLimit { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Config/IronClientConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class IronClientConfig : IIronSharpConfig, IInspectable 8 | { 9 | private IronSharpConfig _sharpConfig; 10 | 11 | [JsonProperty("host")] 12 | public string Host { get; set; } 13 | 14 | [JsonProperty("project_id")] 15 | public string ProjectId { get; set; } 16 | 17 | [JsonProperty("token")] 18 | public string Token { get; set; } 19 | 20 | [JsonProperty("api_version")] 21 | public int ApiVersion { get; set; } 22 | 23 | [JsonProperty("port")] 24 | public int? Port { get; set; } 25 | 26 | [JsonProperty("scheme")] 27 | public String Scheme { get; set; } 28 | 29 | [JsonProperty("keystone")] 30 | public KeystoneClientConfig Keystone { get; set; } 31 | 32 | [JsonProperty("sharp_config")] 33 | public IronSharpConfig SharpConfig 34 | { 35 | get { return LazyInitializer.EnsureInitialized(ref _sharpConfig, CreateDefaultIronSharpConfig); } 36 | set { _sharpConfig = value; } 37 | } 38 | 39 | public bool KeystoneKeysExist() 40 | { 41 | return Keystone.Tenant != null && Keystone.Server != null && 42 | Keystone.Username != null && Keystone.Password != null; 43 | } 44 | 45 | private static IronSharpConfig CreateDefaultIronSharpConfig() 46 | { 47 | return new IronSharpConfig 48 | { 49 | BackoffFactor = 25 50 | }; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Config/IronDotConfigManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Web.Hosting; 6 | using Common.Logging; 7 | using Newtonsoft.Json; 8 | 9 | namespace IronSharp.Core 10 | { 11 | /// 12 | /// http://dev.iron.io/cache/reference/configuration/ 13 | /// 14 | public static class IronDotConfigManager 15 | { 16 | public static string GetEnvironmentKey(IronProduct product, string key) 17 | { 18 | if (key == null) throw new ArgumentNullException("key"); 19 | 20 | string productName = GetProductName(product); 21 | 22 | return string.Format("{0}_{1}", productName, key).ToUpper(); 23 | } 24 | 25 | public static T GetEnvironmentValue(IronProduct product, string key, EnvironmentVariableTarget target = EnvironmentVariableTarget.Process) 26 | { 27 | return GetEnvironmentValue(product, key, default(T), target); 28 | } 29 | 30 | public static T GetEnvironmentValue(IronProduct product, string key, T defaultValue, EnvironmentVariableTarget target = EnvironmentVariableTarget.Process) 31 | { 32 | return Environment.GetEnvironmentVariable(GetEnvironmentKey(product, key), target).As(defaultValue); 33 | } 34 | 35 | public static IronClientConfig Load(IronProduct product = IronProduct.AllProducts, IronClientConfig overrideConfig = null, string env = null) 36 | { 37 | string homeIronDotJson = Path.Combine(GetHomeDirectory(), ".iron.json"); 38 | string appIronDotJson = Path.Combine(GetAppDirectory(), "iron.json"); 39 | 40 | IronClientConfig home = ParseJsonFile(product, homeIronDotJson, env); 41 | IronClientConfig app = ParseJsonFile(product, appIronDotJson, env); 42 | 43 | ApplyOverrides(home, app); 44 | ApplyOverrides(home, overrideConfig); 45 | 46 | return home; 47 | } 48 | 49 | public static IronClientConfig LoadFromEnvironment(IronProduct product, EnvironmentVariableTarget target = EnvironmentVariableTarget.Process) 50 | { 51 | var baseConfig = new IronClientConfig 52 | { 53 | ProjectId = GetEnvironmentValue(IronProduct.AllProducts, "projectid", target), 54 | Token = GetEnvironmentValue(IronProduct.AllProducts, "token", target) 55 | }; 56 | 57 | var productConfig = new IronClientConfig 58 | { 59 | ProjectId = GetEnvironmentValue(product, "projectid", target), 60 | Token = GetEnvironmentValue(product, "token", target), 61 | Host = GetEnvironmentValue(product, "host", target) 62 | }; 63 | 64 | ApplyOverrides(baseConfig, productConfig); 65 | 66 | return baseConfig; 67 | } 68 | 69 | public static IronClientConfig ParseJsonFile(IronProduct product, string filePath, string env = null) 70 | { 71 | JsonDotConfigModel config = LoadJson(filePath, env); 72 | 73 | var settings = new IronClientConfig 74 | { 75 | ProjectId = config.ProjectId, 76 | Token = config.Token, 77 | Host = config.Host, 78 | Keystone = config.Keystone 79 | }; 80 | 81 | ApplyOverrides(settings, GetProductOverride(product, config)); 82 | 83 | return settings; 84 | } 85 | 86 | public static void SetEnvironmentValue(IronProduct product, string key, string value, EnvironmentVariableTarget target = EnvironmentVariableTarget.Process) 87 | { 88 | Environment.SetEnvironmentVariable(GetEnvironmentKey(product, key), value, target); 89 | } 90 | 91 | public static void DeleteEnvironmentValue(IronProduct product, string key, EnvironmentVariableTarget target = EnvironmentVariableTarget.Process) 92 | { 93 | SetEnvironmentValue(product, key, null, target); 94 | } 95 | 96 | private static void ApplyOverrides(IronClientConfig targetConfig, IronClientConfig overrideConfig) 97 | { 98 | if (overrideConfig == null) 99 | { 100 | return; 101 | } 102 | 103 | targetConfig.ProjectId = string.IsNullOrEmpty(overrideConfig.ProjectId) ? targetConfig.ProjectId : overrideConfig.ProjectId; 104 | targetConfig.Token = string.IsNullOrEmpty(overrideConfig.Token) ? targetConfig.Token : overrideConfig.Token; 105 | targetConfig.Host = string.IsNullOrEmpty(overrideConfig.Host) ? targetConfig.Host : overrideConfig.Host; 106 | targetConfig.Scheme = string.IsNullOrEmpty(overrideConfig.Scheme) ? targetConfig.Scheme : overrideConfig.Scheme; 107 | targetConfig.ApiVersion = overrideConfig.ApiVersion == default(int) ? targetConfig.ApiVersion : overrideConfig.ApiVersion; 108 | targetConfig.Port = overrideConfig.Port.HasValue ? overrideConfig.Port : targetConfig.Port; 109 | targetConfig.Keystone = overrideConfig.Keystone == null ? targetConfig.Keystone : overrideConfig.Keystone; 110 | } 111 | 112 | private static string _appDirectory; 113 | 114 | public static void SetAppDirectory(string path) 115 | { 116 | _appDirectory = path; 117 | } 118 | 119 | private static string GetAppDirectory() 120 | { 121 | if (string.IsNullOrEmpty(_appDirectory)) 122 | { 123 | _appDirectory = HostingEnvironment.IsHosted ? 124 | HostingEnvironment.MapPath("~/") : 125 | Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); 126 | } 127 | return _appDirectory; 128 | } 129 | 130 | private static string GetHomeDirectory() 131 | { 132 | return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); 133 | } 134 | 135 | private static string GetProductName(IronProduct product) 136 | { 137 | string productName; 138 | 139 | switch (product) 140 | { 141 | case IronProduct.AllProducts: 142 | productName = "iron"; 143 | break; 144 | case IronProduct.IronMQ: 145 | productName = "iron_mq"; 146 | break; 147 | case IronProduct.IronWorker: 148 | productName = "iron_worker"; 149 | break; 150 | case IronProduct.IronCache: 151 | productName = "iron_cache"; 152 | break; 153 | default: 154 | throw new ArgumentOutOfRangeException("product"); 155 | } 156 | return productName; 157 | } 158 | 159 | private static IronClientConfig GetProductOverride(IronProduct product, JsonDotConfigModel config) 160 | { 161 | IronClientConfig productOverride = null; 162 | 163 | switch (product) 164 | { 165 | case IronProduct.IronCache: 166 | productOverride = config.IronCache; 167 | break; 168 | case IronProduct.IronMQ: 169 | productOverride = config.IronMQ; 170 | break; 171 | case IronProduct.IronWorker: 172 | productOverride = config.IronWoker; 173 | break; 174 | } 175 | return productOverride; 176 | } 177 | 178 | private static JsonDotConfigModel LoadJson(string filePath, string env = null) 179 | { 180 | try 181 | { 182 | if (File.Exists(filePath)) 183 | { 184 | string content = File.ReadAllText(filePath); 185 | 186 | if (!string.IsNullOrEmpty(env)) 187 | { 188 | var envType = JsonConvert.DeserializeObject>(content, new JsonSerializerSettings 189 | { 190 | Error = (sender, args) => 191 | { 192 | args.ErrorContext.Handled = true; 193 | } 194 | }); 195 | JsonDotConfigModel envSpecific; 196 | if (envType.TryGetValue(env, out envSpecific)) 197 | { 198 | return envSpecific; 199 | } 200 | } 201 | return JsonConvert.DeserializeObject(content); 202 | } 203 | } 204 | catch (IOException ex) 205 | { 206 | LogManager.GetCurrentClassLogger().Error(ex); 207 | } 208 | return new JsonDotConfigModel(); 209 | } 210 | 211 | private class JsonDotConfigModel : IronClientConfig 212 | { 213 | [JsonProperty("iron_cache")] 214 | public IronClientConfig IronCache { get; set; } 215 | 216 | [JsonProperty("iron_mq")] 217 | public IronClientConfig IronMQ { get; set; } 218 | 219 | [JsonProperty("iron_worker")] 220 | public IronClientConfig IronWoker { get; set; } 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Config/IronSharpConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.Core 5 | { 6 | public class IronSharpConfig : IInspectable 7 | { 8 | private IValueSerializer _valueSerializer; 9 | 10 | [JsonProperty("back_off_factor")] 11 | public double BackoffFactor { get; set; } 12 | 13 | [JsonIgnore] 14 | public IValueSerializer ValueSerializer 15 | { 16 | get { return LazyInitializer.EnsureInitialized(ref _valueSerializer, () => new DefaultValueSerializer()); } 17 | set { _valueSerializer = value; } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Config/KeystoneClientConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class KeystoneClientConfig 8 | { 9 | [JsonProperty("tenant")] 10 | public String Tenant { get; set; } 11 | 12 | [JsonProperty("server")] 13 | public String Server { get; set; } 14 | 15 | [JsonProperty("username")] 16 | public String Username { get; set; } 17 | 18 | [JsonProperty("password")] 19 | public String Password { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Constants/AuthHeaderLocation.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public enum AuthTokenLocation 4 | { 5 | None = 0, 6 | Header = 1, 7 | Querystring = 2 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Constants/IronProduct.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public enum IronProduct 4 | { 5 | AllProducts = 0, 6 | IronMQ, 7 | IronWorker, 8 | IronCache 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Content/iron.json: -------------------------------------------------------------------------------- 1 | {"token":"XXXXXXXXXXXXXXXXXXXXXXXXXX","project_id":"0000000000000000000000000000"} -------------------------------------------------------------------------------- /src/IronSharp.Core/Content/web.config.transform: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IronSharp.Core/DateTimeHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public static class DateTimeHelpers 6 | { 7 | public static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1); 8 | 9 | public static int SecondsSinceEpoch(DateTime value) 10 | { 11 | return (value - UnixEpoch).Seconds; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/DefaultValueSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.Core 5 | { 6 | public class DefaultValueSerializer : IValueSerializer 7 | { 8 | private readonly JsonSerializerSettings _settings; 9 | 10 | public DefaultValueSerializer() : this(null) 11 | { 12 | } 13 | 14 | public DefaultValueSerializer(JsonSerializerSettings settings) 15 | { 16 | _settings = settings; 17 | } 18 | 19 | public string Generate(object value) 20 | { 21 | return JSON.Generate(value, _settings); 22 | } 23 | 24 | public object Parse(string value, Type type) 25 | { 26 | return JSON.Parse(value, type); 27 | } 28 | 29 | public T Parse(string value) 30 | { 31 | return JSON.Parse(value, _settings); 32 | } 33 | } 34 | 35 | public static class ExtensionsForDefaultSerializer 36 | { 37 | public static void UseDefaultSerializer(this IIronSharpConfig config) 38 | { 39 | config.SharpConfig.ValueSerializer = null; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Exceptions/IronSharpException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public class IronSharpException : ApplicationException 6 | { 7 | public IronSharpException(string message) : base(message) 8 | { 9 | } 10 | 11 | public IronSharpException(string message, Exception innerException) : base(message, innerException) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Exceptions/MaximumRetryAttemptsExceededException.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public class MaximumRetryAttemptsExceededException : IronSharpException 6 | { 7 | private readonly HttpRequestMessage _request; 8 | 9 | public MaximumRetryAttemptsExceededException(HttpRequestMessage request, int maxAttempts) 10 | : base(string.Format("The maximum number of retry attempts ({0}) has been exceeded.", maxAttempts)) 11 | { 12 | _request = request; 13 | } 14 | 15 | public HttpRequestMessage Request 16 | { 17 | get { return _request; } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Exceptions/RestResponseException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Net.Http; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class RestResponseException : IronSharpException 8 | { 9 | public RestResponseException(string message, HttpResponseMessage response) 10 | : base(message + AppendDebugInfo(response)) 11 | { 12 | Response = response; 13 | } 14 | 15 | public RestResponseException(string message, HttpResponseMessage response, Exception innerException) 16 | : base(message + AppendDebugInfo(response), innerException) 17 | { 18 | Response = response; 19 | } 20 | 21 | public HttpRequestMessage RequestMessage 22 | { 23 | get { return Response.RequestMessage; } 24 | } 25 | 26 | public HttpResponseMessage Response { get; set; } 27 | 28 | private static string AppendDebugInfo(HttpResponseMessage response) 29 | { 30 | if (response == null || response.RequestMessage == null) 31 | { 32 | return null; 33 | } 34 | 35 | using (var sw = new StringWriter()) 36 | { 37 | HttpRequestMessage request = response.RequestMessage; 38 | 39 | sw.WriteLine(); 40 | 41 | sw.WriteLine("RequestUri: {0} {1}", request.Method, request.RequestUri); 42 | 43 | if (request.Content != null) 44 | { 45 | try 46 | { 47 | sw.WriteLine(request.Content.ReadAsStringAsync().Result); 48 | } 49 | catch (Exception e) 50 | { 51 | sw.WriteLine("Unable to read response content. " + e.Message); 52 | } 53 | } 54 | 55 | return sw.ToString(); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/ExponentialBackoff.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace IronSharp.Core 5 | { 6 | internal static class ExponentialBackoff 7 | { 8 | public static void Sleep(double backoffFactor, int attempt) 9 | { 10 | Thread.Sleep(TimeSpan.FromMilliseconds(Math.Pow(backoffFactor, attempt))); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Extensions/ExtensionsForDictionary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Diagnostics.Contracts; 6 | 7 | namespace IronSharp.Core 8 | { 9 | public static class ExtensionsForDictionary 10 | { 11 | public static void AddValues(this IDictionary dictionary, object value) 12 | { 13 | if (value == null) 14 | { 15 | return; 16 | } 17 | foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(value)) 18 | { 19 | dictionary.Add(item.Name, item.GetValue(value)); 20 | } 21 | } 22 | 23 | public static TValue Get(this IDictionary dictionary, object key) 24 | { 25 | Contract.Requires(dictionary != null); 26 | if (!dictionary.Contains(key)) 27 | { 28 | return default(TValue); 29 | } 30 | return (TValue) dictionary[key]; 31 | } 32 | 33 | public static TValue Get(this IDictionary dictionary, string key, TValue defaultValue = default(TValue)) 34 | { 35 | Contract.Requires(dictionary != null); 36 | object value; 37 | if (dictionary.TryGetValue(key, out value)) 38 | { 39 | try 40 | { 41 | return (TValue) value; 42 | } 43 | catch (InvalidCastException) 44 | { 45 | return Convert.ToString(value).As(); 46 | } 47 | } 48 | return defaultValue; 49 | } 50 | 51 | public static TValue GetOrAdd(this IDictionary dictionary, object key, Func valueFactory) 52 | { 53 | Contract.Requires(dictionary != null); 54 | if (dictionary.Contains(key)) 55 | { 56 | return (TValue) dictionary[key]; 57 | } 58 | TValue instance = valueFactory.Invoke(key); 59 | dictionary[key] = instance; 60 | return instance; 61 | } 62 | 63 | public static TValue GetOrAdd(this IDictionary dictionary, string key, TValue defaultValue) 64 | { 65 | return GetOrAdd(dictionary, key, () => defaultValue); 66 | } 67 | 68 | public static TValue GetOrAdd(this IDictionary dictionary, string key, Func valueFactory) 69 | { 70 | Contract.Requires(dictionary != null); 71 | lock (dictionary) 72 | { 73 | if (!dictionary.ContainsKey(key)) 74 | { 75 | dictionary.Set(key, valueFactory.Invoke()); 76 | } 77 | return (TValue) dictionary[key]; 78 | } 79 | } 80 | 81 | public static TValue GetOrAdd(this IDictionary dictionary, string key, Func valueFactory) 82 | { 83 | Contract.Requires(dictionary != null); 84 | lock (dictionary) 85 | { 86 | if (!dictionary.ContainsKey(key)) 87 | { 88 | dictionary.Set(key, valueFactory.Invoke(key)); 89 | } 90 | return (TValue) dictionary[key]; 91 | } 92 | } 93 | 94 | public static void Set(this IDictionary dictionary, object key, object value) 95 | { 96 | Contract.Requires(dictionary != null); 97 | dictionary[key] = value; 98 | } 99 | 100 | 101 | public static void Set(this IDictionary dictionary, TKey key, TValue value) 102 | { 103 | Contract.Requires(dictionary != null); 104 | dictionary[key] = value; 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Extensions/ExtensionsForIInspectable.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public static class ExtensionsForIInspectable 4 | { 5 | public static string Inspect(this IInspectable value) 6 | { 7 | return JSON.Generate(value); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Extensions/ExtensionsForIMsg.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.Core 2 | { 3 | public static class ExtensionsForIMsg 4 | { 5 | public static bool HasExpectedMessage(this IMsg msg, string message) 6 | { 7 | return msg != null && msg.Message == message; 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/IronSharp.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1A6CC922-40A5-440A-868D-757FCDB08622} 8 | Library 9 | Properties 10 | IronSharp.Core 11 | IronSharp.Core 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | bin\Publish\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | 43 | ..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll 44 | 45 | 46 | ..\packages\Newtonsoft.Json.5.0.7\lib\net45\Newtonsoft.Json.dll 47 | 48 | 49 | 50 | 51 | 52 | 53 | ..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Designer 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 120 | -------------------------------------------------------------------------------- /src/IronSharp.Core/IronSharp.Core.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True 6 | True 7 | True -------------------------------------------------------------------------------- /src/IronSharp.Core/IronSharp.Core.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iron.IronCore 5 | 3.0.10 6 | IronCore 7 | Jeremy Bell 8 | Iron.io 9 | https://raw.github.com/iron-io/iron_dotnet/master/LICENSE 10 | https://github.com/iron-io/iron_dotnet 11 | https://raw.github.com/iron-io/iron_dotnet/master/images/net-iron-core.png 12 | false 13 | IronCore is core for IronWorker, IronMq, IronCache packets 14 | New version for MQ v3 and others products 15 | iron.io 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/IronSharp.Core/JSON.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public static class JSON 8 | { 9 | private static JsonSerializerSettings _settings; 10 | 11 | public static JsonSerializerSettings Settings 12 | { 13 | get { return LazyInitializer.EnsureInitialized(ref _settings, GetDefaultSerializerSettings); } 14 | set { _settings = value; } 15 | } 16 | 17 | public static string Generate(object value, JsonSerializerSettings opts = null) 18 | { 19 | return Generate(value, null, opts); 20 | } 21 | 22 | public static string Generate(object value, Type type, JsonSerializerSettings opts = null) 23 | { 24 | return JsonConvert.SerializeObject(value, type, Formatting.None, opts ?? Settings); 25 | } 26 | 27 | public static T Parse(string value, JsonSerializerSettings opts = null) 28 | { 29 | return (T)Parse(value, typeof(T), opts); 30 | } 31 | 32 | public static object Parse(string value, Type type, JsonSerializerSettings opts = null) 33 | { 34 | return DeserializeObject(value, type, opts); 35 | } 36 | 37 | private static object DeserializeObject(string value, Type type, JsonSerializerSettings opts) 38 | { 39 | // If the target type is already string, then there is no need to Deserialize the value. 40 | if (type == typeof (string)) 41 | { 42 | return value; 43 | } 44 | return JsonConvert.DeserializeObject(value, type, opts ?? Settings); 45 | } 46 | 47 | private static JsonSerializerSettings GetDefaultSerializerSettings() 48 | { 49 | return new JsonSerializerSettings 50 | { 51 | DefaultValueHandling = DefaultValueHandling.Ignore, 52 | ReferenceLoopHandling = ReferenceLoopHandling.Ignore, 53 | DateFormatHandling = DateFormatHandling.IsoDateFormat 54 | }; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/JsonContent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Net.Http.Headers; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class JsonContent : StringContent 8 | { 9 | public JsonContent(Object content) 10 | : base(JSON.Generate(content)) 11 | { 12 | Headers.ContentType = new MediaTypeHeaderValue("application/json"); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/MqRestClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.IO; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Net.Http.Headers; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | using Common.Logging; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace IronSharp.Core 14 | { 15 | public class MqRestClient: RestClient 16 | { 17 | private ITokenContainer tokenContainer; 18 | 19 | public MqRestClient(ITokenContainer tokenContainer) 20 | { 21 | this.tokenContainer = tokenContainer; 22 | } 23 | 24 | public RestResponse GetKeystone(KeystoneClientConfig config) where T : class 25 | { 26 | Keystone keystone = new Keystone(config.Tenant, config.Username, config.Password); 27 | HttpClient client = new HttpClient(); 28 | HttpContent contentPost = new StringContent(JSON.Generate(keystone), Encoding.UTF8, "application/json"); 29 | String uri = config.Server.TrimEnd('/') + "/tokens"; 30 | HttpResponseMessage response = client.PostAsync(uri, contentPost).Result; 31 | return new RestResponse(response); 32 | } 33 | 34 | public override void SetOauthHeaderIfRequired(IronClientConfig config, IRestClientRequest request, HttpRequestHeaders headers) 35 | { 36 | if (request.AuthTokenLocation == AuthTokenLocation.Header) 37 | { 38 | String token = tokenContainer.getToken(); 39 | headers.Authorization = new AuthenticationHeaderValue("OAuth", token); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("IronSharp.Core")] 5 | [assembly: AssemblyProduct("IronSharp.Core")] 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: Guid("4baa8d66-1945-4d1f-8f11-a5cb5dfd5150")] 9 | 10 | [assembly: AssemblyDescription("Core configuration and other common features for IronSharp. Iron.io is a cloud application services provider that gives you immediate access to high-scale message queues, async processing, and caching.")] -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/HttpRequestMessageBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Net.Http.Headers; 4 | using IronSharp.Core.Abstract; 5 | 6 | namespace IronSharp.Core.Types 7 | { 8 | internal class HttpRequestMessageBuilder 9 | { 10 | public IronClientConfig Config { get; set; } 11 | public IRestClientRequest Request { get; set; } 12 | public Object Payload { get; set; } 13 | public IRequestHelpersContainer RequestHelpersContainer { get; set; } 14 | 15 | public HttpRequestMessageBuilder(IronClientConfig config, IRequestHelpersContainer requestHelpersContainer, IRestClientRequest request) 16 | { 17 | Config = config; 18 | RequestHelpersContainer = requestHelpersContainer; 19 | Request = request; 20 | } 21 | 22 | public HttpRequestMessage Build() 23 | { 24 | RequestHelpersContainer.SetOathQueryParameterIfRequired(Request, Config.Token); 25 | var httpRequest = new HttpRequestMessage 26 | { 27 | Content = Payload != null ? new JsonContent(Payload) : Request.Content, 28 | RequestUri = RequestHelpersContainer.BuildUri(Config, Request.EndPoint, Request.Query), 29 | Method = Request.Method 30 | }; 31 | 32 | HttpRequestHeaders headers = httpRequest.Headers; 33 | RequestHelpersContainer.SetOauthHeaderIfRequired(Config, Request, headers); 34 | headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); 35 | headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); 36 | headers.Accept.Add(new MediaTypeWithQualityHeaderValue(Request.Accept)); 37 | 38 | return httpRequest; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/IronTokenContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace IronSharp.Core 8 | { 9 | public class IronTokenContainer: ITokenContainer 10 | { 11 | private String token; 12 | 13 | public IronTokenContainer(String token) 14 | { 15 | this.token = token; 16 | } 17 | 18 | public String getToken() 19 | { 20 | return token; 21 | } 22 | 23 | public void setToken(String token) 24 | { 25 | this.token = token; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/Keystone.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Newtonsoft.Json; 7 | 8 | namespace IronSharp.Core 9 | { 10 | public class Keystone 11 | { 12 | [JsonProperty("auth")] 13 | public Auth Auth { get; set; } 14 | 15 | public Keystone(String tenant, String username, String password) 16 | { 17 | Credentials credentials = new Credentials(username, password); 18 | Auth = new Auth(tenant, credentials); 19 | } 20 | } 21 | 22 | public class Auth 23 | { 24 | [JsonProperty("tenantName")] 25 | public String Tenant { get; set; } 26 | [JsonProperty("passwordCredentials")] 27 | public Credentials Credentials { get; set; } 28 | 29 | public Auth(String tenant, Credentials credentials) 30 | { 31 | Tenant = tenant; 32 | Credentials = credentials; 33 | } 34 | } 35 | 36 | public class Credentials 37 | { 38 | [JsonProperty("username")] 39 | public String Username { get; set; } 40 | [JsonProperty("password")] 41 | public String Password { get; set; } 42 | 43 | public Credentials(String username, String password) 44 | { 45 | Username = username; 46 | Password = password; 47 | } 48 | } 49 | 50 | public class KeystoneResponse 51 | { 52 | [JsonProperty("access")] 53 | public KeystoneAccess Access { get; set; } 54 | } 55 | 56 | public class KeystoneAccess 57 | { 58 | [JsonProperty("token")] 59 | public KestoneToken Token { get; set; } 60 | } 61 | public class KestoneToken 62 | { 63 | [JsonProperty("issued_at")] 64 | public String IssuedAt { get; set; } 65 | 66 | [JsonProperty("expires")] 67 | public String Expires { get; set; } 68 | 69 | [JsonProperty("id")] 70 | public String Id { get; set; } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/KeystoneContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Globalization; 7 | 8 | namespace IronSharp.Core 9 | { 10 | public class KeystoneContainer: ITokenContainer 11 | { 12 | private String token; 13 | private KeystoneClientConfig config; 14 | private DateTime localExpiresAt; 15 | 16 | public KeystoneContainer(KeystoneClientConfig config) 17 | { 18 | this.config = config; 19 | } 20 | 21 | public String getToken() 22 | { 23 | DateTime today = System.DateTime.Now; 24 | if (this.token == null || this.localExpiresAt.CompareTo(today) < 0) 25 | { 26 | MqRestClient restClient = new MqRestClient(this); 27 | KeystoneResponse response = restClient.GetKeystone(this.config); 28 | DateTime issuedAt = DateTime.Parse(response.Access.Token.IssuedAt, null, DateTimeStyles.RoundtripKind); 29 | DateTime expires = DateTime.Parse(response.Access.Token.Expires, null, DateTimeStyles.RoundtripKind); 30 | TimeSpan timespan = expires.Subtract(issuedAt); 31 | this.localExpiresAt = today.Add(timespan); 32 | this.token = response.Access.Token.Id; 33 | } 34 | return this.token; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/PagingFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class PagingFilter : IPagingFilter 8 | { 9 | public PagingFilter() 10 | { 11 | } 12 | 13 | public PagingFilter(int? page = null, int? perPage = null) 14 | { 15 | Page = page.GetValueOrDefault(); 16 | PerPage = perPage.GetValueOrDefault(); 17 | } 18 | 19 | public PagingFilter(IPagingFilter filter) 20 | { 21 | if (filter == null) 22 | { 23 | return; 24 | } 25 | Page = filter.Page; 26 | PerPage = filter.PerPage; 27 | } 28 | 29 | [JsonProperty("page")] 30 | public virtual int Page { get; set; } 31 | 32 | [JsonProperty("per_page")] 33 | public int PerPage { get; set; } 34 | 35 | public static implicit operator NameValueCollection(PagingFilter filter) 36 | { 37 | var collection = new NameValueCollection(); 38 | 39 | if (filter != null && filter.Page > 0) 40 | { 41 | collection.Add("page", Convert.ToString(filter.Page)); 42 | } 43 | 44 | if (filter != null && filter.PerPage > 0) 45 | { 46 | collection.Add("per_page", Convert.ToString(filter.PerPage)); 47 | } 48 | 49 | return collection; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/ResponseMsg.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.Core 4 | { 5 | public class ResponseMsg : IMsg 6 | { 7 | [JsonProperty("msg")] 8 | public string Message { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/RestClientRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Net.Http; 3 | 4 | namespace IronSharp.Core 5 | { 6 | public class RestClientRequest : IRestClientRequest 7 | { 8 | public RestClientRequest() 9 | { 10 | Accept = "appliction/json"; 11 | Method = HttpMethod.Get; 12 | AuthTokenLocation = AuthTokenLocation.Header; 13 | } 14 | 15 | public string Accept { get; set; } 16 | 17 | public AuthTokenLocation AuthTokenLocation { get; set; } 18 | 19 | public HttpContent Content { get; set; } 20 | 21 | public string EndPoint { get; set; } 22 | 23 | public HttpMethod Method { get; set; } 24 | 25 | public NameValueCollection Query { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/Types/RestResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class RestResponse : IMsg where T : class 8 | { 9 | private T _result; 10 | 11 | public RestResponse(HttpResponseMessage responseMessage) 12 | { 13 | ResponseMessage = responseMessage; 14 | } 15 | 16 | public HttpContent Content 17 | { 18 | get { return ResponseMessage.Content; } 19 | } 20 | 21 | public HttpResponseMessage ResponseMessage { get; set; } 22 | 23 | public T Result 24 | { 25 | get 26 | { 27 | SetResult(); 28 | return _result; 29 | } 30 | } 31 | 32 | string IMsg.Message 33 | { 34 | get 35 | { 36 | ResponseMsg msg = Msg(); 37 | return msg == null ? null : msg.Message; 38 | } 39 | } 40 | 41 | public static implicit operator bool(RestResponse value) 42 | { 43 | return value.ResponseMessage != null && value.ResponseMessage.IsSuccessStatusCode; 44 | } 45 | 46 | public static implicit operator T(RestResponse value) 47 | { 48 | return value.Result; 49 | } 50 | 51 | public bool CanReadResult() 52 | { 53 | try 54 | { 55 | SetResult(); 56 | return true; 57 | } 58 | catch 59 | { 60 | return false; 61 | } 62 | } 63 | 64 | public ResponseMsg Msg() 65 | { 66 | return Content.ReadAsAsync().Result; 67 | } 68 | 69 | public Task ReadResultAsync() 70 | { 71 | return Content.ReadAsAsync(); 72 | } 73 | 74 | private void SetResult() 75 | { 76 | LazyInitializer.EnsureInitialized(ref _result, () => ReadResultAsync().Result); 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /src/IronSharp.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/ExtensionsForISharpConfig.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | 3 | namespace IronSharp.Extras.ProtoBufSerializers 4 | { 5 | public static class ExtensionsForISharpConfig 6 | { 7 | public static void UseProtoBufSerializer(this IIronSharpConfig config, ProtoBufConfig protoBufConfig = null) 8 | { 9 | ProtoBufValueSerializer serializer = null; 10 | 11 | if (protoBufConfig != null) 12 | { 13 | ModelSerializerContext.Model = protoBufConfig.TypeModel; 14 | 15 | if (protoBufConfig.ConvertToBytes != null && protoBufConfig.ConvertToString != null) 16 | { 17 | serializer = new ProtoBufValueSerializer(protoBufConfig.ConvertToBytes, protoBufConfig.ConvertToString); 18 | } 19 | } 20 | config.SharpConfig.ValueSerializer = serializer ?? new ProtoBufValueSerializer(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/IronSharp.Extras.ProtoBufSerializers.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {40DF09EE-FD18-4BCA-9A61-898044477F7E} 8 | Library 9 | Properties 10 | IronSharp.Extras.ProtoBufSerializers 11 | IronSharp.Extras.ProtoBufSerializers 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | {1a6cc922-40a5-440a-868d-757fcdb08622} 54 | IronSharp.Core 55 | 56 | 57 | 58 | 59 | 60 | 61 | 68 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/ModelSerializerContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading; 4 | using ProtoBuf.Meta; 5 | 6 | namespace IronSharp.Extras.ProtoBufSerializers 7 | { 8 | public static class ModelSerializerContext 9 | { 10 | private static RuntimeTypeModel _model; 11 | 12 | public static RuntimeTypeModel Model 13 | { 14 | get { return LazyInitializer.EnsureInitialized(ref _model, TypeModel.Create); } 15 | set { _model = value; } 16 | } 17 | 18 | public static object DeserializeFromStream(Type type, Stream source) 19 | { 20 | return Model.Deserialize(source, null, type); 21 | } 22 | 23 | /// 24 | /// Deserializers the protobuf byte stream into an instance of the specified type of . 25 | /// 26 | public static T FromProtoBuf(this byte[] bytes) 27 | { 28 | return (T)bytes.FromProtoBuf(typeof(T)); 29 | } 30 | 31 | /// 32 | /// Deserializers the protobuf byte stream into an instance of the specified . 33 | /// 34 | public static object FromProtoBuf(this byte[] bytes, Type type) 35 | { 36 | using (var ms = new MemoryStream(bytes)) 37 | { 38 | return DeserializeFromStream(type, ms); 39 | } 40 | } 41 | 42 | public static void SerializeToStream(object value, Stream destination) 43 | { 44 | Model.Serialize(destination, value); 45 | } 46 | 47 | /// 48 | /// Serializes the object graph into a protobuf type stream 49 | /// 50 | public static byte[] ToProtoBuf(this T value) 51 | { 52 | using (var ms = new MemoryStream()) 53 | { 54 | SerializeToStream(value, ms); 55 | return ms.ToArray(); 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IronSharp.Extras.ProtoBufSerializers")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IronSharp.Extras.ProtoBufSerializers")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2dbb097c-5305-4d61-9bdf-41191051583f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/ProtoBufConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ProtoBuf.Meta; 3 | 4 | namespace IronSharp.Extras.ProtoBufSerializers 5 | { 6 | public class ProtoBufConfig 7 | { 8 | public Func ConvertToBytes { get; set; } 9 | 10 | public Func ConvertToString { get; set; } 11 | 12 | public RuntimeTypeModel TypeModel { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/ProtoBufValueSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | 4 | namespace IronSharp.Extras.ProtoBufSerializers 5 | { 6 | public class ProtoBufValueSerializer : IValueSerializer 7 | { 8 | private readonly Func _convertToBytes; 9 | 10 | private readonly Func _convertToString; 11 | 12 | /// 13 | /// Creates a new instance of the ProtoBufValueSerializer using Base64 string conversions 14 | /// 15 | public ProtoBufValueSerializer() 16 | : this(Convert.FromBase64String, Convert.ToBase64String) 17 | { 18 | } 19 | 20 | /// 21 | /// Creates a new instance of the ProtoBufValueSerializer using custom string conversions 22 | /// 23 | public ProtoBufValueSerializer(Func convertToBytes, Func convertToString) 24 | { 25 | _convertToBytes = convertToBytes; 26 | _convertToString = convertToString; 27 | } 28 | 29 | public string Generate(object value) 30 | { 31 | return _convertToString(value.ToProtoBuf()); 32 | } 33 | 34 | public object Parse(string value, Type type) 35 | { 36 | return _convertToBytes(value).FromProtoBuf(type); 37 | } 38 | 39 | public T Parse(string value) 40 | { 41 | return _convertToBytes(value).FromProtoBuf(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ProtoBufSerializers/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/ExtensionsForISharpConfig.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | 3 | namespace IronSharp.Extras.ServiceStackSerializers 4 | { 5 | public static class ExtensionsForISharpConfig 6 | { 7 | public static void UseServiceStackJsonSerializer(this IIronSharpConfig config) 8 | { 9 | config.SharpConfig.ValueSerializer = new ServiceStackJsonSerializer(); 10 | } 11 | 12 | public static void UseServiceStackTypeSerializer(this IIronSharpConfig config) 13 | { 14 | config.SharpConfig.ValueSerializer = new ServiceStackTypeSerializer(); 15 | } 16 | 17 | public static void UseServiceStackXmlSerializer(this IIronSharpConfig config) 18 | { 19 | config.SharpConfig.ValueSerializer = new ServiceStackXmlSerializer(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/IronSharp.Extras.ServiceStackSerializers.2013.10.55.845.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iron-io/iron_dotnet/b5dfcaeefa2f549413c9136b2bc39ef8e1f331af/src/IronSharp.Extras.ServiceStackSerializers/IronSharp.Extras.ServiceStackSerializers.2013.10.55.845.nupkg -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/IronSharp.Extras.ServiceStackSerializers.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823} 8 | Library 9 | Properties 10 | IronSharp.Extras.ServiceStackSerializers 11 | IronSharp.Extras.ServiceStackSerializers 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\ServiceStack.Text.3.9.67\lib\net35\ServiceStack.Text.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {1a6cc922-40a5-440a-868d-757fcdb08622} 52 | IronSharp.Core 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 67 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/IronSharp.Extras.ServiceStackSerializers.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | $version$ 6 | $title$ 7 | $author$ 8 | $author$ 9 | http://grcodemonkey.github.io/iron_sharp/ 10 | http://c577730.r99.cf2.rackcdn.com/images/FeSharp_Icon_128.png 11 | false 12 | $description$ 13 | 14 | iron.io,serializers,jsv,servicestack 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("IronSharp.Extras.ServiceStackSerializers")] 5 | [assembly: AssemblyProduct("IronSharp.Extras.ServiceStackSerializers")] 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: Guid("b1013b90-fb5a-422a-8d50-83e18e78f00d")] 9 | 10 | [assembly: AssemblyDescription("Provides additional Value Serializers for IronSharp using ServiceStack.Text")] -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/ServiceStackJsonSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using ServiceStack.Text; 4 | 5 | namespace IronSharp.Extras.ServiceStackSerializers 6 | { 7 | public class ServiceStackJsonSerializer : IValueSerializer 8 | { 9 | public string Generate(object value) 10 | { 11 | return JsonSerializer.SerializeToString(value); 12 | } 13 | 14 | public object Parse(string value, Type type) 15 | { 16 | return JsonSerializer.DeserializeFromString(value, type); 17 | } 18 | 19 | public T Parse(string value) 20 | { 21 | return JsonSerializer.DeserializeFromString(value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/ServiceStackTypeSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using ServiceStack.Text; 4 | 5 | namespace IronSharp.Extras.ServiceStackSerializers 6 | { 7 | public class ServiceStackTypeSerializer : IValueSerializer 8 | { 9 | public string Generate(object value) 10 | { 11 | return TypeSerializer.SerializeToString(value); 12 | } 13 | 14 | public object Parse(string value, Type type) 15 | { 16 | return TypeSerializer.DeserializeFromString(value, type); 17 | } 18 | 19 | public T Parse(string value) 20 | { 21 | return TypeSerializer.DeserializeFromString(value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/ServiceStackXmlSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using ServiceStack.Text; 4 | 5 | namespace IronSharp.Extras.ServiceStackSerializers 6 | { 7 | public class ServiceStackXmlSerializer : IValueSerializer 8 | { 9 | public string Generate(object value) 10 | { 11 | return XmlSerializer.SerializeToString(value); 12 | } 13 | 14 | public object Parse(string value, Type type) 15 | { 16 | return XmlSerializer.DeserializeFromString(value, type); 17 | } 18 | 19 | public T Parse(string value) 20 | { 21 | return XmlSerializer.DeserializeFromString(value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/IronSharp.Extras.ServiceStackSerializers/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/IronSharp.IronCache/CacheClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Contracts; 3 | using IronSharp.Core; 4 | 5 | namespace IronSharp.IronCache 6 | { 7 | public class CacheClient 8 | { 9 | private readonly string _cacheName; 10 | private readonly IronCacheRestClient _client; 11 | private readonly RestClient _restClient = new RestClient(); 12 | 13 | public CacheClient(IronCacheRestClient client, string cacheName) 14 | { 15 | if (client == null) throw new ArgumentNullException("client"); 16 | if (string.IsNullOrEmpty(cacheName)) throw new ArgumentNullException("cacheName"); 17 | Contract.EndContractBlock(); 18 | 19 | _client = client; 20 | _cacheName = cacheName; 21 | } 22 | 23 | public IValueSerializer ValueSerializer 24 | { 25 | get { return _client.Config.SharpConfig.ValueSerializer; } 26 | } 27 | 28 | /// 29 | /// Delete all items in a cache. This cannot be undone. 30 | /// 31 | /// 32 | /// http://dev.iron.io/cache/reference/api/#clear_a_cache 33 | /// 34 | public bool Clear() 35 | { 36 | return _restClient.Post(_client.Config, string.Format("{0}/clear", CacheNameEndPoint())).HasExpectedMessage("Deleted."); 37 | } 38 | 39 | public bool Delete(string key) 40 | { 41 | return _restClient.Delete(_client.Config, CacheItemEndPoint(key)).HasExpectedMessage("Deleted."); 42 | } 43 | 44 | /// 45 | /// This call retrieves an item from the cache. The item will not be deleted. 46 | /// 47 | /// The key the item is stored under in the cache. 48 | /// 49 | /// http://dev.iron.io/cache/reference/api/#get_an_item_from_a_cache 50 | /// 51 | public CacheItem Get(string key) 52 | { 53 | RestResponse response = _restClient.Get(_client.Config, CacheItemEndPoint(key)); 54 | 55 | if (response.CanReadResult()) 56 | { 57 | response.Result.Client = this; 58 | } 59 | 60 | return response; 61 | } 62 | 63 | public T Get(string key) 64 | { 65 | CacheItem item = Get(key); 66 | 67 | if (IsDefaultValue(item)) 68 | { 69 | return default(T); 70 | } 71 | 72 | return item.ReadValueAs(); 73 | } 74 | 75 | public T GetOrAdd(string key, Func valueFactory, CacheItemOptions options = null) 76 | { 77 | var item = Get(key); 78 | 79 | if (Equals(item, default(T))) 80 | { 81 | item = valueFactory(); 82 | Put(key, item, options); 83 | } 84 | 85 | return item; 86 | } 87 | 88 | public CacheItem GetOrAdd(string key, Func valueFactory) 89 | { 90 | CacheItem item = Get(key); 91 | 92 | if (IsDefaultValue(item)) 93 | { 94 | item = valueFactory(); 95 | Put(key, item); 96 | } 97 | 98 | item.Client = this; 99 | 100 | return item; 101 | } 102 | 103 | /// 104 | /// This call increments the numeric value of an item in the cache. The amount must be a number and attempting to increment non-numeric values results in an error. 105 | /// Negative amounts may be passed to decrement the value. 106 | /// The increment is atomic, so concurrent increments will all be observed. 107 | /// 108 | /// The key of the item to increment 109 | /// The amount to increment the value, as an integer. If negative, the value will be decremented. 110 | /// 111 | /// http://dev.iron.io/cache/reference/api/#increment_an_items_value 112 | /// 113 | public CacheIncrementResult Increment(string key, int amount = 1) 114 | { 115 | return _restClient.Post(_client.Config, string.Format("{0}/increment", CacheItemEndPoint(key)), new {amount}); 116 | } 117 | 118 | /// 119 | /// This call gets general information about a cache. 120 | /// 121 | /// 122 | /// http://dev.iron.io/cache/reference/api/#get_info_about_a_cache 123 | /// 124 | public CacheInfo Info() 125 | { 126 | return _restClient.Get(_client.Config, CacheNameEndPoint()); 127 | } 128 | 129 | public bool Put(string key, object value, CacheItemOptions options = null) 130 | { 131 | return Put(key, ValueSerializer.Generate(value), options); 132 | } 133 | 134 | public bool Put(string key, int value, CacheItemOptions options = null) 135 | { 136 | return Put(key, new CacheItem(value, options)); 137 | } 138 | 139 | public bool Put(string key, string value, CacheItemOptions options = null) 140 | { 141 | return Put(key, new CacheItem(value, options)); 142 | } 143 | 144 | /// 145 | /// This call puts an item into a cache. 146 | /// 147 | /// The key to store the item under in the cache. 148 | /// The item’s data 149 | /// 150 | /// http://dev.iron.io/cache/reference/api/#put_an_item_into_a_cache 151 | /// 152 | public bool Put(string key, CacheItem item) 153 | { 154 | return _restClient.Put(_client.Config, CacheItemEndPoint(key), item).HasExpectedMessage("Stored."); 155 | } 156 | 157 | private static bool IsDefaultValue(CacheItem item) 158 | { 159 | return item == null || item.Value == null || string.IsNullOrEmpty(Convert.ToString(item.Value)); 160 | } 161 | 162 | private string CacheItemEndPoint(string key) 163 | { 164 | return string.Format("{0}/items/{1}", CacheNameEndPoint(), key); 165 | } 166 | 167 | private string CacheNameEndPoint() 168 | { 169 | return string.Format("{0}/{1}", _client.EndPoint, _cacheName); 170 | } 171 | } 172 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/CacheIncrementResult.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronCache 5 | { 6 | public class CacheIncrementResult : IMsg, IInspectable 7 | { 8 | public bool Success 9 | { 10 | get { return this.HasExpectedMessage("Added"); } 11 | } 12 | 13 | [JsonProperty("value", DefaultValueHandling = DefaultValueHandling.Ignore)] 14 | public int? Value { get; set; } 15 | 16 | [JsonProperty("msg")] 17 | public string Message { get; set; } 18 | 19 | public static implicit operator bool(CacheIncrementResult value) 20 | { 21 | return value != null && value.Success; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/CacheInfo.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.IronCache 4 | { 5 | public class CacheInfo 6 | { 7 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 8 | public string Id { get; set; } 9 | 10 | [JsonProperty("project_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 11 | public string ProjectId { get; set; } 12 | 13 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 14 | public string Name { get; set; } 15 | 16 | [JsonProperty("size", DefaultValueHandling = DefaultValueHandling.Ignore)] 17 | public int? Size { get; set; } 18 | 19 | [JsonProperty("data_size", DefaultValueHandling = DefaultValueHandling.Ignore)] 20 | public int? DataSize { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/CacheItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronCache 5 | { 6 | public class CacheItem : CacheItemOptions 7 | { 8 | public CacheItem() 9 | { 10 | } 11 | 12 | public CacheItem(int value, CacheItemOptions options = null) 13 | { 14 | Value = value; 15 | 16 | if (options == null) return; 17 | 18 | ExpiresIn = options.ExpiresIn; 19 | Replace = options.Replace; 20 | Add = options.Add; 21 | Cas = options.Cas; 22 | } 23 | 24 | public CacheItem(string value, CacheItemOptions options = null) 25 | { 26 | Value = value; 27 | 28 | if (options == null) return; 29 | 30 | ExpiresIn = options.ExpiresIn; 31 | Replace = options.Replace; 32 | Add = options.Add; 33 | Cas = options.Cas; 34 | } 35 | 36 | [JsonProperty("value")] 37 | public object Value { get; set; } 38 | 39 | [JsonProperty("cache", DefaultValueHandling = DefaultValueHandling.Ignore)] 40 | public string Cache { get; set; } 41 | 42 | [JsonProperty("key", DefaultValueHandling = DefaultValueHandling.Ignore)] 43 | public string Key { get; set; } 44 | 45 | [JsonIgnore] 46 | internal CacheClient Client { get; set; } 47 | 48 | public T ReadValueAs() 49 | { 50 | if (Value is T) 51 | { 52 | return (T) Value; 53 | } 54 | 55 | return Client.ValueSerializer.Parse(Convert.ToString(Value)); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/CacheItemOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronCache 6 | { 7 | public class CacheItemOptions : IInspectable 8 | { 9 | public CacheItemOptions() 10 | { 11 | } 12 | 13 | public CacheItemOptions(TimeSpan expiresIn) 14 | { 15 | ExpiresIn = expiresIn.Seconds; 16 | } 17 | 18 | /// 19 | /// How long in seconds to keep the item in the cache before it is deleted. By default, items do not expire. Maximum is 2,592,000 seconds (30 days). 20 | /// 21 | [JsonProperty("expires_in", DefaultValueHandling = DefaultValueHandling.Ignore)] 22 | public int? ExpiresIn { get; set; } 23 | 24 | /// 25 | /// If set to true, only set the item if the item is already in the cache. If the item is not in the cache, do not create it. 26 | /// 27 | [JsonProperty("replace", DefaultValueHandling = DefaultValueHandling.Ignore)] 28 | public bool? Replace { get; set; } 29 | 30 | /// 31 | /// If set to true, only set the item if the item is not already in the cache. If the item is in the cache, do not overwrite it. 32 | /// 33 | [JsonProperty("Add", DefaultValueHandling = DefaultValueHandling.Ignore)] 34 | public bool? Add { get; set; } 35 | 36 | /// 37 | /// If set, the new item will only be placed in the cache if there is an existing item with a matching key and cas value. An item’s cas value is automatically generated and is 38 | /// included when the item is retrieved. 39 | /// 40 | [JsonProperty("cas", DefaultValueHandling = DefaultValueHandling.Ignore)] 41 | public string Cas { get; set; } 42 | } 43 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/Client.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | 3 | namespace IronSharp.IronCache 4 | { 5 | public static class Client 6 | { 7 | /// 8 | /// Creates a new client using the environmental configuration JSON heirarchy. 9 | /// 10 | public static IronCacheRestClient @New() 11 | { 12 | return New(null); 13 | } 14 | 15 | /// 16 | /// Creates a new client using the specified values 17 | /// 18 | public static IronCacheRestClient @New(string projectId, string token, string host = null) 19 | { 20 | return New(new IronClientConfig 21 | { 22 | Host = host, 23 | ProjectId = projectId, 24 | Token = token 25 | }); 26 | } 27 | 28 | /// 29 | /// Loads the config from a specific enivonment key 30 | /// 31 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 32 | public static IronCacheRestClient @New(string env) 33 | { 34 | return New(null, env); 35 | } 36 | 37 | /// 38 | /// Creates a new client using the specified configuration and optional paramter to specificy which enivonment to use when loading default values; 39 | /// 40 | /// The explicitly specified configuration values 41 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 42 | public static IronCacheRestClient @New(IronClientConfig config, string env = null) 43 | { 44 | IronClientConfig hierarchyConfig = IronDotConfigManager.Load(IronProduct.IronCache, config, env); 45 | 46 | return new IronCacheRestClient(hierarchyConfig); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/IronCacheCloudHosts.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronCache 2 | { 3 | /// 4 | /// http://dev.iron.io/mq/reference/clouds/ 5 | /// 6 | public static class IronCacheCloudHosts 7 | { 8 | public const string DEFAULT = AWS_US_EAST_HOST; 9 | 10 | /// 11 | /// Default 12 | /// 13 | public const string AWS_US_EAST_HOST = "cache-aws-us-east-1.iron.io"; 14 | } 15 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/IronCacheRestClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | 6 | namespace IronSharp.IronCache 7 | { 8 | public class IronCacheRestClient 9 | { 10 | private readonly IronClientConfig _config; 11 | private readonly RestClient _restClient = new RestClient(); 12 | 13 | internal IronCacheRestClient(IronClientConfig config) 14 | { 15 | _config = LazyInitializer.EnsureInitialized(ref config); 16 | 17 | if (string.IsNullOrEmpty(Config.Host)) 18 | { 19 | Config.Host = IronCacheCloudHosts.DEFAULT; 20 | } 21 | 22 | if (config.ApiVersion == default (int)) 23 | { 24 | config.ApiVersion = 1; 25 | } 26 | } 27 | 28 | public IronClientConfig Config 29 | { 30 | get { return _config; } 31 | } 32 | 33 | public string EndPoint 34 | { 35 | get { return "/projects/{Project ID}/caches"; } 36 | } 37 | 38 | 39 | public CacheClient Cache(string cacheName) 40 | { 41 | return new CacheClient(this, cacheName); 42 | } 43 | 44 | /// 45 | /// Delete a cache and all items in it. 46 | /// 47 | /// The name of the cache 48 | /// 49 | /// http://dev.iron.io/cache/reference/api/#delete_a_cache 50 | /// 51 | public bool Delete(string cacheName) 52 | { 53 | return _restClient.Delete(_config, string.Format("{0}/{1}", EndPoint, cacheName)).HasExpectedMessage("Deleted."); 54 | } 55 | 56 | /// 57 | /// Get a list of all caches in a project. 100 caches are listed at a time. To see more, use the page parameter. 58 | /// 59 | /// The current page 60 | /// 61 | /// http://dev.iron.io/cache/reference/api/#list_caches 62 | /// 63 | public CacheInfo[] List(int? page) 64 | { 65 | var query = new NameValueCollection(); 66 | 67 | if (page.HasValue) 68 | { 69 | query.Add("page", Convert.ToString(page)); 70 | } 71 | 72 | return _restClient.Get(_config, EndPoint, query); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/IronSharp.IronCache/IronSharp.IronCache.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2603E861-09AB-482E-BF28-41D8B0B1B20B} 8 | Library 9 | Properties 10 | IronSharp.IronCache 11 | IronSharp.IronCache 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | bin\Publish\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | 43 | ..\packages\Newtonsoft.Json.5.0.7\lib\net45\Newtonsoft.Json.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | {1a6cc922-40a5-440a-868d-757fcdb08622} 65 | IronSharp.Core 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 80 | -------------------------------------------------------------------------------- /src/IronSharp.IronCache/IronSharp.IronCache.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iron.IronCache 5 | 1.0.2 6 | IronCache 7 | Jeremy Bell 8 | Iron.io 9 | https://raw.github.com/iron-io/iron_dotnet/master/LICENSE 10 | https://github.com/iron-io/iron_dotnet 11 | https://raw.github.com/iron-io/iron_dotnet/master/images/net-iron-c.png 12 | false 13 | IronCache is an elastic and durable key/value store that’s perfect for applications 14 | that need to share state, pass data, and coordinate activity between processes and 15 | devices. Reduce database load by making use of a high-performance middle tier for 16 | asynchronous processing and communication. 17 | 18 | iron.io,cache 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/IronSharp.IronCache/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("IronSharp.IronCache")] 5 | [assembly: AssemblyProduct("IronSharp.IronCache")] 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: Guid("1b53e643-f7da-4edc-b610-636a79a03d6b")] 9 | 10 | [assembly: AssemblyDescription("Key/Value Data Cache. IronCache is an elastic cache and key/value data store designed for sharing state, passing data, and coordinating activity between processes and devices.")] -------------------------------------------------------------------------------- /src/IronSharp.IronCache/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/Alert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace IronSharp.IronMQ 7 | { 8 | public class Alert 9 | { 10 | public Alert() : this(AlertType.Fixed, AlertDirection.Asc, null, null) 11 | { 12 | } 13 | 14 | public Alert(AlertType type, AlertDirection direction, int? trigger, string queue) 15 | { 16 | Type = type; 17 | Direction = direction; 18 | Trigger = trigger; 19 | Queue = queue; 20 | } 21 | 22 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 23 | public string Id { get; set; } 24 | 25 | [JsonProperty("snooze", DefaultValueHandling = DefaultValueHandling.Ignore)] 26 | public int? Snooze { get; set; } 27 | 28 | [JsonProperty("queue", DefaultValueHandling = DefaultValueHandling.Ignore)] 29 | public string Queue { get; set; } 30 | 31 | [JsonProperty("trigger", DefaultValueHandling = DefaultValueHandling.Ignore)] 32 | public int? Trigger { get; set; } 33 | 34 | [JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Include)] 35 | public AlertType Type { get; set; } 36 | 37 | [JsonProperty("direction", DefaultValueHandling = DefaultValueHandling.Include)] 38 | public AlertDirection Direction { get; set; } 39 | 40 | [JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)] 41 | public string Status { get; set; } 42 | 43 | [JsonProperty("status_code", DefaultValueHandling = DefaultValueHandling.Ignore)] 44 | protected int? Code { get; set; } 45 | 46 | [JsonIgnore] 47 | public HttpStatusCode StatusCode 48 | { 49 | get { return (HttpStatusCode) Code.GetValueOrDefault(200); } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/AlertCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class AlertCollection : IInspectable 10 | { 11 | [JsonProperty("alerts", DefaultValueHandling = DefaultValueHandling.Ignore)] private List _alerts; 12 | 13 | public AlertCollection() 14 | { 15 | } 16 | 17 | public AlertCollection(Alert alert) : this(new[] {alert}) 18 | { 19 | } 20 | 21 | public AlertCollection(IEnumerable alerts) 22 | { 23 | foreach (Alert alert in alerts) 24 | { 25 | Alerts.Add(alert); 26 | } 27 | } 28 | 29 | [JsonIgnore] 30 | public List Alerts 31 | { 32 | get { return LazyInitializer.EnsureInitialized(ref _alerts); } 33 | set { _alerts = value; } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/AlertDirection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | using Newtonsoft.Json.Converters; 9 | 10 | namespace IronSharp.IronMQ 11 | { 12 | [JsonConverter(typeof(StringEnumConverter))] 13 | public enum AlertDirection 14 | { 15 | [EnumMember(Value = "asc")] 16 | Asc, 17 | [EnumMember(Value = "desc")] 18 | Desc 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/AlertType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.Serialization; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | using Newtonsoft.Json.Converters; 9 | 10 | namespace IronSharp.IronMQ 11 | { 12 | [JsonConverter(typeof(StringEnumConverter))] 13 | public enum AlertType 14 | { 15 | [EnumMember(Value = "fixed")] 16 | Fixed, 17 | [EnumMember(Value = "progressive")] 18 | Progressive 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/Client.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | 3 | namespace IronSharp.IronMQ 4 | { 5 | public static class Client 6 | { 7 | /// 8 | /// Creates a new client using the environmental configuration JSON heirarchy. 9 | /// 10 | public static IronMqRestClient @New() 11 | { 12 | return New(null); 13 | } 14 | 15 | /// 16 | /// Creates a new client using the specified values 17 | /// 18 | public static IronMqRestClient @New(string projectId, string token, string host = null) 19 | { 20 | return New(new IronClientConfig 21 | { 22 | Host = host, 23 | ProjectId = projectId, 24 | Token = token 25 | }); 26 | } 27 | 28 | /// 29 | /// Loads the config from a specific enivonment key 30 | /// 31 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 32 | public static IronMqRestClient @New(string env) 33 | { 34 | return New(null, env); 35 | } 36 | 37 | /// 38 | /// Creates a new client using the specified configuration and optional paramter to specificy which enivonment to use when loading default values; 39 | /// 40 | /// The explicitly specified configuration values 41 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 42 | public static IronMqRestClient @New(IronClientConfig config, string env = null) 43 | { 44 | IronClientConfig hierarchyConfig = IronDotConfigManager.Load(IronProduct.IronMQ, config, env); 45 | 46 | return new IronMqRestClient(hierarchyConfig); 47 | } 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/IronMqCloudHosts.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronMQ 2 | { 3 | /// 4 | /// http://dev.iron.io/mq/reference/clouds/ 5 | /// 6 | public static class IronMqCloudHosts 7 | { 8 | public const string DEFAULT = AWS_US_EAST_HOST; 9 | 10 | /// 11 | /// Default 12 | /// 13 | public const string AWS_US_EAST_HOST = "mq-aws-us-east-1-1.iron.io"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/IronMqRestClient.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using IronSharp.Core; 4 | using IronSharp.Core.Attributes; 5 | using System; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class IronMqRestClient 10 | { 11 | private readonly IronClientConfig _config; 12 | private MqRestClient _restClient; 13 | public ITokenContainer TokenContainer { get; set; } 14 | 15 | internal IronMqRestClient(IronClientConfig config) 16 | { 17 | _config = LazyInitializer.EnsureInitialized(ref config); 18 | 19 | if (_config.Keystone != null) 20 | { 21 | if (_config.KeystoneKeysExist()) 22 | { 23 | TokenContainer = new KeystoneContainer(_config.Keystone); 24 | } 25 | else 26 | { 27 | throw new IronSharpException("Keystone keys missing"); 28 | } 29 | } 30 | else 31 | { 32 | TokenContainer = new IronTokenContainer(_config.Token); 33 | } 34 | 35 | _restClient = new MqRestClient(TokenContainer); 36 | 37 | if (string.IsNullOrEmpty(Config.Host)) 38 | { 39 | Config.Host = IronMqCloudHosts.DEFAULT; 40 | } 41 | 42 | if (config.ApiVersion == default (int)) 43 | { 44 | config.ApiVersion = 3; 45 | } 46 | } 47 | 48 | public IronClientConfig Config 49 | { 50 | get { return _config; } 51 | } 52 | 53 | public string EndPoint 54 | { 55 | get { return "/projects/{Project ID}/queues"; } 56 | } 57 | 58 | public QueueClient Queue() 59 | { 60 | return new QueueClient(this, QueueNameAttribute.GetName()); 61 | } 62 | 63 | public QueueClient Queue(string name) 64 | { 65 | return new QueueClient(this, name); 66 | } 67 | 68 | /// 69 | /// Get a list of all queues in a project. 70 | /// By default, 30 queues are listed at a time. 71 | /// To see more, use the page parameter or the per_page parameter. 72 | /// Up to 100 queues may be listed on a single page. 73 | /// 74 | /// 75 | /// 76 | public IEnumerable Queues(MqPagingFilter filter = null) 77 | { 78 | var queuesInfo = _restClient.Get(_config, EndPoint, filter).Result; 79 | return queuesInfo == null ? null : queuesInfo.Queues; 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/IronSharp.IronMQ.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D891A220-AA6F-4D0C-B012-B25875787BA0} 8 | Library 9 | Properties 10 | IronSharp.IronMQ 11 | IronSharp.IronMQ 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | bin\Publish\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | 43 | ..\packages\Newtonsoft.Json.5.0.7\lib\net45\Newtonsoft.Json.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | {1a6cc922-40a5-440a-868d-757fcdb08622} 85 | IronSharp.Core 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/IronSharp.IronMQ.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iron.IronMQ 5 | 3.0.14 6 | IronMQ 7 | Jeremy Bell 8 | Iron.io 9 | https://raw.github.com/iron-io/iron_dotnet/master/LICENSE 10 | https://github.com/iron-io/iron_dotnet 11 | https://raw.github.com/iron-io/iron_dotnet/master/images/net-iron-mq.png 12 | false 13 | An easy-to-use highly available message queuing service. Built for distributed 14 | cloud applications with critical messaging needs. Provides on-demand message 15 | queuing with HTTPS transport, one-time FIFO delivery, message persistence, 16 | and cloud-optimized performance. 17 | New V3 Version! 18 | iron.io,message queue 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MessageCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronMQ 6 | { 7 | public class MessageCollection 8 | { 9 | [JsonProperty("messages")] private List _messages; 10 | 11 | public MessageCollection() 12 | { 13 | } 14 | 15 | public MessageCollection(QueueMessage message) 16 | { 17 | Messages.Add(message); 18 | } 19 | 20 | public MessageCollection(IEnumerable messages) 21 | { 22 | Messages.AddRange(messages); 23 | } 24 | 25 | public MessageCollection(string message, MessageOptions options = null) 26 | { 27 | Messages.Add(new QueueMessage(message, options)); 28 | } 29 | 30 | public MessageCollection(IEnumerable messages, MessageOptions options = null) 31 | { 32 | foreach (string message in messages) 33 | { 34 | Messages.Add(new QueueMessage(message, options)); 35 | } 36 | } 37 | 38 | [JsonIgnore] 39 | public List Messages 40 | { 41 | get { return LazyInitializer.EnsureInitialized(ref _messages); } 42 | set { _messages = value; } 43 | } 44 | 45 | public static implicit operator MessageCollection(string message) 46 | { 47 | return new MessageCollection(message); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MessageContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | 9 | namespace IronSharp.IronMQ 10 | { 11 | public class MessageContainer 12 | { 13 | [JsonProperty("message", DefaultValueHandling = DefaultValueHandling.Ignore)] 14 | public QueueMessage Message { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MessageIdCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using IronSharp.Core; 4 | using Newtonsoft.Json; 5 | 6 | namespace IronSharp.IronMQ 7 | { 8 | public class MessageIdCollection : IMsg, IInspectable, IIdCollection 9 | { 10 | private List _ids; 11 | 12 | public MessageIdCollection() 13 | { 14 | } 15 | 16 | public MessageIdCollection(IEnumerable messageIds) 17 | { 18 | Ids.AddRange(messageIds); 19 | } 20 | 21 | [JsonProperty("ids")] 22 | public List Ids 23 | { 24 | get { return LazyInitializer.EnsureInitialized(ref _ids); } 25 | set { _ids = value; } 26 | } 27 | 28 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 29 | public string Message { get; set; } 30 | 31 | [JsonIgnore] 32 | public bool Success 33 | { 34 | get { return this.HasExpectedMessage("Messages put on queue."); } 35 | } 36 | 37 | public static implicit operator bool(MessageIdCollection collection) 38 | { 39 | return collection.Success; 40 | } 41 | 42 | IEnumerable IIdCollection.GetIds() 43 | { 44 | return Ids; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MessageIdContainer.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronMQ 5 | { 6 | public class MessageIdContainer : IInspectable 7 | { 8 | 9 | /// 10 | /// Id of message. 11 | /// 12 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 13 | public string Id { get; set; } 14 | 15 | /// 16 | /// When message is reserved this property stores actual reservation_id. This id can be used 17 | /// for deleting the message, touching or releasing. 18 | /// 19 | [JsonProperty("reservation_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 20 | public string ReservationId { get; set; } 21 | 22 | [JsonProperty("subscriber_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 23 | public string SubscriberName { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MessageOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IronSharp.Core; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronMQ 6 | { 7 | public class MessageOptions : IInspectable 8 | { 9 | /// 10 | /// The item will not be available on the queue until this many seconds have passed. 11 | /// Default is 0 seconds. 12 | /// Maximum is 604,800 seconds (7 days). 13 | /// 14 | [JsonProperty("delay", DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public int? Delay { get; set; } 16 | 17 | /// 18 | /// How long in seconds to keep the item on the queue before it is deleted. 19 | /// Default is 604,800 seconds (7 days). 20 | /// Maximum is 2,592,000 seconds (30 days). 21 | /// 22 | [JsonProperty("expires_in", DefaultValueHandling = DefaultValueHandling.Ignore)] 23 | public int? ExpiresIn { get; set; } 24 | 25 | /// 26 | /// After timeout (in seconds), item will be placed back onto queue. 27 | /// You must delete the message from the queue to ensure it does not go back onto the queue. 28 | /// Default is 60 seconds. 29 | /// Minimum is 30 seconds, and maximum is 86,400 seconds (24 hours). 30 | /// 31 | [JsonProperty("timeout", DefaultValueHandling = DefaultValueHandling.Ignore)] 32 | public int? Timeout { get; set; } 33 | 34 | /// 35 | /// When message is sent to a push queue these headers will be passed to subscribers 36 | /// 37 | [JsonProperty("push_headers", DefaultValueHandling = DefaultValueHandling.Ignore)] 38 | public Dictionary PushHeaders { get; set; } 39 | 40 | /// 41 | /// When message is reserved this property stores actual reservation_id. This id can be used 42 | /// for deleting the message, touching or releasing. 43 | /// 44 | [JsonProperty("reservation_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 45 | public string ReservationId { get; set; } 46 | 47 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 48 | protected string Msg { get; set; } 49 | } 50 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/MqPagingFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.Core 6 | { 7 | public class MqPagingFilter : PagingFilter 8 | { 9 | public MqPagingFilter() 10 | { 11 | } 12 | 13 | public MqPagingFilter(string previous = null, int? perPage = null) 14 | { 15 | Previous = previous; 16 | PerPage = perPage.GetValueOrDefault(); 17 | } 18 | 19 | public MqPagingFilter(IPagingFilter filter) 20 | { 21 | if (filter == null) 22 | { 23 | return; 24 | } 25 | PerPage = filter.PerPage; 26 | if (filter is MqPagingFilter) 27 | Previous = ((MqPagingFilter)filter).Previous; 28 | } 29 | 30 | private const string PAGE_NOT_SUPPORTED = "Pagination principle in List Queues changed. It doesn’t support Page parameter. You should specify the name of queue prior to the first desirable queue in result."; 31 | [JsonProperty("page")] 32 | public override int Page 33 | { 34 | get { return default(int); } 35 | set { throw new NotSupportedException(PAGE_NOT_SUPPORTED); } 36 | } 37 | 38 | [JsonProperty("per_page")] 39 | public int PerPage { get; set; } 40 | 41 | 42 | /// 43 | /// The name of queue prior to the first desirable queue in result. 44 | /// If queue with specified name doesn’t exist result will contain first 45 | /// amount of queues that lexicographically greater than Previous 46 | /// 47 | [JsonProperty("previous")] 48 | public string Previous { get; set; } 49 | 50 | public static implicit operator NameValueCollection(MqPagingFilter filter) 51 | { 52 | var collection = new NameValueCollection(); 53 | 54 | if (filter != null && filter.PerPage > 0) 55 | { 56 | collection.Add("per_page", Convert.ToString(filter.PerPage)); 57 | } 58 | 59 | if (filter != null && !String.IsNullOrEmpty(filter.Previous)) 60 | { 61 | collection.Add("previous", filter.Previous); 62 | } 63 | 64 | return collection; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("IronSharp.IronMQ")] 5 | [assembly: AssemblyProduct("IronSharp.IronMQ")] 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: Guid("597a8f42-31b3-4698-bcc3-d1a2a2ea008f")] 9 | 10 | [assembly: AssemblyDescription("Message Queue for the Cloud. IronMQ is a reliable message queue service that lets you connect systems and build distributed apps that scale effortlessly and eliminate any single points of failure.")] -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/PushInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using Newtonsoft.Json; 8 | 9 | namespace IronSharp.IronMQ 10 | { 11 | public class PushInfo 12 | { 13 | [JsonProperty("subscribers", DefaultValueHandling = DefaultValueHandling.Ignore)] 14 | private List _subscribers; 15 | 16 | /// 17 | /// How many times to retry on failure. 18 | /// Default is 3. 19 | /// Maximum is 100. 20 | /// 21 | [JsonProperty("retries", DefaultValueHandling = DefaultValueHandling.Ignore)] 22 | public int? Retries { get; set; } 23 | 24 | /// 25 | /// Delay between each retry in seconds. 26 | /// Default is 60. 27 | /// 28 | [JsonProperty("retries_delay", DefaultValueHandling = DefaultValueHandling.Ignore)] 29 | public int? RetriesDelay { get; set; } 30 | 31 | [JsonIgnore] 32 | public List Subscribers 33 | { 34 | get { return LazyInitializer.EnsureInitialized(ref _subscribers); } 35 | set { _subscribers = value; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/PushStatus.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.IronMQ 4 | { 5 | public class PushStatus 6 | { 7 | [JsonProperty("retries_remaining", DefaultValueHandling = DefaultValueHandling.Ignore)] 8 | public int? RetriesRemaining { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/PushType.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronMQ 2 | { 3 | public enum PushType 4 | { 5 | Pull = 0, 6 | 7 | /// 8 | /// Multicast is a routing pattern that will push the messages to all the subscribers. http://dev.iron.io/faq/#MQfaq-11 9 | /// 10 | Multicast, 11 | 12 | /// 13 | /// Unicast is a routing pattern that will cycle through the endpoints pushing to one endpoint after another until a success push occurs. http://dev.iron.io/faq/#MQfaq-11 14 | /// 15 | Unicast 16 | } 17 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueueContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class QueueContainer : IInspectable 10 | { 11 | public QueueContainer(QueueInfo queue) 12 | { 13 | Queue = queue; 14 | } 15 | 16 | [JsonProperty("queue", DefaultValueHandling = DefaultValueHandling.Ignore)] 17 | public QueueInfo Queue { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueueDeadletterInfo.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronMQ 5 | { 6 | /// 7 | /// Info about dead letter queue, as documented on http://dev.iron.io/mq/3/reference/dlq/ 8 | /// 9 | public class QueueDeadletterInfo : IInspectable 10 | { 11 | /// 12 | /// Name of the dead-letter queue, if one is setup 13 | /// 14 | [JsonProperty("queue_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public string Name { get; set; } 16 | 17 | /// 18 | /// Max reservations before messages are moved to this dead letter queue 19 | /// 20 | [JsonProperty("max_reservations", DefaultValueHandling = DefaultValueHandling.Ignore)] 21 | public int MaxReservations { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueueInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class QueueInfo : IInspectable 10 | { 11 | [JsonProperty("alerts", DefaultValueHandling = DefaultValueHandling.Ignore)] 12 | private List _alerts; 13 | 14 | [JsonProperty("push", DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public PushInfo PushInfo { get; set; } 16 | 17 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string Id { get; set; } 19 | 20 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 21 | public string Name { get; set; } 22 | 23 | [JsonProperty("project_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public string ProjectId { get; set; } 25 | 26 | /// 27 | /// Either multicast to push to all subscribers or unicast to push to one and only one subscriber. 28 | /// Default is multicast. 29 | /// To revert push queue to reqular pull queue set pull. 30 | /// 31 | [JsonIgnore] 32 | public PushType PushType { get; set; } 33 | 34 | [JsonProperty("size", DefaultValueHandling = DefaultValueHandling.Ignore)] 35 | public int? Size { get; set; } 36 | 37 | [JsonProperty("total_messages", DefaultValueHandling = DefaultValueHandling.Ignore)] 38 | public int? TotalMessages { get; set; } 39 | 40 | [JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)] 41 | protected string PushTypeValue 42 | { 43 | get 44 | { 45 | switch (PushType) 46 | { 47 | case PushType.Pull: 48 | return "pull"; 49 | case PushType.Multicast: 50 | return "multicast"; 51 | case PushType.Unicast: 52 | return "unicast"; 53 | default: 54 | throw new ArgumentOutOfRangeException(); 55 | } 56 | } 57 | set { PushType = value.As(); } 58 | } 59 | 60 | /// 61 | /// Time (in seconds), after which messages taken from this queue will be placed back onto queue. 62 | /// You must delete the message from the queue to ensure it does not go back onto the queue. 63 | /// Default is 60 seconds. 64 | /// Minimum is 30 seconds, and maximum is 86,400 seconds (24 hours). 65 | /// 66 | [JsonProperty("message_timeout", DefaultValueHandling = DefaultValueHandling.Ignore)] 67 | public int? MessageTimeout { get; set; } 68 | 69 | /// 70 | /// Time (in seconds) after posting the message to the queue it will be deleted 71 | /// Default is 604800 seconds (7 days). 72 | /// 73 | [JsonProperty("message_expiration", DefaultValueHandling = DefaultValueHandling.Ignore)] 74 | public int? MessageExpiration { get; set; } 75 | 76 | [JsonProperty("dead_letter", DefaultValueHandling = DefaultValueHandling.Ignore)] 77 | public QueueDeadletterInfo QueueDeadletterInfo { get; set; } 78 | 79 | [JsonIgnore] 80 | public List Alerts 81 | { 82 | get { return LazyInitializer.EnsureInitialized(ref _alerts); } 83 | set { _alerts = value; } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueueMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronMQ 5 | { 6 | public class QueueMessage : MessageOptions 7 | { 8 | public QueueMessage(string body, MessageOptions options = null) 9 | : this() 10 | { 11 | Body = body; 12 | 13 | if (options == null) return; 14 | 15 | Delay = options.Delay; 16 | ExpiresIn = options.ExpiresIn; 17 | Timeout = options.Timeout; 18 | PushHeaders = options.PushHeaders; 19 | } 20 | 21 | protected QueueMessage() 22 | { 23 | } 24 | 25 | #region Properties 26 | 27 | /// 28 | /// The message data 29 | /// 30 | [JsonProperty("body")] 31 | public string Body { get; set; } 32 | 33 | [JsonProperty("id")] 34 | public string Id { get; set; } 35 | 36 | [JsonProperty("push_status", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public PushStatus PushStatus { get; set; } 38 | 39 | [JsonProperty("reserved_count", DefaultValueHandling = DefaultValueHandling.Ignore)] 40 | public int? ReservedCount { get; set; } 41 | 42 | #endregion 43 | 44 | #region Methods 45 | 46 | /// 47 | /// This call will delete the message. Be sure you call this after you’re done with a message or it will be placed back on the queue. 48 | /// 49 | public bool Delete() 50 | { 51 | return Client.DeleteMessage(Id, ReservationId); 52 | } 53 | 54 | /// 55 | /// Releases this message and puts it back on the queue as if the message had timed out. 56 | /// 57 | /// The item will not be available on the queue until this many seconds have passed. Default is 0 seconds. Maximum is 604,800 seconds (7 days). 58 | /// 59 | public bool Release(int? delay = null) 60 | { 61 | return Client.Release(Id, ReservationId, delay); 62 | } 63 | 64 | /// 65 | /// Extends this message's timeout by the duration specified when the message was created, which is 60 seconds by default. 66 | /// 67 | public MessageOptions Touch() 68 | { 69 | var options = Client.Touch(Id, ReservationId); 70 | this.ReservationId = options.ReservationId; 71 | return options; 72 | } 73 | 74 | #endregion 75 | 76 | [JsonIgnore] 77 | internal QueueClient Client { get; set; } 78 | 79 | [JsonProperty("subscriber_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 80 | public string SubscriberName { get; set; } 81 | 82 | public static implicit operator QueueMessage(string message) 83 | { 84 | return new QueueMessage(message); 85 | } 86 | 87 | public object ReadValueAs(Type type) 88 | { 89 | return Client.ValueSerializer.Parse(Body, type); 90 | } 91 | 92 | public T ReadValueAs() 93 | { 94 | return Client.ValueSerializer.Parse(Body); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueueMessageContext.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronMQ 2 | { 3 | public class QueueMessageContext 4 | { 5 | public QueueMessage Message { get; set; } 6 | 7 | public QueueClient Client { get; set; } 8 | 9 | public bool Success { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/QueuesInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class QueuesInfo : IInspectable 10 | { 11 | [JsonProperty("queues", DefaultValueHandling = DefaultValueHandling.Ignore)] 12 | private List _queues; 13 | 14 | public List Queues 15 | { 16 | get { return _queues; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/ReservedMessageIdCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class ReservedMessageIdCollection : IInspectable 10 | { 11 | private List _ids; 12 | 13 | public ReservedMessageIdCollection(IEnumerable messageIds) 14 | { 15 | _ids = new List(); 16 | _ids.AddRange(messageIds.Select(id => new MessageIdContainer { Id = id })); 17 | } 18 | public ReservedMessageIdCollection(MessageCollection collection) 19 | { 20 | _ids = new List(); 21 | _ids.AddRange(collection.Messages.ConvertAll(m => new MessageIdContainer { Id = m.Id, ReservationId = m.ReservationId, SubscriberName = m.SubscriberName})); 22 | } 23 | 24 | [JsonProperty("ids", DefaultValueHandling = DefaultValueHandling.Ignore)] 25 | public List Ids 26 | { 27 | get { return LazyInitializer.EnsureInitialized(ref _ids); } 28 | set { _ids = value; } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/Subscriber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using Newtonsoft.Json; 5 | 6 | namespace IronSharp.IronMQ 7 | { 8 | public class Subscriber 9 | { 10 | public Subscriber() : this(null,null,null) 11 | { 12 | } 13 | 14 | public Subscriber(string name, string url) : this(name, url, null) 15 | { 16 | } 17 | 18 | public Subscriber(string name, string url, Dictionary headers ) 19 | { 20 | Name = name; 21 | Url = url; 22 | Headers = headers; 23 | } 24 | 25 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 26 | public string Name { get; set; } 27 | 28 | [JsonProperty("retries_delay", DefaultValueHandling = DefaultValueHandling.Ignore)] 29 | public int? RetriesDelay { get; set; } 30 | 31 | [JsonProperty("retries_remaining", DefaultValueHandling = DefaultValueHandling.Ignore)] 32 | public int? RetriesRemaining { get; set; } 33 | 34 | [JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)] 35 | public string Status { get; set; } 36 | 37 | [JsonProperty("status_code", DefaultValueHandling = DefaultValueHandling.Ignore)] 38 | protected int? Code { get; set; } 39 | 40 | [JsonProperty("url")] 41 | public string Url { get; set; } 42 | 43 | [JsonProperty("error_queue", DefaultValueHandling = DefaultValueHandling.Ignore)] 44 | public string ErrorQueue { get; set; } 45 | 46 | [JsonProperty("headers", DefaultValueHandling = DefaultValueHandling.Ignore)] 47 | public Dictionary Headers { get; set; } 48 | 49 | [JsonIgnore] 50 | public HttpStatusCode StatusCode 51 | { 52 | get { return (HttpStatusCode) Code.GetValueOrDefault(200); } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/SubscriberCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronMQ 8 | { 9 | public class SubscriberCollection : IInspectable 10 | { 11 | [JsonProperty("subscribers", DefaultValueHandling = DefaultValueHandling.Ignore)] private List _subscribers; 12 | 13 | public SubscriberCollection() 14 | { 15 | } 16 | 17 | public SubscriberCollection(string name, string url) : this(name, url, null) 18 | { 19 | } 20 | 21 | public SubscriberCollection(string name, Uri uri) : this(name, uri.ToString(), null) 22 | { 23 | } 24 | 25 | public SubscriberCollection(string name, string url, Dictionary headers) 26 | { 27 | Subscribers.Add(new Subscriber(name, url, headers)); 28 | } 29 | 30 | public SubscriberCollection(string name, Uri uri, Dictionary headers) 31 | : this(name, uri.ToString(), headers) 32 | { 33 | } 34 | 35 | [JsonIgnore] 36 | public List Subscribers 37 | { 38 | get { return LazyInitializer.EnsureInitialized(ref _subscribers); } 39 | set { _subscribers = value; } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/IronSharp.IronMQ/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Client.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | /// 6 | /// http://dev.iron.io/worker/reference/api/#list_code_packages 7 | /// 8 | public static class Client 9 | { 10 | /// 11 | /// Creates a new client using the environmental configuration JSON heirarchy. 12 | /// 13 | public static IronWorkerRestClient @New() 14 | { 15 | return New(null); 16 | } 17 | 18 | /// 19 | /// Creates a new client using the specified values 20 | /// 21 | public static IronWorkerRestClient @New(string projectId, string token, string host = null) 22 | { 23 | return New(new IronClientConfig 24 | { 25 | Host = host, 26 | ProjectId = projectId, 27 | Token = token 28 | }); 29 | } 30 | 31 | /// 32 | /// Loads the config from a specific enivonment key 33 | /// 34 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 35 | public static IronWorkerRestClient @New(string env) 36 | { 37 | return New(null, env); 38 | } 39 | 40 | /// 41 | /// Creates a new client using the specified configuration and optional paramter to specificy which enivonment to use when loading default values; 42 | /// 43 | /// The explicitly specified configuration values 44 | /// The environment key as it appears in the iron.json file. See http://dev.iron.io/worker/reference/cli/#upload_with_multiple_environments for an example layout 45 | public static IronWorkerRestClient @New(IronClientConfig config, string env = null) 46 | { 47 | IronClientConfig hierarchyConfig = IronDotConfigManager.Load(IronProduct.IronWorker, config, env); 48 | 49 | return new IronWorkerRestClient(hierarchyConfig); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Code/CodeClient.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Net.Http; 3 | using System.Net.Mime; 4 | using System.Threading.Tasks; 5 | using IronSharp.Core; 6 | 7 | namespace IronSharp.IronWorker 8 | { 9 | public class CodeClient 10 | { 11 | private readonly IronWorkerRestClient _client; 12 | private readonly RestClient _restClient = new RestClient(); 13 | private readonly string _codeId; 14 | 15 | public CodeClient(IronWorkerRestClient client, string codeId) 16 | { 17 | _client = client; 18 | _codeId = codeId; 19 | } 20 | 21 | public string EndPoint 22 | { 23 | get { return string.Format("{0}/codes/{1}", _client.EndPoint, _codeId); } 24 | } 25 | 26 | /// 27 | /// Delete a code package 28 | /// 29 | /// 30 | /// http://dev.iron.io/worker/reference/api/#delete_a_code_package 31 | /// 32 | public bool Delete() 33 | { 34 | return _restClient.Delete(_client.Config, EndPoint).HasExpectedMessage("Deleted"); 35 | } 36 | 37 | /// 38 | /// Download a Code Package 39 | /// 40 | /// 41 | /// http://dev.iron.io/worker/reference/api/#download_a_code_package 42 | /// 43 | public Task Download() 44 | { 45 | return _restClient.Execute(_client.Config, new RestClientRequest 46 | { 47 | EndPoint = EndPoint + "/download", 48 | Method = HttpMethod.Get, 49 | Accept = MediaTypeNames.Application.Octet 50 | }); 51 | } 52 | 53 | /// 54 | /// Get info about a code package 55 | /// 56 | /// 57 | /// http://dev.iron.io/worker/reference/api/#get_info_about_a_code_package 58 | /// 59 | public CodeInfo Info() 60 | { 61 | return _restClient.Get(_client.Config, EndPoint); 62 | } 63 | 64 | public RevisionCollection Revisions(int? page = null, int? perPage = null) 65 | { 66 | return Revisions(new PagingFilter(page, perPage)); 67 | } 68 | 69 | /// 70 | /// List Code Package Revisions 71 | /// 72 | /// 73 | /// http://dev.iron.io/worker/reference/api/#list_code_package_revisions 74 | /// 75 | public RevisionCollection Revisions(PagingFilter filter = null) 76 | { 77 | return _restClient.Get(_client.Config, EndPoint + "/revisions", filter); 78 | } 79 | 80 | /// 81 | /// Upload a Code Package 82 | /// 83 | /// 84 | /// http://dev.iron.io/worker/reference/api/#upload_or_update_a_code_package 85 | /// 86 | public Task Upload(Stream zipFile, WorkerOptions options) 87 | { 88 | return _restClient.Execute(_client.Config, new RestClientRequest 89 | { 90 | EndPoint = EndPoint, 91 | Method = HttpMethod.Post, 92 | Content = new MultipartFormDataContent 93 | { 94 | new JsonContent(options), 95 | new StreamContent(zipFile) 96 | } 97 | }); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Code/CodeInfo.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class CodeInfo : IInspectable 7 | { 8 | [JsonProperty("file_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 9 | public string FileName { get; set; } 10 | 11 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 12 | public string Id { get; set; } 13 | 14 | [JsonProperty("latest_change", DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public string LatestChange { get; set; } 16 | 17 | [JsonProperty("latest_checksum", DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string LatestChecksum { get; set; } 19 | 20 | [JsonProperty("latest_history_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 21 | public string LatestHistoryId { get; set; } 22 | 23 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public string Name { get; set; } 25 | 26 | [JsonProperty("project_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 27 | public string ProjectId { get; set; } 28 | 29 | [JsonProperty("rev", DefaultValueHandling = DefaultValueHandling.Ignore)] 30 | public int? Revision { get; set; } 31 | 32 | [JsonProperty("runtime", DefaultValueHandling = DefaultValueHandling.Ignore)] 33 | public string Runtime { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Code/CodeInfoCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class CodeInfoCollection 8 | { 9 | private List _codes; 10 | 11 | [JsonProperty("codes")] 12 | public List Codes 13 | { 14 | get { return LazyInitializer.EnsureInitialized(ref _codes); } 15 | set { _codes = value; } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Code/RevisionCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class RevisionCollection 8 | { 9 | private List _revisions; 10 | 11 | [JsonProperty("revisions")] 12 | public List Revisions 13 | { 14 | get { return LazyInitializer.EnsureInitialized(ref _revisions); } 15 | set { _revisions = value; } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Code/WorkerOptions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | public class WorkerOptions 6 | { 7 | /// 8 | /// A unique name for your worker. This will be used to assign tasks to the worker as well as to update the code. If a worker with this name already exists, the code you are uploading 9 | /// will be added as a new revision. 10 | /// 11 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 12 | public string Name { get; set; } 13 | 14 | /// 15 | /// The name of the file within the zip that will be executed when a task is run. 16 | /// 17 | [JsonProperty("file_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string FileName { get; set; } 19 | 20 | /// 21 | /// An arbitrary string (usually YAML or JSON) that, if provided, will be available in a file that your worker can access. File location will be passed in via the -config argument. 22 | /// The config cannot be larger than 64KB in size. 23 | /// 24 | [JsonProperty("config", DefaultValueHandling = DefaultValueHandling.Ignore)] 25 | public string Config { get; set; } 26 | 27 | /// 28 | /// The maximum number of workers that should be run in parallel. This is useful for keeping your workers from hitting API quotas or overloading databases that are not prepared to 29 | /// handle the highly-concurrent worker environment. If omitted, there will be no limit on the number of concurrent workers. 30 | /// 31 | [JsonProperty("max_concurrency", DefaultValueHandling = DefaultValueHandling.Ignore)] 32 | public int? MaxConcurrency { get; set; } 33 | 34 | /// 35 | /// The maximum number of times failed tasks should be retried, in the event that there’s an error while running them. If omitted, tasks will not be retried. Tasks cannot be retried 36 | /// more than ten times. 37 | /// 38 | [JsonProperty("retries", DefaultValueHandling = DefaultValueHandling.Ignore)] 39 | public int? Retries { get; set; } 40 | 41 | /// 42 | /// The number of seconds to wait before retries. If omitted, tasks will be immediately retried. 43 | /// 44 | [JsonProperty("retries_delay", DefaultValueHandling = DefaultValueHandling.Ignore)] 45 | public int? RetriesDelay { get; set; } 46 | } 47 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/IronSharp.IronWorker.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B} 8 | Library 9 | Properties 10 | IronSharp.IronWorker 11 | IronSharp.IronWorker 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | bin\Publish\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | 43 | ..\packages\Newtonsoft.Json.5.0.7\lib\net45\Newtonsoft.Json.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | {1a6cc922-40a5-440a-868d-757fcdb08622} 95 | IronSharp.Core 96 | 97 | 98 | 99 | 100 | 107 | -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/IronSharp.IronWorker.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/IronSharp.IronWorker.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iron.IronWorker 5 | 1.0.2 6 | IronWorker 7 | Jeremy Bell 8 | Iron.io 9 | https://raw.github.com/iron-io/iron_dotnet/master/LICENSE 10 | https://github.com/iron-io/iron_dotnet 11 | https://raw.github.com/iron-io/iron_dotnet/master/images/net-iron-w.png 12 | false 13 | An easy-to-use scalable task queue that gives cloud developers a simple way to offload front-end tasks, run scheduled jobs, and process tasks in the background and at scale. 14 | Added generate Webhook URI method 15 | iron.io,cloud workers,task,scheduling 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/IronWorkCloudHosts.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronWorker 2 | { 3 | public static class IronWorkCloudHosts 4 | { 5 | public const string DEFAULT = AWS_US_EAST_HOST; 6 | 7 | /// 8 | /// Default 9 | /// 10 | public const string AWS_US_EAST_HOST = "worker-aws-us-east-1.iron.io"; 11 | } 12 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/IronWorkerRestClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using IronSharp.Core; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class IronWorkerRestClient 7 | { 8 | private readonly IronClientConfig _config; 9 | private readonly RestClient _restClient = new RestClient(); 10 | 11 | internal IronWorkerRestClient(IronClientConfig config) 12 | { 13 | _config = LazyInitializer.EnsureInitialized(ref config); 14 | 15 | if (string.IsNullOrEmpty(Config.Host)) 16 | { 17 | Config.Host = IronWorkCloudHosts.DEFAULT; 18 | } 19 | 20 | if (config.ApiVersion == default (int)) 21 | { 22 | config.ApiVersion = 2; 23 | } 24 | } 25 | 26 | public IronClientConfig Config 27 | { 28 | get { return _config; } 29 | } 30 | 31 | public string EndPoint 32 | { 33 | get { return "/projects/{Project ID}"; } 34 | } 35 | 36 | #region Code 37 | 38 | public CodeClient Code(string codeId) 39 | { 40 | return new CodeClient(this, codeId); 41 | } 42 | 43 | public CodeInfoCollection Codes(int? page = null, int? perPage = null) 44 | { 45 | return Codes(new PagingFilter 46 | { 47 | Page = page.GetValueOrDefault(), 48 | PerPage = perPage.GetValueOrDefault() 49 | }); 50 | } 51 | 52 | /// 53 | /// List code packages 54 | /// 55 | /// 56 | /// 57 | /// http://dev.iron.io/worker/reference/api/#list_code_packages 58 | /// 59 | public CodeInfoCollection Codes(PagingFilter filter = null) 60 | { 61 | return _restClient.Get(_config, string.Format("{0}/codes", EndPoint), filter).Result; 62 | } 63 | 64 | #endregion 65 | 66 | #region Task 67 | 68 | public TaskClient Tasks 69 | { 70 | get { return new TaskClient(this); } 71 | } 72 | 73 | #endregion 74 | 75 | #region Schedule 76 | 77 | public ScheduleClient Schedules 78 | { 79 | get { return new ScheduleClient(this); } 80 | } 81 | 82 | #endregion 83 | } 84 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/PriorityOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class PriorityOption : IInspectable 8 | { 9 | /// 10 | /// The priority queue to run the job in. Valid values are 0, 1, and 2. The default is 0. Higher values means tasks spend less time in the queue once they come off the schedule. 11 | /// 12 | [JsonIgnore] 13 | public TaskPriority Priority { get; set; } 14 | 15 | [JsonProperty("priority", DefaultValueHandling = DefaultValueHandling.Ignore)] 16 | protected int? PriorityValue 17 | { 18 | get 19 | { 20 | switch (Priority) 21 | { 22 | case TaskPriority.Default: 23 | return null; 24 | case TaskPriority.Medium: 25 | return 1; 26 | case TaskPriority.High: 27 | return 2; 28 | default: 29 | throw new ArgumentOutOfRangeException(); 30 | } 31 | } 32 | set { Priority = (TaskPriority) value.GetValueOrDefault(); } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("IronSharp.IronWorker")] 5 | [assembly: AssemblyProduct("IronSharp.IronWorker")] 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: Guid("740a5fa9-60d2-4b88-8445-5608b4ddca63")] 9 | 10 | [assembly: AssemblyDescription("Workers and Scheduling. IronWorker is a multi-language worker platform that runs tasks in the background, in parallel, and at massive scale.")] -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | public static class ScheduleBuilder 6 | { 7 | public static readonly TimeSpan Month = TimeSpan.FromDays(30.4368); 8 | 9 | public static readonly TimeSpan Week = TimeSpan.FromDays(7); 10 | 11 | /// 12 | /// Creates a schedule builder instance 13 | /// 14 | /// The current date and time relative the timezone setting under the account in the HUD on Iron.io (defaults to current local time) 15 | public static ScheduleOptionsBuilder Build(DateTime? now = null) 16 | { 17 | return new ScheduleOptionsBuilder(now.GetValueOrDefault(DateTime.Now)); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Contracts; 3 | using IronSharp.Core; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class ScheduleClient 8 | { 9 | private readonly IronWorkerRestClient _client; 10 | private readonly RestClient _restClient = new RestClient(); 11 | 12 | public ScheduleClient(IronWorkerRestClient client) 13 | { 14 | if (client == null) throw new ArgumentNullException("client"); 15 | Contract.EndContractBlock(); 16 | 17 | _client = client; 18 | } 19 | 20 | public string EndPoint 21 | { 22 | get { return string.Format("{0}/schedules", _client.EndPoint); } 23 | } 24 | 25 | public IValueSerializer ValueSerializer 26 | { 27 | get { return _client.Config.SharpConfig.ValueSerializer; } 28 | } 29 | 30 | public bool Cancel(string scheduleId) 31 | { 32 | return _restClient.Post(_client.Config, ScheduleEndPoint(scheduleId) + "/cancel").HasExpectedMessage("Cancelled"); 33 | } 34 | 35 | public ScheduleIdCollection Create(string codeName, object payload, ScheduleOptions options) 36 | { 37 | return Create(codeName, ValueSerializer.Generate(payload), options); 38 | } 39 | 40 | public ScheduleIdCollection Create(string codeName, string payload, ScheduleOptions options) 41 | { 42 | return Create(new SchedulePayloadCollection(codeName, payload, options)); 43 | } 44 | 45 | public ScheduleIdCollection Create(SchedulePayloadCollection collection) 46 | { 47 | return _restClient.Post(_client.Config, EndPoint, collection); 48 | } 49 | 50 | public ScheduleInfo Get(string scheduleId) 51 | { 52 | return _restClient.Get(_client.Config, ScheduleEndPoint(scheduleId)); 53 | } 54 | 55 | /// 56 | /// List Scheduled Tasks 57 | /// 58 | /// 59 | /// 60 | /// http://dev.iron.io/worker/reference/api/#list_scheduled_tasks 61 | /// 62 | public ScheduleInfoCollection List(PagingFilter filter = null) 63 | { 64 | return _restClient.Get(_client.Config, EndPoint, filter); 65 | } 66 | 67 | public string ScheduleEndPoint(string scheduleId) 68 | { 69 | return string.Format("{0}/{1}", EndPoint, scheduleId); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleIdCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using IronSharp.Core; 4 | using Newtonsoft.Json; 5 | 6 | namespace IronSharp.IronWorker 7 | { 8 | public class ScheduleIdCollection : IMsg, IInspectable 9 | { 10 | private List _schedules; 11 | 12 | [JsonProperty("schedules")] 13 | public List Schedules 14 | { 15 | get { return LazyInitializer.EnsureInitialized(ref _schedules); } 16 | set { _schedules = value; } 17 | } 18 | 19 | [JsonIgnore] 20 | public bool Success 21 | { 22 | get { return this.HasExpectedMessage("Scheduled"); } 23 | } 24 | 25 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 26 | public string Message { get; set; } 27 | 28 | public static implicit operator bool(ScheduleIdCollection collection) 29 | { 30 | return collection.Success; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class ScheduleInfo : IMsg, IInspectable 8 | { 9 | [JsonProperty("code_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 10 | public string CodeName { get; set; } 11 | 12 | [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 13 | public DateTime? CreatedAt { get; set; } 14 | 15 | [JsonProperty("run_times", DefaultValueHandling = DefaultValueHandling.Ignore)] 16 | public int? RunTimes { get; set; } 17 | 18 | [JsonProperty("end_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 19 | public DateTime? EndAt { get; set; } 20 | 21 | [JsonProperty("start_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 22 | public DateTime? StartAt { get; set; } 23 | 24 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 25 | public string Id { get; set; } 26 | 27 | [JsonProperty("last_run_time", DefaultValueHandling = DefaultValueHandling.Ignore)] 28 | public DateTime? LastRunTime { get; set; } 29 | 30 | [JsonProperty("next_start", DefaultValueHandling = DefaultValueHandling.Ignore)] 31 | public DateTime? NextStart { get; set; } 32 | 33 | [JsonProperty("project_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 34 | public string ProjectId { get; set; } 35 | 36 | [JsonProperty("run_count", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public int? RunCount { get; set; } 38 | 39 | [JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)] 40 | public string Status { get; set; } 41 | 42 | [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 43 | public DateTime? UpdatedAt { get; set; } 44 | 45 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 46 | public string Message { get; set; } 47 | } 48 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleInfoCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronWorker 8 | { 9 | public class ScheduleInfoCollection : IInspectable, IIdCollection 10 | { 11 | private List _schedules; 12 | 13 | [JsonProperty("schedules")] 14 | public List Schedules 15 | { 16 | get { return LazyInitializer.EnsureInitialized(ref _schedules); } 17 | set { _schedules = value; } 18 | } 19 | 20 | /// 21 | /// Returns a list of IDs 22 | /// 23 | public IEnumerable GetIds() 24 | { 25 | return Schedules.Select(x => x.Id); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class ScheduleOptions : PriorityOption 7 | { 8 | private int? _runEvery; 9 | 10 | /// 11 | /// The amount of time, in seconds, between runs. By default, the task will only run once. run_every will return a 400 error if it is set to less than 60. 12 | /// 13 | [JsonProperty("run_every", DefaultValueHandling = DefaultValueHandling.Ignore)] 14 | public int? RunEvery 15 | { 16 | get { return _runEvery; } 17 | set 18 | { 19 | if (value.HasValue && value < 60) 20 | { 21 | value = 60; 22 | } 23 | _runEvery = value; 24 | } 25 | } 26 | 27 | /// 28 | /// The number of times a task will run. 29 | /// 30 | [JsonProperty("run_times", DefaultValueHandling = DefaultValueHandling.Ignore)] 31 | public int? RunTimes { get; set; } 32 | 33 | /// 34 | /// The time tasks will stop being queued. Should be a time or datetime. 35 | /// 36 | [JsonProperty("end_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public DateTime? EndAt { get; set; } 38 | 39 | /// 40 | /// The time the scheduled task should first be run. 41 | /// 42 | [JsonProperty("start_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 43 | public DateTime? StartAt { get; set; } 44 | } 45 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/ScheduleOptionsBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | public class ScheduleOptionsBuilder : ScheduleOptions 6 | { 7 | public ScheduleOptionsBuilder(DateTime now) 8 | { 9 | Now = now; 10 | } 11 | 12 | public DateTime Now { get; set; } 13 | 14 | public ScheduleOptionsBuilder Delay(TimeSpan delay) 15 | { 16 | return StartingOn(Now + delay); 17 | } 18 | 19 | public ScheduleOptionsBuilder StopAt(DateTime endAt) 20 | { 21 | EndAt = endAt; 22 | return this; 23 | } 24 | 25 | public ScheduleOptionsBuilder NeverStop() 26 | { 27 | EndAt = null; 28 | RunTimes = null; 29 | return this; 30 | } 31 | 32 | public ScheduleOptionsBuilder StopAfterNumberOfRuns(int times) 33 | { 34 | RunTimes = times; 35 | return this; 36 | } 37 | 38 | public ScheduleOptionsBuilder RunFor(TimeSpan duration) 39 | { 40 | return StopAt(Now + duration); 41 | } 42 | 43 | public ScheduleOptionsBuilder StartingOn(DateTime startAt) 44 | { 45 | StartAt = startAt; 46 | return this; 47 | } 48 | 49 | public ScheduleOptionsBuilder WithFrequency(TimeSpan frequency) 50 | { 51 | RunEvery = frequency.Seconds; 52 | return this; 53 | } 54 | 55 | public ScheduleOptionsBuilder WithPriority(TaskPriority priority) 56 | { 57 | Priority = priority; 58 | return this; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/SchedulePayload.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | public class SchedulePayload : ScheduleOptions 6 | { 7 | public SchedulePayload() 8 | { 9 | } 10 | 11 | public SchedulePayload(string codeName, string payload, ScheduleOptions options = null) 12 | { 13 | CodeName = codeName; 14 | Payload = payload; 15 | 16 | if (options == null) return; 17 | 18 | EndAt = options.EndAt; 19 | Priority = options.Priority; 20 | RunEvery = options.RunEvery; 21 | StartAt = options.StartAt; 22 | } 23 | 24 | /// 25 | /// The name of the code package to execute. 26 | /// 27 | [JsonProperty("code_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 28 | public string CodeName { get; set; } 29 | 30 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 31 | public string Name { get; set; } 32 | 33 | /// 34 | /// A string of data to pass to the code package on execution. 35 | /// 36 | [JsonProperty("payload", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public string Payload { get; set; } 38 | } 39 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/SchedulePayloadCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class SchedulePayloadCollection 8 | { 9 | private List _schedules; 10 | 11 | public SchedulePayloadCollection(SchedulePayload payload) 12 | { 13 | Schedules.Add(payload); 14 | } 15 | 16 | public SchedulePayloadCollection(string codeName, string payload, ScheduleOptions options = null) 17 | { 18 | Schedules.Add(new SchedulePayload(codeName, payload, options)); 19 | } 20 | 21 | [JsonProperty("schedules")] 22 | public List Schedules 23 | { 24 | get { return LazyInitializer.EnsureInitialized(ref _schedules); } 25 | set { _schedules = value; } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Schedules/TimeUnit.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronWorker 2 | { 3 | public enum TimeUnit 4 | { 5 | Seconds = 0, 6 | Minutes, 7 | Hours, 8 | Days, 9 | Weeks, 10 | Months, 11 | Year 12 | } 13 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/TaskPriority.cs: -------------------------------------------------------------------------------- 1 | namespace IronSharp.IronWorker 2 | { 3 | public enum TaskPriority 4 | { 5 | /// 6 | /// Default 7 | /// 8 | Default = 0, 9 | 10 | /// 11 | /// Medium 12 | /// 13 | Medium = 1, 14 | 15 | /// 16 | /// High (less time in queue) 17 | /// 18 | High = 2 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/TaskStates.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | [Flags] 6 | public enum TaskStates 7 | { 8 | /// 9 | /// No state information 10 | /// 11 | None = 0x0000, 12 | 13 | /// 14 | /// in the queue, waiting to run 15 | /// 16 | Queued = 0x0001, 17 | 18 | /// 19 | /// running 20 | /// 21 | Running = 0x0002, 22 | 23 | /// 24 | /// finished running 25 | /// 26 | Complete = 0x0004, 27 | 28 | /// 29 | /// error during processing 30 | /// 31 | Error = 0x0008, 32 | 33 | /// 34 | /// cancelled by user 35 | /// 36 | Cancelled = 0x0010, 37 | 38 | /// 39 | /// killed by system 40 | /// 41 | Killed = 0x0020, 42 | 43 | /// 44 | /// exceeded processing time threshold 45 | /// 46 | Timeout = 0x0040 47 | } 48 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskId.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class TaskId : IInspectable 7 | { 8 | [JsonProperty("id")] 9 | public string Id { get; set; } 10 | 11 | public override string ToString() 12 | { 13 | return Id; 14 | } 15 | 16 | public static implicit operator string(TaskId taskId) 17 | { 18 | return taskId == null ? null : taskId.Id; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskIdCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronWorker 8 | { 9 | public class TaskIdCollection : IMsg, IInspectable, IIdCollection 10 | { 11 | private List _tasks; 12 | 13 | [JsonIgnore] 14 | public bool Success 15 | { 16 | get { return this.HasExpectedMessage("Queued up"); } 17 | } 18 | 19 | [JsonProperty("tasks")] 20 | public List Tasks 21 | { 22 | get { return LazyInitializer.EnsureInitialized(ref _tasks); } 23 | set { _tasks = value; } 24 | } 25 | 26 | /// 27 | /// Returns a list of IDs 28 | /// 29 | public IEnumerable GetIds() 30 | { 31 | return Tasks.Select(x => x.Id); 32 | } 33 | 34 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 35 | public string Message { get; set; } 36 | 37 | public static implicit operator bool(TaskIdCollection collection) 38 | { 39 | return collection.Success; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | using Newtonsoft.Json; 4 | 5 | namespace IronSharp.IronWorker 6 | { 7 | public class TaskInfo : IMsg, IInspectable 8 | { 9 | [JsonProperty("code_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 10 | public string CodeId { get; set; } 11 | 12 | [JsonProperty("code_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 13 | public string CodeName { get; set; } 14 | 15 | [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 16 | public DateTime? CreatedAt { get; set; } 17 | 18 | [JsonProperty("duration", DefaultValueHandling = DefaultValueHandling.Ignore)] 19 | public int? Duration { get; set; } 20 | 21 | [JsonProperty("end_time", DefaultValueHandling = DefaultValueHandling.Ignore)] 22 | public DateTime? EndTime { get; set; } 23 | 24 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 25 | public string Id { get; set; } 26 | 27 | [JsonProperty("schedule_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 28 | public string ScheduleId { get; set; } 29 | 30 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 31 | public string Message { get; set; } 32 | 33 | [JsonProperty("percent", DefaultValueHandling = DefaultValueHandling.Ignore)] 34 | public int? Percent { get; set; } 35 | 36 | [JsonProperty("project_id", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public string ProjectId { get; set; } 38 | 39 | [JsonProperty("run_times", DefaultValueHandling = DefaultValueHandling.Ignore)] 40 | public int? RunTimes { get; set; } 41 | 42 | [JsonProperty("start_time", DefaultValueHandling = DefaultValueHandling.Ignore)] 43 | public DateTime? StartTime { get; set; } 44 | 45 | [JsonIgnore] 46 | public TaskStates Status { 47 | get { return StatusValue.As(); } 48 | set { StatusValue = Convert.ToString(value).ToLower(); } 49 | } 50 | 51 | [JsonProperty("timeout", DefaultValueHandling = DefaultValueHandling.Ignore)] 52 | public int? Timeout { get; set; } 53 | 54 | [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 55 | public DateTime? UpdatedAt { get; set; } 56 | 57 | [JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)] 58 | protected string StatusValue { get; set; } 59 | } 60 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskInfoCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading; 4 | using IronSharp.Core; 5 | using Newtonsoft.Json; 6 | 7 | namespace IronSharp.IronWorker 8 | { 9 | public class TaskInfoCollection : IInspectable, IIdCollection 10 | { 11 | private List _tasks; 12 | 13 | [JsonIgnore] 14 | public bool IsEmpty 15 | { 16 | get { return _tasks == null || _tasks.Count == 0; } 17 | } 18 | 19 | [JsonProperty("tasks")] 20 | public List Tasks 21 | { 22 | get { return LazyInitializer.EnsureInitialized(ref _tasks); } 23 | set { _tasks = value; } 24 | } 25 | 26 | /// 27 | /// Returns a list of IDs 28 | /// 29 | public IEnumerable GetIds() 30 | { 31 | return Tasks.Select(x => x.Id); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskListFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using IronSharp.Core; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class TaskListFilter : PagingFilter 7 | { 8 | /// 9 | /// Limit the retrieved tasks to only those that were created after the time specified in the value. Time should be formatted as the number of seconds since 10 | /// the Unix epoch. 11 | /// 12 | public DateTime? FromTime { get; set; } 13 | 14 | /// 15 | /// Limit the retrieved tasks to only those that were created before the time specified in the value. Time should be formatted as the number of seconds since the 16 | /// Unix epoch. 17 | /// 18 | public DateTime? ToTime { get; set; } 19 | 20 | /// 21 | /// the parameters queued, running, complete, error, cancelled, killed, and timeout will all filter by their respective status when given a value of 1. 22 | /// These parameters can be mixed and matched to return tasks that fall into any of the status filters. 23 | /// If no filters are provided, tasks will be displayed across all statuses. 24 | /// 25 | public TaskStates Status { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskOptions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace IronSharp.IronWorker 4 | { 5 | public class TaskOptions : PriorityOption 6 | { 7 | /// 8 | /// The maximum runtime of your task in seconds. No task can exceed 3600 seconds (60 minutes). The default is 3600 but can be set to a shorter duration. 9 | /// 10 | [JsonProperty("timeout", DefaultValueHandling = DefaultValueHandling.Ignore)] 11 | public int? Timeout { get; set; } 12 | 13 | /// 14 | /// The number of seconds to delay before actually queuing the task. Default is 0. 15 | /// 16 | [JsonProperty("delay", DefaultValueHandling = DefaultValueHandling.Ignore)] 17 | public int? Delay { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskPayload.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | /// 7 | /// http://dev.iron.io/worker/reference/api/#schedule_a_task 8 | /// 9 | public class TaskPayload : TaskOptions 10 | { 11 | public TaskPayload() 12 | { 13 | } 14 | 15 | public TaskPayload(string codeName, string payload, TaskOptions options = null) 16 | { 17 | CodeName = codeName; 18 | Payload = payload; 19 | 20 | if (options == null) return; 21 | 22 | Timeout = options.Timeout; 23 | Delay = options.Delay; 24 | Priority = options.Priority; 25 | } 26 | 27 | /// 28 | /// The name of the code package to execute. 29 | /// 30 | [JsonProperty("code_name", DefaultValueHandling = DefaultValueHandling.Ignore)] 31 | public string CodeName { get; set; } 32 | 33 | /// 34 | /// The time tasks will stop being queued. Should be a time or datetime. 35 | /// 36 | [JsonProperty("end_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 37 | public DateTime? EndAt { get; set; } 38 | 39 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] 40 | public string Name { get; set; } 41 | 42 | /// 43 | /// A string of data to pass to the code package on execution. 44 | /// 45 | [JsonProperty("payload", DefaultValueHandling = DefaultValueHandling.Ignore)] 46 | public string Payload { get; set; } 47 | 48 | /// 49 | /// The amount of time, in seconds, between runs. 50 | /// By default, the task will only run once. 51 | /// run_every will return a 400 error if it is set to less than 60. 52 | /// 53 | [JsonProperty("run_every", DefaultValueHandling = DefaultValueHandling.Ignore)] 54 | public int? RunEvery { get; set; } 55 | 56 | /// 57 | /// The number of times a task will run. 58 | /// 59 | [JsonProperty("run_times", DefaultValueHandling = DefaultValueHandling.Ignore)] 60 | public int? RunTimes { get; set; } 61 | 62 | /// 63 | /// The time the scheduled task should first be run. 64 | /// 65 | [JsonProperty("start_at", DefaultValueHandling = DefaultValueHandling.Ignore)] 66 | public DateTime? StartAt { get; set; } 67 | } 68 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskPayloadCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading; 3 | using IronSharp.Core; 4 | using Newtonsoft.Json; 5 | 6 | namespace IronSharp.IronWorker 7 | { 8 | public class TaskPayloadCollection : IInspectable 9 | { 10 | private List _schedules; 11 | 12 | public TaskPayloadCollection(TaskPayload payload) 13 | { 14 | Tasks.Add(payload); 15 | } 16 | 17 | public TaskPayloadCollection(IEnumerable payloads) 18 | { 19 | Tasks.AddRange(payloads); 20 | } 21 | 22 | public TaskPayloadCollection(string codeName, string payload, TaskOptions options = null) 23 | { 24 | Tasks.Add(new TaskPayload(codeName, payload, options)); 25 | } 26 | 27 | public TaskPayloadCollection(string codeName, IEnumerable payloads, TaskOptions options = null) 28 | { 29 | foreach (string payload in payloads) 30 | { 31 | Tasks.Add(new TaskPayload(codeName, payload, options)); 32 | } 33 | } 34 | 35 | [JsonProperty("tasks")] 36 | public List Tasks 37 | { 38 | get { return LazyInitializer.EnsureInitialized(ref _schedules); } 39 | set { _schedules = value; } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskProgress.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class TaskProgress : IMsg, IInspectable 7 | { 8 | /// 9 | /// An integer, between 0 and 100 inclusive, that describes the completion of the task. 10 | /// 11 | [JsonProperty("percent", DefaultValueHandling = DefaultValueHandling.Ignore)] 12 | public int? Percent { get; set; } 13 | 14 | /// 15 | /// Any message or data describing the completion of the task. Must be a string value, and the 64KB request limit applies. 16 | /// 17 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string Message { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/Tasks/TaskWebhookResponse.cs: -------------------------------------------------------------------------------- 1 | using IronSharp.Core; 2 | using Newtonsoft.Json; 3 | 4 | namespace IronSharp.IronWorker 5 | { 6 | public class TaskWebhookResponse : IMsg, IInspectable 7 | { 8 | [JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)] 9 | public string Id { get; set; } 10 | 11 | [JsonIgnore] 12 | public bool Success 13 | { 14 | get { return this.HasExpectedMessage("Queued up."); } 15 | } 16 | 17 | [JsonProperty("msg", DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string Message { get; set; } 19 | 20 | public static implicit operator bool(TaskWebhookResponse collection) 21 | { 22 | return collection.Success; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/IronSharp.IronWorker/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/IronSharp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.Core", "IronSharp.Core\IronSharp.Core.csproj", "{1A6CC922-40A5-440A-868D-757FCDB08622}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.IronMQ", "IronSharp.IronMQ\IronSharp.IronMQ.csproj", "{D891A220-AA6F-4D0C-B012-B25875787BA0}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.IronWorker", "IronSharp.IronWorker\IronSharp.IronWorker.csproj", "{4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.IronCache", "IronSharp.IronCache\IronSharp.IronCache.csproj", "{2603E861-09AB-482E-BF28-41D8B0B1B20B}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.Extras.ServiceStackSerializers", "IronSharp.Extras.ServiceStackSerializers\IronSharp.Extras.ServiceStackSerializers.csproj", "{51A944C8-8A3D-4AB6-A475-6B2C204CD823}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.IronSharp", "Demo.IronSharp\Demo.IronSharp.csproj", "{4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}" 17 | EndProject 18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{01B8724C-95A0-4B03-AE87-1BAAAA3AA2F1}" 19 | EndProject 20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extras", "Extras", "{C8778C67-3748-47F8-AEAB-B33D8E6B9D55}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronSharp.Extras.ProtoBufSerializers", "IronSharp.Extras.ProtoBufSerializers\IronSharp.Extras.ProtoBufSerializers.csproj", "{40DF09EE-FD18-4BCA-9A61-898044477F7E}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Any CPU = Debug|Any CPU 27 | Publish|Any CPU = Publish|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Publish|Any CPU.ActiveCfg = Publish|Any CPU 34 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Publish|Any CPU.Build.0 = Publish|Any CPU 35 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {1A6CC922-40A5-440A-868D-757FCDB08622}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Publish|Any CPU.ActiveCfg = Publish|Any CPU 40 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Publish|Any CPU.Build.0 = Publish|Any CPU 41 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {D891A220-AA6F-4D0C-B012-B25875787BA0}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Publish|Any CPU.ActiveCfg = Publish|Any CPU 46 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Publish|Any CPU.Build.0 = Publish|Any CPU 47 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Release|Any CPU.ActiveCfg = Release|Any CPU 48 | {4FA5BF5D-C543-404E-89EC-C3BFF90ACF6B}.Release|Any CPU.Build.0 = Release|Any CPU 49 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Publish|Any CPU.ActiveCfg = Publish|Any CPU 52 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Publish|Any CPU.Build.0 = Publish|Any CPU 53 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {2603E861-09AB-482E-BF28-41D8B0B1B20B}.Release|Any CPU.Build.0 = Release|Any CPU 55 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 56 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Debug|Any CPU.Build.0 = Debug|Any CPU 57 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Publish|Any CPU.ActiveCfg = Release|Any CPU 58 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Publish|Any CPU.Build.0 = Release|Any CPU 59 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Release|Any CPU.ActiveCfg = Release|Any CPU 60 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823}.Release|Any CPU.Build.0 = Release|Any CPU 61 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 62 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Debug|Any CPU.Build.0 = Debug|Any CPU 63 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Publish|Any CPU.ActiveCfg = Release|Any CPU 64 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Publish|Any CPU.Build.0 = Release|Any CPU 65 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Release|Any CPU.ActiveCfg = Release|Any CPU 66 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B}.Release|Any CPU.Build.0 = Release|Any CPU 67 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 68 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Debug|Any CPU.Build.0 = Debug|Any CPU 69 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Publish|Any CPU.ActiveCfg = Release|Any CPU 70 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Publish|Any CPU.Build.0 = Release|Any CPU 71 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Release|Any CPU.ActiveCfg = Release|Any CPU 72 | {40DF09EE-FD18-4BCA-9A61-898044477F7E}.Release|Any CPU.Build.0 = Release|Any CPU 73 | EndGlobalSection 74 | GlobalSection(SolutionProperties) = preSolution 75 | HideSolutionNode = FALSE 76 | EndGlobalSection 77 | GlobalSection(NestedProjects) = preSolution 78 | {51A944C8-8A3D-4AB6-A475-6B2C204CD823} = {C8778C67-3748-47F8-AEAB-B33D8E6B9D55} 79 | {40DF09EE-FD18-4BCA-9A61-898044477F7E} = {C8778C67-3748-47F8-AEAB-B33D8E6B9D55} 80 | {4EFB32B2-4CD3-4604-9ADC-458A4FC4C50B} = {01B8724C-95A0-4B03-AE87-1BAAAA3AA2F1} 81 | EndGlobalSection 82 | EndGlobal 83 | -------------------------------------------------------------------------------- /src/IronSharp.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | False 3 | True 4 | JSON 5 | MQ 6 | <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> -------------------------------------------------------------------------------- /src/SolutionInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyConfiguration("")] 4 | [assembly: AssemblyCompany("grcodemonkey")] 5 | 6 | [assembly: AssemblyCopyright("")] 7 | [assembly: AssemblyTrademark("")] 8 | [assembly: AssemblyCulture("")] 9 | 10 | [assembly: AssemblyVersion("2013.11.02.0")] 11 | [assembly: AssemblyFileVersion("2013.11.02.0")] --------------------------------------------------------------------------------