-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from enmerk4r/dev-0-1-8
Dev 0.1.8
- Loading branch information
Showing
38 changed files
with
5,386 additions
and
3,399 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.UI.WebControls; | ||
using Grasshopper.Kernel; | ||
using Rhino.Geometry; | ||
using Swiftlet.DataModels.Implementations; | ||
using Swiftlet.Goo; | ||
using Swiftlet.Params; | ||
using Swiftlet.Util; | ||
|
||
namespace Swiftlet.Components | ||
{ | ||
public class CreateUrl : GH_Component | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the DeconstructHttpResponse class. | ||
/// </summary> | ||
public CreateUrl() | ||
: base("Create URL", "CURL", | ||
"Construct a URL from its constituent parts", | ||
NamingUtility.CATEGORY, NamingUtility.REQUEST) | ||
{ | ||
} | ||
|
||
public override GH_Exposure Exposure => GH_Exposure.primary; | ||
/// <summary> | ||
/// Registers all the input parameters for this component. | ||
/// </summary> | ||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddTextParameter("Scheme", "S", "URL scheme (http or https)", GH_ParamAccess.item); | ||
pManager.AddTextParameter("Host", "H", "Host component of the URL", GH_ParamAccess.item); | ||
pManager.AddIntegerParameter("Port", "P", "TCP port number", GH_ParamAccess.item); | ||
pManager.AddTextParameter("Route", "R", "A route (path) to an online resource", GH_ParamAccess.item); | ||
|
||
pManager[2].Optional = true; | ||
pManager[3].Optional = true; | ||
} | ||
|
||
/// <summary> | ||
/// Registers all the output parameters for this component. | ||
/// </summary> | ||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddTextParameter("URL", "U", "Constructed URL string", GH_ParamAccess.item); | ||
} | ||
|
||
/// <summary> | ||
/// This is the method that actually does the work. | ||
/// </summary> | ||
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> | ||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
string scheme = string.Empty; | ||
string host = string.Empty; | ||
int port = -1; | ||
string route = string.Empty; | ||
|
||
|
||
DA.GetData(0, ref scheme); | ||
DA.GetData(1, ref host); | ||
DA.GetData(2, ref port); | ||
DA.GetData(3, ref route); | ||
|
||
UriBuilder builder = new UriBuilder(); | ||
builder.Scheme = scheme; | ||
builder.Host = host; | ||
|
||
if (port > 0) builder.Port = port; | ||
|
||
|
||
if (!string.IsNullOrEmpty(route)) | ||
{ | ||
builder.Path = route; | ||
} | ||
|
||
DA.SetData(0, builder.ToString()); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Provides an Icon for the component. | ||
/// </summary> | ||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
//You can add image files to your project resources and access them like this: | ||
// return Resources.IconForThisComponent; | ||
return Properties.Resources.Icons_construct_url_24x24; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the unique ID for this component. Do not change this ID after release. | ||
/// </summary> | ||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("104e0b1e-9954-475c-8046-a7259a8967f5"); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Linq; | ||
using System.Web; | ||
using Grasshopper.Kernel; | ||
using Rhino.Geometry; | ||
using Swiftlet.DataModels.Implementations; | ||
using Swiftlet.Goo; | ||
using Swiftlet.Params; | ||
using Swiftlet.Util; | ||
|
||
namespace Swiftlet.Components | ||
{ | ||
public class DeconstructUrl : GH_Component | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the DeconstructHttpResponse class. | ||
/// </summary> | ||
public DeconstructUrl() | ||
: base("Deconstruct URL", "DURL", | ||
"Deconstruct a URL into its constituent parts", | ||
NamingUtility.CATEGORY, NamingUtility.SEND) | ||
{ | ||
} | ||
|
||
public override GH_Exposure Exposure => GH_Exposure.tertiary; | ||
/// <summary> | ||
/// Registers all the input parameters for this component. | ||
/// </summary> | ||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddTextParameter("URL", "U", "A URL string to be deconstructed", GH_ParamAccess.item); | ||
} | ||
|
||
/// <summary> | ||
/// Registers all the output parameters for this component. | ||
/// </summary> | ||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddTextParameter("Base", "B", "Base URL", GH_ParamAccess.item); | ||
pManager.AddTextParameter("Scheme", "S", "URL scheme (http or https)", GH_ParamAccess.item); | ||
pManager.AddTextParameter("Host", "H", "Host component of the URL", GH_ParamAccess.item); | ||
pManager.AddTextParameter("Route", "R", "A route (path) to the online resource", GH_ParamAccess.item); | ||
pManager.AddParameter(new QueryParamParam(), "Params", "P", "Http Query Parameters", GH_ParamAccess.list); | ||
|
||
|
||
} | ||
|
||
/// <summary> | ||
/// This is the method that actually does the work. | ||
/// </summary> | ||
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> | ||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
string url = string.Empty; | ||
DA.GetData(0, ref url); | ||
|
||
if (!url.StartsWith("http")) throw new Exception(" A valid URL must include a scheme (http or https)"); | ||
|
||
Uri myUri = new Uri(url); | ||
NameValueCollection parameters = HttpUtility.ParseQueryString(myUri.Query); | ||
|
||
List<QueryParamGoo> paramGoo = new List<QueryParamGoo>(); | ||
|
||
string baseUri = url.Split('?').First(); | ||
|
||
foreach (string key in parameters.AllKeys) | ||
{ | ||
string value = parameters.Get(key); | ||
paramGoo.Add(new QueryParamGoo(key, value)); | ||
} | ||
|
||
DA.SetData(0, baseUri); | ||
DA.SetData(1, myUri.Scheme); | ||
DA.SetData(2, myUri.Host); | ||
DA.SetData(3, myUri.AbsolutePath); | ||
DA.SetDataList(4, paramGoo); | ||
|
||
} | ||
|
||
|
||
/// <summary> | ||
/// Provides an Icon for the component. | ||
/// </summary> | ||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
//You can add image files to your project resources and access them like this: | ||
// return Resources.IconForThisComponent; | ||
return Properties.Resources.Icons_deconstruct_url_24x24; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the unique ID for this component. Do not change this ID after release. | ||
/// </summary> | ||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("6240a6fa-f6fa-47af-a796-0a2fc3dd6cc1"); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Grasshopper.Kernel; | ||
using Rhino.Geometry; | ||
using Swiftlet.Goo; | ||
using Swiftlet.Params; | ||
using Swiftlet.Util; | ||
|
||
namespace Swiftlet.Components | ||
{ | ||
public class ByteArrayToList : GH_Component | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the TextToByteArray class. | ||
/// </summary> | ||
public ByteArrayToList() | ||
: base("Byte Array To List", "BAL", | ||
"Converts a byte array into a list of integers", | ||
NamingUtility.CATEGORY, NamingUtility.UTILITIES) | ||
{ | ||
} | ||
|
||
public override GH_Exposure Exposure => GH_Exposure.quarternary; | ||
|
||
/// <summary> | ||
/// Registers all the input parameters for this component. | ||
/// </summary> | ||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddParameter(new ByteArrayParam(), "Byte Array", "A", "Byte Array to convert", GH_ParamAccess.item); | ||
} | ||
|
||
/// <summary> | ||
/// Registers all the output parameters for this component. | ||
/// </summary> | ||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddIntegerParameter("Bytes", "B", "Byte Array as a list of integers", GH_ParamAccess.list); | ||
} | ||
|
||
/// <summary> | ||
/// This is the method that actually does the work. | ||
/// </summary> | ||
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> | ||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
ByteArrayGoo goo = null; | ||
DA.GetData(0, ref goo); | ||
|
||
DA.SetDataList(0, goo.Value.Select(b => ((int)b)).ToList()); | ||
} | ||
|
||
/// <summary> | ||
/// Provides an Icon for the component. | ||
/// </summary> | ||
protected override System.Drawing.Bitmap Icon | ||
{ | ||
get | ||
{ | ||
//You can add image files to your project resources and access them like this: | ||
// return Resources.IconForThisComponent; | ||
return Properties.Resources.Icons_byte_array_to_list_24x24; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the unique ID for this component. Do not change this ID after release. | ||
/// </summary> | ||
public override Guid ComponentGuid | ||
{ | ||
get { return new Guid("60e16712-a6aa-4e02-860a-d587b512320c"); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.