예제 #1
0
        public IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent)
        {
            // The class reference of the parent variable.
            int reference = (int)((CsvNumber)parent.Value).Value;

            IDebugVariable[] variables = new IDebugVariable[Class.ObjectVariables.Count];
            for (int i = 0; i < variables.Length; i++)
            {
                CsvPart value = new CsvNull();

                // Get the related object variable array.
                var objectVariableArray = collection.ActionStream.Variables.FirstOrDefault(v => v.Name == ClassData.ObjectVariableTag + i);
                if (objectVariableArray != null && objectVariableArray.Value is Csv.CsvArray csvArray)
                {
                    value = csvArray.Values[reference];
                }

                variables[i] = new ChildDebugVariable(
                    // Child variable resolver
                    Class.ObjectVariables[i].Variable.Type()?.DebugVariableResolver ?? new DefaultResolver(),
                    // Value
                    value,
                    // Name
                    Class.ObjectVariables[i].Variable.Name,
                    // Type
                    Class.ObjectVariables[i].Variable.Type()?.GetName() ?? "define"
                    );
                collection.Add(variables[i]);
            }

            return(variables);
        }
        public IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent)
        {
            // Use the default resolver if the value is not a number.
            if (parent.Value is CsvNumber == false)
            {
                return(new DefaultResolver().GetChildren(collection, parent));
            }

            // The class reference of the parent variable.
            int reference = (int)((CsvNumber)parent.Value).Value;

            IDebugVariable[] variables = new IDebugVariable[Class.Variables.Length];
            for (int i = 0; i < variables.Length; i++)
            {
                CsvPart value = new CsvNull();

                // Get the related object variable array.
                var objectVariableArray = collection.ActionStream.Variables.FirstOrDefault(v => v.Name == ClassData.ObjectVariableTag + i);
                if (objectVariableArray != null && objectVariableArray.Value is Csv.CsvArray csvArray && reference < csvArray.Values.Length)
                {
                    value = csvArray.Values[reference];
                }

                var type = Class.Variables[i].CodeType.GetCodeType(_deltinScript);

                variables[i] = new ChildDebugVariable(
                    // Child variable resolver
                    type.DebugVariableResolver ?? new DefaultResolver(),
                    // Value
                    value,
                    // Name
                    Class.Variables[i].Name,
                    // Type
                    type.GetName()
                    );
                collection.Add(variables[i]);
            }

            return(variables);
        }