예제 #1
0
        private static ScopeSpecification CreateScopeSpesification(OctoVariable variable, VariableSetResource variableSet)
        {
            var scopeSpecifiaciton = new ScopeSpecification();

            variable.Scopes.ForEach(scope =>
            {
                ScopeField scopeName = FindScopeName(scope);

                List <ReferenceDataItem> referenceDataItems = FindScopeValue(scopeName, variableSet);

                List <string> scopeValues = referenceDataItems.Join(scope.Values,
                                                                    refDataItem => refDataItem.Name,
                                                                    selectedScope => selectedScope,
                                                                    (item, s) => item.Id)
                                            .ToList();

                if (!scopeValues.Any())
                {
                    throw new CakeException($"({string.Join(",", scope.Values)}) value(s) can not be found on ({scope.Name}) scope.");
                }

                var value = new ScopeValue(scopeValues.First(), scopeValues.Skip(1).ToArray());

                scopeSpecifiaciton.Add(scopeName, value);
            });

            return(scopeSpecifiaciton);
        }
예제 #2
0
        private static string CreateScopeInformationsForLogging(OctoVariable variable)
        {
            List <string> scopeInformation = variable.Scopes
                                             .SelectMany(x => x.Values, (scope, c) => $"{scope.Name}({string.Join(", ", scope.Values)})")
                                             .Distinct()
                                             .ToList();

            return(string.Join(", ", scopeInformation));
        }