示例#1
0
        private static ContextInputs MakeContextInputs(string name, Collection <ValueTypeComponent> component, ItemDefinitionMeta curItemDefMeta, Dictionary <string, ItemDefinitionMeta> itemDefMetaDict)
        {
            var ctx = new ContextInputs(name);

            ctx.IsItemDefinition = true;

            foreach (var item in component)
            {
                var itemComponent = FindDefMeta(itemDefMetaDict, curItemDefMeta, item.Name);

                if (item.ComponentSpecified)
                {
                    var nestedCtx = MakeContextInputs(item.Name, item.Component, itemComponent, itemDefMetaDict);
                    ctx.Add(item.Name, nestedCtx);
                }

                if (item.ListSpecified)
                {
                    var nestedList = MakeList(item.Name, item.List, itemComponent, itemDefMetaDict);
                    ctx.Add(item.Name, nestedList);
                }

                if (itemComponent.TypeName == null)
                {
                    throw new TCKException($"Missing type name for for component:{item.Name}");
                }

                ctx.Add(item.Name, VariableHelper.MakeVariable(GetValueType(item.Value), itemComponent.TypeName));
            }

            return(ctx);
        }
示例#2
0
        public object Execute(VariableContext context = null)
        {
            var contextInput = new ContextInputs();

            if (context == null)
            {
                context = new VariableContext();
            }

            if (context.LocalContext == null)
            {
                context.LocalContext = contextInput;
            }
            else if (context.LocalContext.ContextDict.ContainsKey("__currentContextX__"))
            {
                context.LocalContext.ContextDict["__currentContextX__"] = contextInput;
            }
            else
            {
                context.LocalContext.Add("__currentContextX__", contextInput);
            }

            foreach (var item in ContextEntries)
            {
                var itemVal = (Variable)item.Execute(context);
                contextInput.Add(itemVal.TwoTuple.a, itemVal.TwoTuple.b);
            }

            if (context.LocalContext != null)
            {
                context.LocalContext.ContextDict.Remove("__currentContextX__");
            }

            return(new Variable(contextInput));
        }