コード例 #1
0
        /// <summary>
        /// Creates a new environment. You can only create one environment per service instance.An attempt to create another environment
        /// will result in an error. The size of the new environment can be controlled by specifying the size parameter.
        /// </summary>
        /// <param name="callback">The OnAnalyze callback.</param>
        /// <param name="parameters">The analyze parameters.</param>
        /// <param name="customData">Optional custom data.</param>
        /// <returns>True if the call succeeds, false if the call is unsuccessful.</returns>
        public bool Analyze(OnAnalyze callback, Parameters parameters, string customData = default(string))
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            AnalyzeRequest req = new AnalyzeRequest();

            req.Callback                = callback;
            req._Parameters             = parameters;
            req.Data                    = customData;
            req.OnResponse              = OnAnalyzeResponse;
            req.Headers["Content-Type"] = "application/json";
            req.Headers["Accept"]       = "application/json";
            req.Parameters["version"]   = NaturalLanguageUnderstandingVersion.Version;

            fsData   data     = null;
            fsResult r        = sm_Serializer.TrySerialize(parameters, out data);
            string   sendjson = data.ToString();

            req.Send = Encoding.UTF8.GetBytes(sendjson);
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_ANALYZE);

            if (connector == null)
            {
                return(false);
            }

            return(connector.Send(req));
        }
コード例 #2
0
 public void Check(OnAnalyze checker)
 {
     onAnalyzes.Add(checker);
 }
コード例 #3
0
 public void Analyze()
 {
     OnAnalyze?.Invoke(this, EventArgs.Empty);
 }