Exemple #1
0
        public EditorField(EditorSession session, FieldInformation field, JProperty json)
        {
            Session = session;
            Field   = field;

            if (field.Type != "JObject")
            {
                FieldType = session.Manifest.GetTypeInformation(field.Type);
                if (FieldType == null)
                {
                    throw new InvalidOperationException($"Failed to find type for {field.Type}");
                }
            }
            else
            {
                string typeName = json.Parent["Type"].ToString();
                FieldType = session.Manifest.GetTypeInformation(typeName);
                if (FieldType == null)
                {
                    throw new InvalidOperationException($"Failed to find type for {typeName}");
                }
            }

            this.json = json;
            features  = new List <object>();

            valueInternal = session.CreateValue(FieldType, field.Wrapper, json.Value);
        }
        public EditorKeyValuePair(EditorSession session, TypeInformation valueType, JProperty json)
        {
            Session   = session;
            ValueType = valueType;

            this.json = json;

            Value = session.CreateValue(valueType, null, json.Value);
        }
        private IEnumerable <EditorField> AllFields(IEditorValue root)
        {
            if (root is EditorObject editorObject)
            {
                foreach (var field in editorObject.Fields)
                {
                    yield return(field.Value);

                    foreach (var childField in AllFields(field.Value.Value))
                    {
                        yield return(childField);
                    }
                }
            }
        }
Exemple #4
0
        private IEditorValue CreateWrapper(Type controlType, EditEntryFormMode mode, string propertyName)
        {
            IEditorValue control = Activator.CreateInstance(controlType) as IEditorValue;

            if (control == null)
            {
                return(null);
            }
            LinkLabelTextBox linkLabelTextBox = control as LinkLabelTextBox;

            if (linkLabelTextBox != null)
            {
                linkLabelTextBox.DataChanged = DataChanged;
            }
            control.Mode         = mode;
            control.Data         = _entry;
            control.PropertyName = propertyName;
            control.Type         = _type;
            return(control);
        }
        private static void DrawValue(IEditorValue editorValue, int indent = 1)
        {
            if (editorValue is EditorValue editableValue)
            {
                var rendered = editableValue.ToString();
                if (string.IsNullOrEmpty(rendered))
                {
                    TestContext.Error.WriteLine("null");
                }
                else
                {
                    TestContext.Error.WriteLine($"{editableValue}");
                }
            }
            else if (editorValue is EditorObject editorObject)
            {
                DrawTree(editorObject, indent + 1);
            }
            else if (editorValue is EditorDictionary editorDictionary)
            {
                foreach (var element in editorDictionary.KeyValuePairs)
                {
                    TestContext.Error.Write($"[\"{element.Key}\"] = ");
                    DrawValue(element.Value.Value, indent);
                }
            }
            else if (editorValue is EditorList editorList)
            {
                for (int i = 0; i < editorList.Elements.Count; i++)
                {
                    var element = editorList.Elements[i];
                    TestContext.Error.Write($"[{i}] = ");

                    DrawValue(element, indent);
                }
            }
        }