public Activity Parse(JsonElement node, ITypeInfoProvider typeInfoProvider,
                              CompositeActivityParser compositeParser)
        {
            var inputType      = typeInfoProvider.Find(node.GetProperty("inType").GetString());
            var outputType     = typeInfoProvider.Find(node.GetProperty("outType").GetString());
            var argumentsExits = node.TryGetProperty("arguments", out var argumentsNode);
            var arguments      = argumentsExits ? argumentsNode.GetString() : null;
            var code           = node.GetProperty("code").GetString();
            var displayName    = ActivityParseUtil.GetDisplayName(node);
            var result         = node.GetProperty("result").GetString();
            var methodInfo     = _methodInfo !.MakeGenericMethod(inputType, outputType);

            return((Activity)methodInfo.Invoke(this, new object[] { displayName, code, result, arguments }));
        }
        public Activity Parse(JsonElement node, ITypeInfoProvider typeInfoProvider,
                              CompositeActivityParser compositeParser)
        {
            var typeName   = node.GetProperty("type").GetString();
            var type       = typeInfoProvider.Find(typeName);
            var coreMethod = _coreMethod !.MakeGenericMethod(type);

            return((Activity)coreMethod.Invoke(this, new object[] { node }));
        }
        public Type Find(string name)
        {
            var type = _parent?.Find(name);

            if (type != null)
            {
                return(type);
            }
            return(_types.TryGetValue(name, out type) ? type : null);
        }
Example #4
0
        public Activity Parse(JsonElement node, ITypeInfoProvider typeInfoProvider, CompositeActivityParser compositeParser)
        {
            var mirrorBase = node.GetProperty("mirrorBase").GetString();
            var tenantId   = node.GetProperty("tenantId").GetString();
            var modelKey   = node.GetProperty("modelKey").GetString();
            var modelType  = typeInfoProvider.Find(modelKey);
            var model      = node.GetProperty("model").GetString();
            var result     = node.GetProperty("result").GetString();
            var methodInfo = _methodInfo !.MakeGenericMethod(modelType);

            return((Activity)methodInfo.Invoke(this, new object[] { mirrorBase, tenantId, modelKey, model, result }));
        }
Example #5
0
        private IEnumerable <DynamicActivityProperty> ParseArguments(JsonElement node)
        {
            var exists = node.TryGetProperty("arguments", out var argumentsNode);

            if (!exists)
            {
                yield break;
            }
            foreach (var argumentNode in argumentsNode.EnumerateArray())
            {
                var typeName = argumentNode.GetProperty("type").GetString();
                var name     = argumentNode.GetProperty("name").GetString();
                var type     = _typeInfoProvider.Find(typeName);
                var value    = Argument.Create(type, ArgumentDirection.In);
                yield return(new DynamicActivityProperty
                {
                    Name = name,
                    Type = value.GetType(),
                    Value = value
                });
            }
        }
        public Activity Parse(JsonElement node, ITypeInfoProvider typeInfoProvider,
                              CompositeActivityParser compositeParser)
        {
            var typeName = node.GetProperty("type").GetString();
            var type     = typeInfoProvider.Find(typeName);

            if (type == null)
            {
                throw new Exception($"can not find type name {typeName}");
            }
            var coreMethod = _coreMethod !.MakeGenericMethod(type);

            return((Activity)coreMethod !.Invoke(this, new object[] { node, compositeParser }));
        }
        public Activity Parse(JsonElement node, ITypeInfoProvider typeInfoProvider, CompositeActivityParser compositeParser)
        {
            var mirrorBase = node.GetProperty("mirrorBase").GetString();
            var tenantId   = node.GetProperty("tenantId").GetString();
            var modelKey   = node.GetProperty("modelKey").GetString();
            var modelType  = typeInfoProvider.Find(modelKey);
            var filter     = node.GetProperty("filter").GetString();

            filter = MirrorExpressionHelper.BuildCSharpExpression(filter);
            var sort = node.GetProperty("sort").GetString();

            sort = MirrorExpressionHelper.BuildCSharpExpression(sort);
            var result     = node.GetProperty("result").GetString();
            var methodInfo = _methodInfo !.MakeGenericMethod(modelType);

            return((Activity)methodInfo.Invoke(this, new object[] { mirrorBase, tenantId, modelKey, filter, sort, result }));
        }
        public static IEnumerable <Variable> ParseVariables(JsonElement node, ITypeInfoProvider typeInfoProvider)
        {
            var exists = node.TryGetProperty("variables", out var variablesNode);

            if (!exists)
            {
                yield break;
            }
            foreach (var variableNode in variablesNode.EnumerateArray())
            {
                var typeName = variableNode.GetProperty("type").GetString();
                var type     = typeInfoProvider.Find(typeName);
                if (type == null)
                {
                    throw new Exception($"can not find type {typeName}");
                }
                var coreMethod = typeof(ActivityParseUtil).GetMethod(nameof(ParseVariableCore),
                                                                     BindingFlags.Default | BindingFlags.Static | BindingFlags.NonPublic);
                coreMethod = coreMethod !.MakeGenericMethod(type);
                yield return((Variable)coreMethod.Invoke(null, new object[] { variableNode }));
            }
        }