Exemplo n.º 1
0
        private void PasteItems(bool copy)
        {
            Type listOf = GetFirstGenericType(CurrentList);

            if (listOf == null)
            {
                return;
            }
            object str = Clipboard.GetData(listOf.FullName);

            if (!(str is string))
            {
                return;
            }
            IWritableContext context = CreateRootContext();
            DataObjectList   objs    = Json.JsonSerializer.fromJson((string)str, copy, context) as DataObjectList;

            if (objs == null)
            {
                return;
            }

            int index = listBoxList.SelectedIndex + 1;

            AddItems(objs, index, true);
        }
Exemplo n.º 2
0
        private IWritableContext CreateRootContext()
        {
            DataObjectEditor parent = this;

            while (parent.parent != null)
            {
                parent = parent.parent;
            }
            Json.DataObject  root    = parent.DataObject;
            IWritableContext context = JsonSerializer.createContext(root);

            return(context);
        }
Exemplo n.º 3
0
        private IContext SetupContext(
            SegmentConfiguration segmentConfiguration,
            int segmentIndex,
            int segmentCount,
            IBootstrapper bootstrapper,
            ISafeRepository safeRepository)
        {
            IContext context =
                this
                .GetContextFactory(safeRepository)
                .CreateContext(
                    bootstrapper,
                    segmentConfiguration,
                    segmentIndex,
                    segmentCount,
                    this.runData);
            IWritableContext writableContext = bootstrapper.Get <IWritableContext>();

            writableContext.SetContext(context);
            return(context);
        }
Exemplo n.º 4
0
        public static DataObject fromJson(String json, bool copy = false, IWritableContext context = null)
        {
            if (json == null || json.Length == 0)
            {
                return(null);
            }
            JsonSerializer serializer = new JsonSerializer();

            serializer.write     = false;
            serializer.copyGuids = copy;
            if (context != null)
            {
                serializer.context = context;
            }
            DataObject obj = serializer.read(new JsonObject(json));

            if (copy)
            {
                serializer.UpdateReferences();
            }
            return(obj);
        }
Exemplo n.º 5
0
        private void ImportItems()
        {
            IList list = CurrentList;

            if (list == null)
            {
                return;
            }
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string file = this.openFileDialog.FileName;
                    if (!File.Exists(file))
                    {
                        return;
                    }
                    string           content = File.ReadAllText(file);
                    IWritableContext context = CreateRootContext();
                    var obj = ObjectEditor.Json.JsonSerializer.fromJson(content, true, context);

                    DataObjectList objs = obj as DataObjectList;
                    if (objs == null)
                    {
                        objs = new DataObjectList();
                        objs.Add(obj);
                    }

                    int index = this.listBoxList.SelectedIndex;
                    AddItems(objs, index + 1, true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    MessageBox.Show("Unable to import file");
                }
            }
        }
 /// <inheritdoc />
 public OnUpdateBeforeSaveChangesStep(IWritableContext context)
 {
     Context = context;
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 public OnCreateAfterSaveChangesStep(IWritableContext context)
 {
     Context = context;
 }
 /// <inheritdoc />
 public OnUpdateBeforeMappingStep(IWritableContext context)
 {
     Context = context;
 }
Exemplo n.º 9
0
 /// <inheritdoc />
 public OnCreateBeforeAnyValidationsStep(IWritableContext context)
 {
     Context = context;
 }
Exemplo n.º 10
0
 public Context(IWritableContext writableContext)
 {
     this.writableContext = writableContext;
 }
Exemplo n.º 11
0
 public static T fromJson <T>(String json, bool copy = false, IWritableContext context = null) where T : DataObject
 {
     return((T)fromJson(json, copy, context));
 }
 /// <inheritdoc />
 public OnUpdateAfterSaveChangeStep(IWritableContext context)
 {
     Context = context;
 }