void GetRemoteDescription()
        {
            string address = Path;

            if (!PathIsAppServer)
            {
                if (_pathAsComponentGuid != Guid.Empty)
                {
                    // path provided is a guid to a component
                    address = LocalServer.GetDescriptionUrl(_pathAsComponentGuid);
                }
                else
                {
                    if (!System.IO.File.Exists(address))
                    {
                        return; // file no longer there...
                    }
                    address = LocalServer.GetDescriptionUrl(Path);
                }
            }
            using (var client = new System.Net.WebClient())
            {
                string s = client.DownloadString(address);
                var    responseSchema = JsonConvert.DeserializeObject <Resthopper.IO.IoResponseSchema>(s);
                _description  = responseSchema.Description;
                _inputParams  = new Dictionary <string, Tuple <InputParamSchema, IGH_Param> >();
                _outputParams = new Dictionary <string, IGH_Param>();
                foreach (var input in responseSchema.Inputs)
                {
                    string inputParamName = input.Name;
                    if (inputParamName.StartsWith("RH_IN:"))
                    {
                        var chunks = inputParamName.Split(new char[] { ':' });
                        inputParamName = chunks[chunks.Length - 1];
                    }
                    _inputParams[inputParamName] = Tuple.Create(input, ParamFromIoResponseSchema(input));
                }
                foreach (var output in responseSchema.Outputs)
                {
                    string outputParamName = output.Name;
                    if (outputParamName.StartsWith("RH_OUT:"))
                    {
                        var chunks = outputParamName.Split(new char[] { ':' });
                        outputParamName = chunks[chunks.Length - 1];
                    }
                    _outputParams[outputParamName] = ParamFromIoResponseSchema(output);
                }
            }
        }
예제 #2
0
        public Schema PostToServer(string inputJson)
        {
            string solveUrl = "";

            if (PathIsAppServer)
            {
                int index = Path.LastIndexOf('/');
                solveUrl = Path.Substring(0, index + 1) + "solve";
            }
            else
            {
                solveUrl = LocalServer.GetSolveUrl();
            }

            var content          = new System.Net.Http.StringContent(inputJson, Encoding.UTF8, "application/json");
            var postTask         = HttpClient.PostAsync(solveUrl, content);
            var responseMessage  = postTask.Result;
            var remoteSolvedData = responseMessage.Content;
            var stringResult     = remoteSolvedData.ReadAsStringAsync().Result;
            var schema           = JsonConvert.DeserializeObject <Resthopper.IO.Schema>(stringResult);

            return(schema);
        }
예제 #3
0
        void GetRemoteDescription()
        {
            string address = Path;

            if (!PathIsAppServer)
            {
                address = LocalServer.GetDescriptionUrl(Path);
            }
            using (var client = new System.Net.WebClient())
            {
                string s = client.DownloadString(address);
                var    responseSchema = JsonConvert.DeserializeObject <Resthopper.IO.IoResponseSchema>(s);
                _description  = responseSchema.Description;
                _inputParams  = new Dictionary <string, Tuple <InputParamSchema, IGH_Param> >();
                _outputParams = new Dictionary <string, IGH_Param>();
                foreach (var input in responseSchema.Inputs)
                {
                    string inputParamName = input.Name;
                    if (inputParamName.StartsWith("RH_IN:"))
                    {
                        var chunks = inputParamName.Split(new char[] { ':' });
                        inputParamName = chunks[chunks.Length - 1];
                    }
                    _inputParams[inputParamName] = Tuple.Create(input, ParamFromIoResponseSchema(input));
                }
                foreach (var output in responseSchema.Outputs)
                {
                    string outputParamName = output.Name;
                    if (outputParamName.StartsWith("RH_OUT:"))
                    {
                        var chunks = outputParamName.Split(new char[] { ':' });
                        outputParamName = chunks[chunks.Length - 1];
                    }
                    _outputParams[outputParamName] = ParamFromIoResponseSchema(output);
                }
            }
        }