コード例 #1
0
        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
        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);
                }
            }
        }