Nx 2.4.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Nx --version 2.4.1.3                
NuGet\Install-Package Nx -Version 2.4.1.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nx" Version="2.4.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nx --version 2.4.1.3                
#r "nuget: Nx, 2.4.1.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nx as a Cake Addin
#addin nuget:?package=Nx&version=2.4.1.3

// Install Nx as a Cake Tool
#tool nuget:?package=Nx&version=2.4.1.3                

A .Net Helper Library For Rapid Development.Give You A Easy Way Send Http Request

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Nx:

Package Downloads
Nx.DBUtility

A db util for easy sql query

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.8.0 1,671 3/10/2015
2.4.1.6 1,548 12/19/2014
2.4.1.5 1,516 12/19/2014
2.4.1.3 1,747 12/16/2014
2.4.1.2 1,359 12/15/2014
2.4.1.1 1,331 12/12/2014
2.4.1 1,577 12/12/2014
2.3.1.1 1,325 11/17/2014
2.3.1 1,937 11/16/2014
2.2.1.8 1,107 10/28/2014
2.2.1.5 1,106 10/21/2014
2.2.1.4 1,147 10/21/2014
2.2.1.3 1,082 10/14/2014
2.2.1.2 1,163 10/14/2014
2.2.1.1 1,125 10/14/2014
2.2.1 1,136 10/14/2014
2.1.0.2 1,333 9/29/2014

0x01:Simulation of the HTTP request ======================================
     
     var ctxIn = RequestBuilder.Create("default")
         .SetUrl("http://sample.com/api/sendmsg")
         .SetUserAgent("Nx Framework 2.4.1.0")
         .SetReferer("http://sample.com/api/login")
         .SetProxy(new WebProxy("127.0.0.1:8888")) //or .SetProxy(new WebProxy("127.0.0.1:8888",enable:true))
         .WithCookie("name=value") //or .WithCookies(List<Cookie> cookies) and so on.
         .AllowAutoRedirect(true)
         .SetHttpMethod("POST")
         .WithHeader("X-Token","x9v4d-d043b")
         .WithTextInput("user","tiny")
         .WithFileInput("file1","D:\a.txt")
         .WithBytesInput("file2",new byte[]{0x00,0x03,0x00,0x7f})
         .SetTimeout(3000)
         .UsingAjax()
         .DisableProxy() //or .EnableProxy()
         .Build();
         
     var ctxIn = RequestManager.GetResponse(ctxIn);
     if(ctxIn.Exception==null)
     {
         //if html, we have a nice intergration from Ivony's code(Jumony.Core) builtin.
         var document = respCtx.ResponseDocument;//get IHtmlDocument object.

         //Filter elements like JQUERY using the extensions from Ivony
         var theElements = document.AllElements().Find(".pager");
         
         //LINQ then
         //var matchedElemList = theElements.Where(...).ToList();
         
         //Get text directly
         var text = ctxIn.Text;
         
         //The stream, and other useful properties of IResponseContext
         var ms = ctxIn.Stream;
     }
     
     0x02:Read Text Based File EASY And FAST.====================================
     
     var file = new Nx.IO.TextFileInfo("d:\\d.txt");

     //random row
     while(true)
     {
         Console.WriteLine(file.RandomRow.Text);
     }

     //row items
     foreach(var item in file.RowItems)
     {
         //useful properties:
         
         //item.RowIndex
         //item.Text
         //item.IsEmptyLine
         //item.DataLength
     }

     0x03:ThreadSafeRandom =============================================
     
       see class Nx.ThreadSafeRandom
       
       
     0x04:Extensions
     The usage is [using Nx.Extensions;]
     Provide some extension method for:
     Array
     Compression
     Cookie
     MD5
     Stream
     Time
     Uri
     ...
     For Details, see the reflection tree under Nx.Extension namespace of Nx under the VisualStudio Assembly References folder of vs project after install nx from nuget or you added reference manually.
     
     0x05:dynamicjson project of https://dynamicjson.codeplex.com/
     Read and Access// Parse (from JsonString to DynamicJson)
     var json = DynamicJson.Parse(@"{""foo"":""json"", ""bar"":100, ""nest"":{ ""foobar"":true } }");

     var r1 = json.foo; // "json" - dynamic(string)
     var r2 = json.bar; // 100 - dynamic(double)
     var r3 = json.nest.foobar; // true - dynamic(bool)
     var r4 = json["nest"]["foobar"]; // can access indexer
     Operatevar json = DynamicJson.Parse(@"{""foo"":""json"", ""bar"":100, ""nest"":{ ""foobar"":true } }");

     // Check Defined Peroperty
     // .name() is shortcut of IsDefined("name")
     var b1_1 = json.IsDefined("foo"); // true
     var b2_1 = json.IsDefined("foooo"); // false
     var b1_2 = json.foo(); // true            
     var b2_2 = json.foooo(); // false;

     // Add
     json.Arr = new string[] { "NOR", "XOR" }; // Add Array
     json.Obj1 = new { }; // Add Object
     json.Obj2 = new { foo = "abc", bar = 100 }; // Add and Init

     // Delete
     // ("name") is shortcut of Delete("name")
     json.Delete("foo");
     json.Arr.Delete(0);
     json("bar");
     json.Arr(1);

     // Replace
     json.Obj1 = 5000;

     // Create New JsonObject
     dynamic newjson = new DynamicJson();
     newjson.str = "aaa";
     newjson.obj = new { foo = "bar" };

     // Serialize(to JSON String)
     var jsonstring = newjson.ToString(); // {"str":"aaa","obj":{"foo":"bar"}}
     Enumerate// DynamicJson - (IsArray)
     var arrayJson = DynamicJson.Parse(@"[1,10,200,300]");
     foreach (int item in arrayJson)
     {
         Console.WriteLine(item); // 1, 10, 200, 300
     }

     // DynamicJson - (IsObject)
     var objectJson = DynamicJson.Parse(@"{""foo"":""json"",""bar"":100}");
     foreach (KeyValuePair<string, dynamic> item in objectJson)
     {
         Console.WriteLine(item.Key + ":" + item.Value); // foo:json, bar:100
     }
     Convert/Deserialize
     public class FooBar
     {
         public string foo { get; set; }
         public int bar { get; set; }
     }

     var arrayJson = DynamicJson.Parse(@"[1,10,200,300]");
     var objectJson = DynamicJson.Parse(@"{""foo"":""json"",""bar"":100}");

     // (type) is shortcut of Deserialize<type>()
     var array1 = arrayJson.Deserialize<int[]>();
     var array2 = (int[])arrayJson; // equals array1
     int[] array3 = arrayJson; // equals array2

     // mapping by public property name
     var foobar1 = objectJson.Deserialize<FooBar>();
     var foobar2 = (FooBar)objectJson;
     FooBar foobar3 = objectJson;

     // with linq
     var objectJsonList = DynamicJson.Parse(@"[{""bar"":50},{""bar"":100}]");
     var barSum = ((FooBar[])objectJsonList).Select(fb => fb.bar).Sum(); // 150
     var dynamicWithLinq = ((dynamic[])objectJsonList).Select(d => d.bar);
     Serialize (to JSON String from Object)// Serialize (from Object to JsonString)
     var obj = new
     {
         Name = "Foo",
         Age = 30,
         Address = new
         {
             Country = "Japan",
             City = "Tokyo"
         },
         Like = new[] { "Microsoft", "Xbox" }
     };
     // {"Name":"Foo","Age":30,"Address":{"Country":"Japan","City":"Tokyo"},"Like":["Microsoft","Xbox"]}
     var jsonStringFromObj = DynamicJson.Serialize(obj);

     // [{"foo":"fooooo!","bar":1000},{"foo":"orz","bar":10}]
     var foobar = new FooBar[] {
             new FooBar { foo = "fooooo!", bar = 1000 },
             new FooBar { foo = "orz", bar = 10 } };
     var jsonFoobar = DynamicJson.Serialize(foobar);
     Notice: corner casevar nestJson = DynamicJson.Parse(@"{""tes"":10,""nest"":{""a"":0}");

     nestJson.nest(); // This equals json.IsDefined("nest")
     nestJson.nest("a"); // This equals json.nest.Delete("a")

     // if name is C#'s reserved word then put prefix "@"
     var json = DynamicJson.Parse(@"{""int"":10,""event"":null}");
     var r1 = json.@int; // 10.0
     var r2 = json.@event; // null
     Example : TwitterAPIstatic void Main()
     {
         var publicTL = new WebClient().DownloadString(@"http://twitter.com/statuses/public_timeline.json");
         var statuses = DynamicJson.Parse(publicTL);
         foreach (var status in statuses)
         {
             Console.WriteLine(status.user.screen_name);
             Console.WriteLine(status.text);
         }
     }
     Example : TwitterAPI2static void Main(string[] args)
     {
         // fetch and flatten user_timeline
         var wc = new WebClient();
         var statuses = Enumerable.Range(1, 5)
             .Select(i =>
                 wc.DownloadString("http://twitter.com/statuses/user_timeline/neuecc.json?page=" + i))
             .SelectMany(s => (dynamic[])DynamicJson.Parse(s))
             .OrderBy(j => j.id);

         foreach (var status in statuses)
         {
             Console.WriteLine(status.text);
         }
     }

     
     PS:
     I'm considering put this project on github someday.
     For this time, any suggestions or bugs can be submited by sending email to me(tiny@sandsea.info).
     
     [Updated at 2014.12.12 utc+8 (Beijing time)]
     

     UPDATE LOGS
     2.4.1.3
     Intergrate the DynamicJson class under Nx.Data namespace, see the project page:https://dynamicjson.codeplex.com/ for more details or usage

     2.4.1.2
     * Add some http header setting method for Nx.Net.RequestBuilder:
     * Add [Accept] with [SetAccept(string)]
     * Add [Host] with [SetHost(string)]
     * Use AutoSetHost() to set the host from url.If url is http://www.baidu.com/index.php, then the host will be set to www.baidu.com
     * Set KeepAlive to false as default for HttpWebReqeust
     * Add Dispose() method for IResponseContext to manual dispose http connection resources.
     * Add [TransferEncoding] with [SetTransferEncoding(string)]
     * At this version, method Nx.Net.RequestBuilder.SetProxy(WebProxy) will also enable the proxy(previous versions have not do that.)

     Fixed bugs on decompress gzip stream from http response.
     2.4.1.1
     Fix bug on determine if a request is multipart-form when build requst context

     2.4.1.0
     Many Bugs Fixed.
     With Ivony Html Extension Builtin.Thanks Ivony's code(Jumony.Core)
     Add Chaos.NaCl's cryto class

     2.3.0.0
     add support http post file using RequestBuilder.WithFileInput.
     the RequestBuilder.WithFormData changes to RequestBuilder.WithTextInput

     2.2.1.5
     fixed bug in Nx.TimeUtil.GetTimestamp()

     2.2.1.4
     small bug fix.

     2.2.1.3
     Add "HttpMethod PUT" support for the core request utils.

     2.2.1.2
     fix the bug that the post data does not submitted after use Nx.Net.RequestBuilder.SetHttpMethod("POST")