private void buttondown_Click(object sender, EventArgs e) { int val = Convert.ToUInt16(textBox_current.Text); val -= 10; textBox_current.Text = val.ToString(); UpdateValue?.Invoke(textBox_current.Text); }
void LateUpdate() { thisFrameUpdate = UpdateValue.None; if (nextFrameUpdate != UpdateValue.None) { thisFrameUpdate = nextFrameUpdate; nextFrameUpdate = UpdateValue.None; } }
/// <summary> /// /// </summary> public BaseField() { m_UpdateValues = new UpdateValue[this.ObjectUpdateFieldCount]; m_PrivateUpdateMask = new UpdateMask( this.ObjectUpdateFieldCount ); m_PublicUpdateMask = new UpdateMask( this.ObjectUpdateFieldCount ); this.Type = ObjectTypes.Object; this.ScaleX = 1.0f; }
/// <summary> /// /// </summary> public BaseField() { m_UpdateValues = new UpdateValue[this.ObjectUpdateFieldCount]; m_PrivateUpdateMask = new UpdateMask(this.ObjectUpdateFieldCount); m_PublicUpdateMask = new UpdateMask(this.ObjectUpdateFieldCount); this.Type = ObjectTypes.Object; this.ScaleX = 1.0f; }
public Value AtualizarVEntidade(String WorkId, String Entidade, String Valor, String NValor) { UpdateValue updatedValue = new UpdateValue() { Value = NValor }; var result = _assistant.UpdateValue(WorkId, Entidade, Valor, updatedValue); return(result); }
private void button2_Click(object sender, EventArgs e) { newvalue = textBox_current.Text; try { UpdateValue?.Invoke(textBox_current.Text); } catch (Exception ex) { } }
public void ResetValue() { if (_value > _bestValue) { _bestValue = _value; //save best UpdateBestValue?.Invoke("BEST: " + _bestValue); PlayerPrefs.SetInt("best", _bestValue); } _value = 0; UpdateValue?.Invoke(_value); }
public Value UpdateValue(string workspaceId, string entity, string value, UpdateValue body) { try { var result = AssistantRepository.UpdateValue(workspaceId, entity, value, body); return(result); } catch (Exception ex) { Logger.Error("AssistantService.UpdateValue failed", this, ex); } return(null); }
//Scroll Rect Updates ScrollBar public void UpdateScrollbar(Vector2 normalizedPosition) { switch (thisFrameUpdate) { case UpdateValue.None: case UpdateValue.ScrollBar: thisFrameUpdate = UpdateValue.ScrollBar; break; default: return; } ForceUpdateScrollBar(normalizedPosition); }
public void OnAddValue(int count) { int add = count * _price; CreateText("+" + add, _positionScore, 45, _scoreAddColor); if (count >= 4) { if (Random.Range(0, 100) > 50) { CreateText(_complimentText[Random.Range(0, _complimentText.Length)], _positionCompliment, 25, _complimentColor); } } _value += add; UpdateValue?.Invoke(_value); }
private void FactorsThread() { ArrayList val = threadMethods.CalculateFactors(200); StringBuilder sb = new StringBuilder(); for (int count = 0; count <= val.Count - 1; count++) { sb.Append((string)val[count]); if (count < val.Count - 1) { sb.Append(","); } } UpdateValue updVal = new UpdateValue(DisplayValue); string[] Args = { sb.ToString() }; Invoke(updVal, Args); }
//ScrollBar Updates ScrollRect public void UpdateScrollRect(float value) { switch (thisFrameUpdate) { case UpdateValue.None: case UpdateValue.ScrollRect: thisFrameUpdate = UpdateValue.ScrollRect; break; default: return; } if (m_scrollRect.horizontal) { m_scrollRect.normalizedPosition = new Vector2(value, m_scrollRect.normalizedPosition.y); } else if (m_scrollRect.vertical) { m_scrollRect.normalizedPosition = new Vector2(m_scrollRect.normalizedPosition.x, value); } }
private void UpdateValue() { string updatedValue = _createdValue + "-updated"; Console.WriteLine(string.Format("\nCalling UpdateValue({0}, {1}, {2}, {3})...", _createdWorkspaceId, _createdEntity, _createdValue, updatedValue)); UpdateValue value = new UpdateValue() { Value = updatedValue }; var result = _conversation.UpdateValue(_createdWorkspaceId, _createdEntity, _createdValue, value); if (result != null) { Console.WriteLine(string.Format("value: {0}", result.ValueText)); _createdValue = updatedValue; } else { Console.WriteLine("Result is null."); } }
private static void CheckUpdate(UpdateValue val) { if (val == UpdateValue.Failed) { PrintToConsole("Update Failed", ConsoleColor.Red); } if (val == UpdateValue.Updated) { PrintToConsole("Finishing Update", ConsoleColor.Yellow); var applicationPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath)); var files = Directory.GetFiles(applicationPath, "PlexRequests.*", SearchOption.TopDirectoryOnly); var oldUpdater = files.FirstOrDefault(x => x == $"{applicationPath}\\PlexRequests.Updater.exe"); var newUpdater = files.FirstOrDefault(x => x == $"{applicationPath}\\PlexRequests.Updater.exe_Updated"); if (oldUpdater == null || newUpdater == null) { PrintToConsole("Looks like there was nothing to update.", ConsoleColor.Yellow); return; } try { File.Copy(oldUpdater, "PlexRequests.Updater.exe_Old", true); File.Delete(oldUpdater); File.Copy(newUpdater, "PlexRequests.Updater.exe", true); File.Delete(newUpdater); File.Delete("PlexRequests.Updater.exe_Old"); // Cleanup } catch (Exception e) { Console.WriteLine(e.Message); } PrintToConsole("Finished Update!", ConsoleColor.Yellow); } }
private ImmutableDictionary <K, V> ResolveConflicts(K key, V value, UpdateValue updateValue) { if (ReferenceEquals(_key, key) || _key.Equals(key)) { return(new ImmutableDictionary <K, V>(_hashCode, key, updateValue(_value, value), _conflicts, _leftChild, _rightChild)); } if (_conflicts == null) { return(new ImmutableDictionary <K, V>(_hashCode, _key, _value, new[] { new KV <K, V>(key, value) }, _leftChild, _rightChild)); } var i = _conflicts.Length - 1; while (i >= 0 && !Equals(_conflicts[i].Key, _key)) { i--; } var conflicts = new KV <K, V> [i != -1 ? _conflicts.Length: _conflicts.Length + 1]; Array.Copy(_conflicts, 0, conflicts, 0, _conflicts.Length); conflicts[i != -1 ? i : _conflicts.Length] = new KV <K, V>(key, i != -1 ? updateValue(_conflicts[i].Value, value) : value); return(new ImmutableDictionary <K, V>(_hashCode, _key, _value, conflicts, _leftChild, _rightChild)); }
private IEnumerator Examples() { // List Workspaces _service.ListWorkspaces(OnListWorkspaces, OnFail); while (!_listWorkspacesTested) { yield return(null); } // Create Workspace CreateWorkspace workspace = new CreateWorkspace() { Name = _createdWorkspaceName, Description = _createdWorkspaceDescription, Language = _createdWorkspaceLanguage, LearningOptOut = true }; _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace); while (!_createWorkspaceTested) { yield return(null); } // Get Workspace _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId); while (!_getWorkspaceTested) { yield return(null); } // Update Workspace UpdateWorkspace updateWorkspace = new UpdateWorkspace() { Name = _createdWorkspaceName + "-updated", Description = _createdWorkspaceDescription + "-updated", Language = _createdWorkspaceLanguage }; _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace); while (!_updateWorkspaceTested) { yield return(null); } // Message Dictionary <string, object> input = new Dictionary <string, object>(); input.Add("text", _inputString); MessageRequest messageRequest = new MessageRequest() { Input = input }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString0; MessageRequest messageRequest0 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest0); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString1; MessageRequest messageRequest1 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest1); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString2; MessageRequest messageRequest2 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest2); while (!_messageTested) { yield return(null); } // List Intents _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId); while (!_listIntentsTested) { yield return(null); } // Create Intent CreateIntent createIntent = new CreateIntent() { Intent = _createdIntent, Description = _createdIntentDescription }; _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent); while (!_createIntentTested) { yield return(null); } // Get Intent _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent); while (!_getIntentTested) { yield return(null); } // Update Intents string updatedIntent = _createdIntent + "-updated"; string updatedIntentDescription = _createdIntentDescription + "-updated"; UpdateIntent updateIntent = new UpdateIntent() { Intent = updatedIntent, Description = updatedIntentDescription }; _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent); while (!_updateIntentTested) { yield return(null); } // List Examples _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent); while (!_listExamplesTested) { yield return(null); } // Create Examples CreateExample createExample = new CreateExample() { Text = _createdExample }; _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample); while (!_createExampleTested) { yield return(null); } // Get Example _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample); while (!_getExampleTested) { yield return(null); } // Update Examples string updatedExample = _createdExample + "-updated"; UpdateExample updateExample = new UpdateExample() { Text = updatedExample }; _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample); while (!_updateExampleTested) { yield return(null); } // List Entities _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId); while (!_listEntitiesTested) { yield return(null); } // Create Entities CreateEntity entity = new CreateEntity() { Entity = _createdEntity, Description = _createdEntityDescription }; _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity); while (!_createEntityTested) { yield return(null); } // Get Entity _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity); while (!_getEntityTested) { yield return(null); } // Update Entities string updatedEntity = _createdEntity + "-updated"; string updatedEntityDescription = _createdEntityDescription + "-updated"; UpdateEntity updateEntity = new UpdateEntity() { Entity = updatedEntity, Description = updatedEntityDescription }; _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity); while (!_updateEntityTested) { yield return(null); } // List Values _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity); while (!_listValuesTested) { yield return(null); } // Create Values CreateValue value = new CreateValue() { Value = _createdValue }; _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value); while (!_createValueTested) { yield return(null); } // Get Value _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue); while (!_getValueTested) { yield return(null); } // Update Values string updatedValue = _createdValue + "-updated"; UpdateValue updateValue = new UpdateValue() { Value = updatedValue }; _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue); while (!_updateValueTested) { yield return(null); } // List Synonyms _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_listSynonymsTested) { yield return(null); } // Create Synonyms CreateSynonym synonym = new CreateSynonym() { Synonym = _createdSynonym }; _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym); while (!_createSynonymTested) { yield return(null); } // Get Synonym _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym); while (!_getSynonymTested) { yield return(null); } // Update Synonyms string updatedSynonym = _createdSynonym + "-updated"; UpdateSynonym updateSynonym = new UpdateSynonym() { Synonym = updatedSynonym }; _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym); while (!_updateSynonymTested) { yield return(null); } // List Dialog Nodes _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId); while (!_listDialogNodesTested) { yield return(null); } // Create Dialog Nodes CreateDialogNode createDialogNode = new CreateDialogNode() { DialogNode = _dialogNodeName, Description = _dialogNodeDesc }; _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode); while (!_createDialogNodeTested) { yield return(null); } // Get Dialog Node _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName); while (!_getDialogNodeTested) { yield return(null); } // Update Dialog Nodes string updatedDialogNodeName = _dialogNodeName + "_updated"; string updatedDialogNodeDescription = _dialogNodeDesc + "_updated"; UpdateDialogNode updateDialogNode = new UpdateDialogNode() { DialogNode = updatedDialogNodeName, Description = updatedDialogNodeDescription }; _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode); while (!_updateDialogNodeTested) { yield return(null); } // List Logs In Workspace _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId); while (!_listLogsInWorkspaceTested) { yield return(null); } // List All Logs var filter = "(language::en,request.context.metadata.deployment::deployment_1)"; _service.ListAllLogs(OnListAllLogs, OnFail, filter); while (!_listAllLogsTested) { yield return(null); } // List Counterexamples _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId); while (!_listCounterexamplesTested) { yield return(null); } // Create Counterexamples CreateCounterexample example = new CreateCounterexample() { Text = _createdCounterExampleText }; _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example); while (!_createCounterexampleTested) { yield return(null); } // Get Counterexample _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText); while (!_getCounterexampleTested) { yield return(null); } // Update Counterexamples string updatedCounterExampleText = _createdCounterExampleText + "-updated"; UpdateCounterexample updateCounterExample = new UpdateCounterexample() { Text = updatedCounterExampleText }; _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample); while (!_updateCounterexampleTested) { yield return(null); } // Delete Counterexample _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText); while (!_deleteCounterexampleTested) { yield return(null); } // Delete Dialog Node _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName); while (!_deleteDialogNodeTested) { yield return(null); } // Delete Synonym _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym); while (!_deleteSynonymTested) { yield return(null); } // Delete Value _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_deleteValueTested) { yield return(null); } // Delete Entity _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity); while (!_deleteEntityTested) { yield return(null); } // Delete Example _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample); while (!_deleteExampleTested) { yield return(null); } // Delete Intent _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent); while (!_deleteIntentTested) { yield return(null); } // Delete Workspace _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId); while (!_deleteWorkspaceTested) { yield return(null); } Log.Debug("TestAssistant.RunTest()", "Assistant examples complete."); yield break; }
protected bool?OnRaiseUpdateValue() { return(UpdateValue?.Invoke(Values[SavedCurrentIndex], StaticDataKey)); }
public override IEnumerator RunTest() { LogSystem.InstallDefaultReactors(); VcapCredentials vcapCredentials = new VcapCredentials(); fsData data = null; string result = null; var vcapUrl = Environment.GetEnvironmentVariable("VCAP_URL"); var vcapUsername = Environment.GetEnvironmentVariable("VCAP_USERNAME"); var vcapPassword = Environment.GetEnvironmentVariable("VCAP_PASSWORD"); using (SimpleGet simpleGet = new SimpleGet(vcapUrl, vcapUsername, vcapPassword)) { while (!simpleGet.IsComplete) { yield return(null); } result = simpleGet.Result; } // Add in a parent object because Unity does not like to deserialize root level collection types. result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES"); // Convert json to fsResult fsResult r = fsJsonParser.Parse(result, out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Convert fsResult to VcapCredentials object obj = vcapCredentials; r = _serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Set credentials from imported credntials Credential credential = vcapCredentials.VCAP_SERVICES["conversation"]; _username = credential.Username.ToString(); _password = credential.Password.ToString(); _url = credential.Url.ToString(); //_workspaceId = credential.WorkspaceId.ToString(); // Create credential and instantiate service Credentials credentials = new Credentials(_username, _password, _url); _service = new Assistant(credentials); _service.VersionDate = _assistantVersionDate; // List Workspaces _service.ListWorkspaces(OnListWorkspaces, OnFail); while (!_listWorkspacesTested) { yield return(null); } // Create Workspace CreateWorkspace workspace = new CreateWorkspace() { Name = _createdWorkspaceName, Description = _createdWorkspaceDescription, Language = _createdWorkspaceLanguage, LearningOptOut = true }; _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace); while (!_createWorkspaceTested) { yield return(null); } // Get Workspace _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId); while (!_getWorkspaceTested) { yield return(null); } // Update Workspace UpdateWorkspace updateWorkspace = new UpdateWorkspace() { Name = _createdWorkspaceName + "-updated", Description = _createdWorkspaceDescription + "-updated", Language = _createdWorkspaceLanguage }; _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace); while (!_updateWorkspaceTested) { yield return(null); } // Message Dictionary <string, object> input = new Dictionary <string, object>(); input.Add("text", _inputString); MessageRequest messageRequest = new MessageRequest() { Input = input, AlternateIntents = true }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest); while (!_messageTested) { yield return(null); } // List Intents _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId); while (!_listIntentsTested) { yield return(null); } // Create Intent CreateIntent createIntent = new CreateIntent() { Intent = _createdIntent, Description = _createdIntentDescription }; _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent); while (!_createIntentTested) { yield return(null); } // Get Intent _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent); while (!_getIntentTested) { yield return(null); } // Update Intents string updatedIntent = _createdIntent + "-updated"; string updatedIntentDescription = _createdIntentDescription + "-updated"; UpdateIntent updateIntent = new UpdateIntent() { Intent = updatedIntent, Description = updatedIntentDescription }; _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent); while (!_updateIntentTested) { yield return(null); } // List Examples _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent); while (!_listExamplesTested) { yield return(null); } // Create Examples CreateExample createExample = new CreateExample() { Text = _createdExample }; _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample); while (!_createExampleTested) { yield return(null); } // Get Example _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample); while (!_getExampleTested) { yield return(null); } // Update Examples string updatedExample = _createdExample + "-updated"; UpdateExample updateExample = new UpdateExample() { Text = updatedExample }; _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample); while (!_updateExampleTested) { yield return(null); } // List Entities _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId); while (!_listEntitiesTested) { yield return(null); } // Create Entities CreateEntity entity = new CreateEntity() { Entity = _createdEntity, Description = _createdEntityDescription }; _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity); while (!_createEntityTested) { yield return(null); } // Get Entity _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity); while (!_getEntityTested) { yield return(null); } // Update Entities string updatedEntity = _createdEntity + "-updated"; string updatedEntityDescription = _createdEntityDescription + "-updated"; UpdateEntity updateEntity = new UpdateEntity() { Entity = updatedEntity, Description = updatedEntityDescription }; _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity); while (!_updateEntityTested) { yield return(null); } // List Values _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity); while (!_listValuesTested) { yield return(null); } // Create Values CreateValue value = new CreateValue() { Value = _createdValue }; _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value); while (!_createValueTested) { yield return(null); } // Get Value _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue); while (!_getValueTested) { yield return(null); } // Update Values string updatedValue = _createdValue + "-updated"; UpdateValue updateValue = new UpdateValue() { Value = updatedValue }; _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue); while (!_updateValueTested) { yield return(null); } // List Synonyms _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_listSynonymsTested) { yield return(null); } // Create Synonyms CreateSynonym synonym = new CreateSynonym() { Synonym = _createdSynonym }; _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym); while (!_createSynonymTested) { yield return(null); } // Get Synonym _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym); while (!_getSynonymTested) { yield return(null); } // Update Synonyms string updatedSynonym = _createdSynonym + "-updated"; UpdateSynonym updateSynonym = new UpdateSynonym() { Synonym = updatedSynonym }; _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym); while (!_updateSynonymTested) { yield return(null); } // List Dialog Nodes _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId); while (!_listDialogNodesTested) { yield return(null); } // Create Dialog Nodes CreateDialogNode createDialogNode = new CreateDialogNode() { DialogNode = _dialogNodeName, Description = _dialogNodeDesc }; _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode); while (!_createDialogNodeTested) { yield return(null); } // Get Dialog Node _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName); while (!_getDialogNodeTested) { yield return(null); } // Update Dialog Nodes string updatedDialogNodeName = _dialogNodeName + "_updated"; string updatedDialogNodeDescription = _dialogNodeDesc + "_updated"; UpdateDialogNode updateDialogNode = new UpdateDialogNode() { DialogNode = updatedDialogNodeName, Description = updatedDialogNodeDescription }; _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode); while (!_updateDialogNodeTested) { yield return(null); } // List Logs In Workspace _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId); while (!_listLogsInWorkspaceTested) { yield return(null); } // List All Logs var filter = "(language::en,request.context.metadata.deployment::deployment_1)"; _service.ListAllLogs(OnListAllLogs, OnFail, filter); while (!_listAllLogsTested) { yield return(null); } // List Counterexamples _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId); while (!_listCounterexamplesTested) { yield return(null); } // Create Counterexamples CreateCounterexample example = new CreateCounterexample() { Text = _createdCounterExampleText }; _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example); while (!_createCounterexampleTested) { yield return(null); } // Get Counterexample _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText); while (!_getCounterexampleTested) { yield return(null); } // Update Counterexamples string updatedCounterExampleText = _createdCounterExampleText + "-updated"; UpdateCounterexample updateCounterExample = new UpdateCounterexample() { Text = updatedCounterExampleText }; _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample); while (!_updateCounterexampleTested) { yield return(null); } // Delete Counterexample _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText); while (!_deleteCounterexampleTested) { yield return(null); } // Delete Dialog Node _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName); while (!_deleteDialogNodeTested) { yield return(null); } // Delete Synonym _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym); while (!_deleteSynonymTested) { yield return(null); } // Delete Value _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_deleteValueTested) { yield return(null); } // Delete Entity _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity); while (!_deleteEntityTested) { yield return(null); } // Delete Example _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample); while (!_deleteExampleTested) { yield return(null); } // Delete Intent _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent); while (!_deleteIntentTested) { yield return(null); } // Delete Workspace _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId); while (!_deleteWorkspaceTested) { yield return(null); } Log.Debug("TestAssistant.RunTest()", "Assistant examples complete."); yield break; }
private ImTreeMapIntToObj AddOrUpdate(int key, object value, bool updateOnly, UpdateValue update) { return(Height == 0 ? // tree is empty (updateOnly ? this : new ImTreeMapIntToObj(key, value, Empty, Empty)) : (key == Key ? // actual update new ImTreeMapIntToObj(key, update == null ? value : update(Value, value), Left, Right) : (key < Key // try update on left or right sub-tree ? With(Left.AddOrUpdate(key, value, updateOnly, update), Right) : With(Left, Right.AddOrUpdate(key, value, updateOnly, update))).KeepBalanced())); }
/// <summary>Returns new tree with added or updated value for specified key.</summary> /// <param name="key">Key</param> <param name="value">Value</param> /// <param name="updateValue">(optional) Delegate to calculate new value from and old and a new value.</param> /// <returns>New tree.</returns> public ImTreeMapIntToObj AddOrUpdate(int key, object value, UpdateValue updateValue) { return(AddOrUpdate(key, value, false, updateValue)); }
public ValueResponse UpdateValue(string workspaceId, string entity, string value, UpdateValue body) { if (string.IsNullOrEmpty(workspaceId)) { throw new ArgumentNullException(nameof(workspaceId)); } if (string.IsNullOrEmpty(entity)) { throw new ArgumentNullException(nameof(entity)); } if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } if (string.IsNullOrEmpty(VersionDate)) { throw new ArgumentNullException("versionDate cannot be null. Use 'CONVERSATION_VERSION_DATE_2017_05_26'"); } ValueResponse result = null; try { result = this.Client.WithAuthentication(this.UserName, this.Password) .PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}/entities/{entity}/values/{value}") .WithArgument("version", VersionDate) .WithBody <UpdateValue>(body) .As <ValueResponse>() .Result; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
private IntNTree <V> AddOrUpdate(DryIoc.Playground.KV <int, V> item, UpdateValue updateValue) { if (Height == 0) { return(new IntNTree <V>(new[] { item }, Empty, Empty)); } if (item.Key < LeftKey) { if (Items.Length < N) { var newItems = new DryIoc.Playground.KV <int, V> [Items.Length + 1]; newItems[0] = item; Array.Copy(Items, 0, newItems, 1, Items.Length); return(new IntNTree <V>(newItems, Left, Right)); } return(With(Left.AddOrUpdate(item, updateValue), Right).EnsureBalanced()); } if (item.Key > RightKey) { if (Items.Length < N) { var newItems = new DryIoc.Playground.KV <int, V> [Items.Length + 1]; Array.Copy(Items, 0, newItems, 0, Items.Length); newItems[Items.Length] = item; return(new IntNTree <V>(newItems, Left, Right)); } return(With(Left, Right.AddOrUpdate(item, updateValue)).EnsureBalanced()); } var i = 0; while (item.Key > Items[i].Key) { i++; } if (item.Key == Items[i].Key) // Update value { var newItems = new DryIoc.Playground.KV <int, V> [Items.Length]; Array.Copy(Items, 0, newItems, 0, Items.Length); newItems[i] = updateValue == null ? item : new DryIoc.Playground.KV <int, V>(item.Key, updateValue(Items[i].Value, item.Value)); return(new IntNTree <V>(newItems, Left, Right)); } if (Items.Length < N) // Insert value into current node { var newItems = new DryIoc.Playground.KV <int, V> [Items.Length + 1]; Array.Copy(Items, 0, newItems, 0, i); newItems[i] = item; Array.Copy(Items, i, newItems, i + 1, Items.Length - i); return(new IntNTree <V>(newItems, Left, Right)); } var items = new DryIoc.Playground.KV <int, V> [Items.Length]; // Drop left item to the left node if it has room for insert, otherwise drop right item to right node. if (Left.Height == 0 || Left.Items.Length < N) { // values: drop 1, 2, insert 3, 4, 6, 9 // indexes: 0, 1, insert 1, 2, 3, 4 // i == 2 Array.Copy(Items, 1, items, 0, i - 1); items[i - 1] = item; Array.Copy(Items, i, items, i, Items.Length - i); return(new IntNTree <V>(items, Left.AddOrUpdate(Items[0], updateValue), Right).EnsureBalanced()); } // values: copy 1, 2, insert 3, copy 4, 6, drop 9 // indexes: copy 0, 1, insert 1, copy 2, 3, drop 4 // i == 2 Array.Copy(Items, 0, items, 0, i); items[i] = item; Array.Copy(Items, i, items, i + 1, Items.Length - i - 1); return(new IntNTree <V>(items, Left, Right.AddOrUpdate(Items[Items.Length - 1], updateValue)).EnsureBalanced()); }
public IntNTree <V> AddOrUpdate(int key, V value, UpdateValue updateValue = null) { return(AddOrUpdate(new DryIoc.Playground.KV <int, V>(key, value), updateValue)); }
/** * Initialize this type inspector using delegates to get and set the stored value. */ public void Initialize(string name, UpdateValue getStoredValueDelegate, Callback <object> onValueChangedDelegate) { Initialize(name, getStoredValueDelegate, onValueChangedDelegate, null, null); }
public AvlTree <K, V> AddOrUpdate(K key, V value, UpdateValue updateValue = null) { return(AddOrUpdate(key.GetHashCode(), key, value, updateValue)); }
public void OnDrag(PointerEventData eventData) { nextFrameUpdate = UpdateValue.ScrollRect; }
public ImmutableDictionary <K, V> AddOrUpdate(K key, V value, UpdateValue updateValue = null) { return(AddOrUpdate(key.GetHashCode(), key, value, updateValue ?? ReplaceValue)); }
void OnDestroy() { updateBlendValue = null; }
bool ICodeGenElementVisitor <bool> .VisitUpdateValue(UpdateValue updateValue) { Update(GetValueSource(updateValue.Variable), ReadCodeGenValue(updateValue.InputIndex)); return(true); }
public override IEnumerator RunTest() { LogSystem.InstallDefaultReactors(); VcapCredentials vcapCredentials = new VcapCredentials(); fsData data = null; string result = null; string credentialsFilepath = "../sdk-credentials/credentials.json"; // Load credentials file if it exists. If it doesn't exist, don't run the tests. if (File.Exists(credentialsFilepath)) { result = File.ReadAllText(credentialsFilepath); } else { yield break; } // Add in a parent object because Unity does not like to deserialize root level collection types. result = Utility.AddTopLevelObjectToJson(result, "VCAP_SERVICES"); // Convert json to fsResult fsResult r = fsJsonParser.Parse(result, out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Convert fsResult to VcapCredentials object obj = vcapCredentials; r = _serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } // Set credentials from imported credntials Credential credential = vcapCredentials.GetCredentialByname("assistant-sdk")[0].Credentials; _username = credential.Username.ToString(); _password = credential.Password.ToString(); _url = credential.Url.ToString(); _workspaceId = credential.WorkspaceId.ToString(); // Create credential and instantiate service Credentials credentials = new Credentials(_username, _password, _url); _service = new Assistant(credentials); _service.VersionDate = _assistantVersionDate; // List Workspaces _service.ListWorkspaces(OnListWorkspaces, OnFail); while (!_listWorkspacesTested) { yield return(null); } // Create Workspace CreateWorkspace workspace = new CreateWorkspace() { Name = _createdWorkspaceName, Description = _createdWorkspaceDescription, Language = _createdWorkspaceLanguage, LearningOptOut = true }; _service.CreateWorkspace(OnCreateWorkspace, OnFail, workspace); while (!_createWorkspaceTested) { yield return(null); } // Get Workspace _service.GetWorkspace(OnGetWorkspace, OnFail, _createdWorkspaceId); while (!_getWorkspaceTested) { yield return(null); } // Update Workspace UpdateWorkspace updateWorkspace = new UpdateWorkspace() { Name = _createdWorkspaceName + "-updated", Description = _createdWorkspaceDescription + "-updated", Language = _createdWorkspaceLanguage }; _service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace); while (!_updateWorkspaceTested) { yield return(null); } // Message with customerID // Create customData object Dictionary <string, object> customData = new Dictionary <string, object>(); // Create a dictionary of custom headers Dictionary <string, string> customHeaders = new Dictionary <string, string>(); // Add to the header dictionary customHeaders.Add("X-Watson-Metadata", "customer_id=" + _unitySdkTestCustomerID); // Add the header dictionary to the custom data object customData.Add(Constants.String.CUSTOM_REQUEST_HEADERS, customHeaders); Dictionary <string, object> input = new Dictionary <string, object>(); input.Add("text", _inputString); MessageRequest messageRequest = new MessageRequest() { Input = input }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest, null, customData); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString0; MessageRequest messageRequest0 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest0); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString1; MessageRequest messageRequest1 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest1); while (!_messageTested) { yield return(null); } _messageTested = false; input["text"] = _conversationString2; MessageRequest messageRequest2 = new MessageRequest() { Input = input, Context = _context }; _service.Message(OnMessage, OnFail, _workspaceId, messageRequest2); while (!_messageTested) { yield return(null); } // List Intents _service.ListIntents(OnListIntents, OnFail, _createdWorkspaceId); while (!_listIntentsTested) { yield return(null); } // Create Intent CreateIntent createIntent = new CreateIntent() { Intent = _createdIntent, Description = _createdIntentDescription }; _service.CreateIntent(OnCreateIntent, OnFail, _createdWorkspaceId, createIntent); while (!_createIntentTested) { yield return(null); } // Get Intent _service.GetIntent(OnGetIntent, OnFail, _createdWorkspaceId, _createdIntent); while (!_getIntentTested) { yield return(null); } // Update Intents string updatedIntent = _createdIntent + "-updated"; string updatedIntentDescription = _createdIntentDescription + "-updated"; UpdateIntent updateIntent = new UpdateIntent() { Intent = updatedIntent, Description = updatedIntentDescription }; _service.UpdateIntent(OnUpdateIntent, OnFail, _createdWorkspaceId, _createdIntent, updateIntent); while (!_updateIntentTested) { yield return(null); } // List Examples _service.ListExamples(OnListExamples, OnFail, _createdWorkspaceId, updatedIntent); while (!_listExamplesTested) { yield return(null); } // Create Examples CreateExample createExample = new CreateExample() { Text = _createdExample }; _service.CreateExample(OnCreateExample, OnFail, _createdWorkspaceId, updatedIntent, createExample); while (!_createExampleTested) { yield return(null); } // Get Example _service.GetExample(OnGetExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample); while (!_getExampleTested) { yield return(null); } // Update Examples string updatedExample = _createdExample + "-updated"; UpdateExample updateExample = new UpdateExample() { Text = updatedExample }; _service.UpdateExample(OnUpdateExample, OnFail, _createdWorkspaceId, updatedIntent, _createdExample, updateExample); while (!_updateExampleTested) { yield return(null); } // List Entities _service.ListEntities(OnListEntities, OnFail, _createdWorkspaceId); while (!_listEntitiesTested) { yield return(null); } // Create Entities CreateEntity entity = new CreateEntity() { Entity = _createdEntity, Description = _createdEntityDescription }; _service.CreateEntity(OnCreateEntity, OnFail, _createdWorkspaceId, entity); while (!_createEntityTested) { yield return(null); } // Get Entity _service.GetEntity(OnGetEntity, OnFail, _createdWorkspaceId, _createdEntity); while (!_getEntityTested) { yield return(null); } // Update Entities string updatedEntity = _createdEntity + "-updated"; string updatedEntityDescription = _createdEntityDescription + "-updated"; UpdateEntity updateEntity = new UpdateEntity() { Entity = updatedEntity, Description = updatedEntityDescription }; _service.UpdateEntity(OnUpdateEntity, OnFail, _createdWorkspaceId, _createdEntity, updateEntity); while (!_updateEntityTested) { yield return(null); } // List Values _service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity); while (!_listValuesTested) { yield return(null); } // Create Values CreateValue value = new CreateValue() { Value = _createdValue }; _service.CreateValue(OnCreateValue, OnFail, _createdWorkspaceId, updatedEntity, value); while (!_createValueTested) { yield return(null); } // Get Value _service.GetValue(OnGetValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue); while (!_getValueTested) { yield return(null); } // Update Values string updatedValue = _createdValue + "-updated"; UpdateValue updateValue = new UpdateValue() { Value = updatedValue }; _service.UpdateValue(OnUpdateValue, OnFail, _createdWorkspaceId, updatedEntity, _createdValue, updateValue); while (!_updateValueTested) { yield return(null); } // List Synonyms _service.ListSynonyms(OnListSynonyms, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_listSynonymsTested) { yield return(null); } // Create Synonyms CreateSynonym synonym = new CreateSynonym() { Synonym = _createdSynonym }; _service.CreateSynonym(OnCreateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, synonym); while (!_createSynonymTested) { yield return(null); } // Get Synonym _service.GetSynonym(OnGetSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym); while (!_getSynonymTested) { yield return(null); } // Update Synonyms string updatedSynonym = _createdSynonym + "-updated"; UpdateSynonym updateSynonym = new UpdateSynonym() { Synonym = updatedSynonym }; _service.UpdateSynonym(OnUpdateSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, _createdSynonym, updateSynonym); while (!_updateSynonymTested) { yield return(null); } // List Dialog Nodes _service.ListDialogNodes(OnListDialogNodes, OnFail, _createdWorkspaceId); while (!_listDialogNodesTested) { yield return(null); } // Create Dialog Nodes CreateDialogNode createDialogNode = new CreateDialogNode() { DialogNode = _dialogNodeName, Description = _dialogNodeDesc }; _service.CreateDialogNode(OnCreateDialogNode, OnFail, _createdWorkspaceId, createDialogNode); while (!_createDialogNodeTested) { yield return(null); } // Get Dialog Node _service.GetDialogNode(OnGetDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName); while (!_getDialogNodeTested) { yield return(null); } // Update Dialog Nodes string updatedDialogNodeName = _dialogNodeName + "_updated"; string updatedDialogNodeDescription = _dialogNodeDesc + "_updated"; UpdateDialogNode updateDialogNode = new UpdateDialogNode() { DialogNode = updatedDialogNodeName, Description = updatedDialogNodeDescription }; _service.UpdateDialogNode(OnUpdateDialogNode, OnFail, _createdWorkspaceId, _dialogNodeName, updateDialogNode); while (!_updateDialogNodeTested) { yield return(null); } // List Logs In Workspace _service.ListLogs(OnListLogs, OnFail, _createdWorkspaceId); while (!_listLogsInWorkspaceTested) { yield return(null); } // List All Logs var filter = "(language::en,request.context.metadata.deployment::deployment_1)"; _service.ListAllLogs(OnListAllLogs, OnFail, filter); while (!_listAllLogsTested) { yield return(null); } // List Counterexamples _service.ListCounterexamples(OnListCounterexamples, OnFail, _createdWorkspaceId); while (!_listCounterexamplesTested) { yield return(null); } // Create Counterexamples CreateCounterexample example = new CreateCounterexample() { Text = _createdCounterExampleText }; _service.CreateCounterexample(OnCreateCounterexample, OnFail, _createdWorkspaceId, example); while (!_createCounterexampleTested) { yield return(null); } // Get Counterexample _service.GetCounterexample(OnGetCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText); while (!_getCounterexampleTested) { yield return(null); } // Update Counterexamples string updatedCounterExampleText = _createdCounterExampleText + "-updated"; UpdateCounterexample updateCounterExample = new UpdateCounterexample() { Text = updatedCounterExampleText }; _service.UpdateCounterexample(OnUpdateCounterexample, OnFail, _createdWorkspaceId, _createdCounterExampleText, updateCounterExample); while (!_updateCounterexampleTested) { yield return(null); } // Delete Counterexample _service.DeleteCounterexample(OnDeleteCounterexample, OnFail, _createdWorkspaceId, updatedCounterExampleText); while (!_deleteCounterexampleTested) { yield return(null); } // Delete Dialog Node _service.DeleteDialogNode(OnDeleteDialogNode, OnFail, _createdWorkspaceId, updatedDialogNodeName); while (!_deleteDialogNodeTested) { yield return(null); } // Delete Synonym _service.DeleteSynonym(OnDeleteSynonym, OnFail, _createdWorkspaceId, updatedEntity, updatedValue, updatedSynonym); while (!_deleteSynonymTested) { yield return(null); } // Delete Value _service.DeleteValue(OnDeleteValue, OnFail, _createdWorkspaceId, updatedEntity, updatedValue); while (!_deleteValueTested) { yield return(null); } // Delete Entity _service.DeleteEntity(OnDeleteEntity, OnFail, _createdWorkspaceId, updatedEntity); while (!_deleteEntityTested) { yield return(null); } // Delete Example _service.DeleteExample(OnDeleteExample, OnFail, _createdWorkspaceId, updatedIntent, updatedExample); while (!_deleteExampleTested) { yield return(null); } // Delete Intent _service.DeleteIntent(OnDeleteIntent, OnFail, _createdWorkspaceId, updatedIntent); while (!_deleteIntentTested) { yield return(null); } // Delete Workspace _service.DeleteWorkspace(OnDeleteWorkspace, OnFail, _createdWorkspaceId); while (!_deleteWorkspaceTested) { yield return(null); } // Delete User Data _service.DeleteUserData(OnDeleteUserData, OnFail, _unitySdkTestCustomerID); while (!_deleteUserDataTested) { yield return(null); } Log.Debug("TestAssistant.RunTest()", "Assistant examples complete."); yield break; }
public static void Dispose() { m_GetSourceValue = null; m_ApplyActual = null; m_UpdateSourceValue = null; }