/// <inheritdoc/> public Value Write(Value value) { #if DEBUG //Log($"value = {value}"); #endif switch (value.KindOfValue) { case KindOfValue.LogicalSearchResultValue: LogChannel(DebugHelperForLogicalSearchResult.ToString(value.AsLogicalSearchResultValue.LogicalSearchResult)); break; case KindOfValue.ErrorValue: LogChannel($"ERROR: {DebugHelperForRuleInstance.ToString(value.AsErrorValue.RuleInstance)}"); break; case KindOfValue.NullValue: LogChannel("NULL"); break; default: { var sysValue = value.GetSystemValue(); if (sysValue == null) { LogChannel("NULL"); break; } var sysValueType = sysValue.GetType(); #if DEBUG //Log($"sysValue = {sysValue}"); //Log($"sysValue.GetType().FullName = {sysValue.GetType().FullName}"); #endif if (sysValueType == typeof(double)) { LogChannel(((double)sysValue).ToString(CultureInfo.InvariantCulture)); break; } if (sysValueType == typeof(float)) { LogChannel(((float)sysValue).ToString(CultureInfo.InvariantCulture)); break; } if (sysValueType == typeof(decimal)) { LogChannel(((decimal)sysValue).ToString(CultureInfo.InvariantCulture)); break; } LogChannel(sysValue.ToString()); } break; } return(value); }
private void Search(string queryStr) { _logger.Log($"queryStr = {queryStr}"); var result = new CodeFile(); result.IsMain = false; result.FileName = "Hi!"; var internalParserContext = new InternalParserContext(queryStr, result, _context); var globalStorage = _context.Storage.GlobalStorage; internalParserContext.SetCurrentDefaultSetings(globalStorage.DefaultSettingsOfCodeEntity); var parser = new LogicalQueryParser(internalParserContext); parser.Run(); var parsedQuery = parser.Result; //_logger.Log($"parsedQuery = {parsedQuery}"); _logger.Log($"DebugHelperForRuleInstance.ToString(parsedQuery) = {DebugHelperForRuleInstance.ToString(parsedQuery)}"); //var indexedQuery = parsedQuery.GetIndexed(_context); //_logger.Log($"indexedQuery = {indexedQuery}"); //_logger.Log($"DebugHelperForIndexedRuleInstance.ToString(indexedQuery) = {DebugHelperForIndexedRuleInstance.ToString(indexedQuery, dictionary)}"); var searcher = _context.DataResolversFactory.GetLogicalSearchResolver(); var searchOptions = new LogicalSearchOptions(); searchOptions.QueryExpression = parsedQuery; var localCodeExecutionContext = new LocalCodeExecutionContext(); searchOptions.LocalCodeExecutionContext = localCodeExecutionContext; localCodeExecutionContext.Storage = _context.Storage.GlobalStorage; localCodeExecutionContext.Holder = _context.CommonNamesStorage.DefaultHolder; //_logger.Log($"searchOptions = {searchOptions}"); var searchResult = searcher.Run(searchOptions); //_logger.Log($"searchResult = {searchResult}"); _logger.Log($"searchResult.IsSuccess = {searchResult.IsSuccess}"); _logger.Log($"searchResult.Items.Count = {searchResult.Items.Count}"); _logger.Log(DebugHelperForLogicalSearchResult.ToString(searchResult)); foreach (var item in searchResult.Items) { _logger.Log($"item.ResultOfVarOfQueryToRelationList.Count = {item.ResultOfVarOfQueryToRelationList.Count}"); foreach (var resultOfVarOfQueryToRelation in item.ResultOfVarOfQueryToRelationList) { var varName = resultOfVarOfQueryToRelation.NameOfVar; _logger.Log($"varName = {varName}"); var foundNode = resultOfVarOfQueryToRelation.FoundExpression; _logger.Log($"DebugHelperForRuleInstance.ToString(foundNode) = {DebugHelperForRuleInstance.ToString(foundNode)}"); } //_logger.Log($" = {}"); } }