コード例 #1
0
        public List <QLAfElementTemplate> GetAfElementTemplates(IResolveFieldContext context, string aAfDatabasePath, string[] nameFilter = null)
        {
            aAfDatabasePath = cleanupPath(aAfDatabasePath);
            var aAfDb = AFDatabase.FindObject(aAfDatabasePath) as AFDatabase;

            if (aAfDb == null)
            {
                context.Errors.Add(new ExecutionError($"AFDatabase not found."));
                return(null);
            }

            var nameFilterStrings = nameFilter != null?nameFilter.ToList() : new List <string>();

            var afElementsField = GraphQlHelpers.GetFieldFromFieldOrContext(context, "afElements");

            var returnObject = new ConcurrentBag <QLAfElementTemplate>();

            var aAfElementTemplateList = aAfDb.ElementTemplates;

            Parallel.ForEach(aAfElementTemplateList, aAfElementTemplate =>
            {
                if (nameFilterStrings.Count == 0 || nameFilterStrings.Contains(aAfElementTemplate.Name))
                {
                    var graphQlAfElementTemplate = new QLAfElementTemplateResolve(aAfElementTemplate, afElementsField);
                    returnObject.Add(graphQlAfElementTemplate);
                }
            });
            return(returnObject.OrderBy(x => x.name).ToList());
        }
コード例 #2
0
        public QLAfDatabase GetAfDatabase(IResolveFieldContext context, string aAfDatabasePath)
        {
            aAfDatabasePath = cleanupPath(aAfDatabasePath);

            var aAfDb = AFDatabase.FindObject(aAfDatabasePath) as AFDatabase;

            var afElementsField = GraphQlHelpers.GetFieldFromFieldOrContext(context, "afElements");

            var aGraphQlAfDatabase = new QLAfDatabaseResolve(aAfDb, afElementsField);

            return(aGraphQlAfDatabase);
        }
コード例 #3
0
        public QLAfElement GetAfElementByPath(IResolveFieldContext context, string aAfElementPath)
        {
            aAfElementPath = cleanupPath(aAfElementPath);
            var aAfElementSearch = AFElement.FindElementsByPath(new string[] { aAfElementPath }, null);

            if (aAfElementSearch.Count == 0)
            {
                context.Errors.Add(new ExecutionError($"AFElement path '{aAfElementPath}' not correct."));
                return(null);
            }
            else
            {
                var aAfElement        = aAfElementSearch.First() as AFElement;
                var afElementsField   = GraphQlHelpers.GetFieldFromFieldOrContext(context, "afElements");
                var afAttributesField = GraphQlHelpers.GetFieldFromFieldOrContext(context, "afAttributes");
                var graphQlAfElement  = new QLAfElementResolve(aAfElement, afElementsField, afAttributesField);
                return(graphQlAfElement);
            }
        }
コード例 #4
0
        public QLPiSystem GetPiSystem(IResolveFieldContext context)
        {
            var afDbsField = GraphQlHelpers.GetFieldFromFieldOrContext(context, "afDbs");

            return(new QLPiSystemResolve(ResolverEntry.aPiSystem, afDbsField));
        }