Exemple #1
0
        public static void Export(string filePath, CustomObject[] customObjects, CustomObjectExportOptions options)
        {
            var export = new CustomObjectExport()
            {
                ExportDate = DateTime.UtcNow,
                Name       = options.ExportName
            };

            export.Data.CustomObjects.AddRange(customObjects);
            export.Data.EmbeddedFiles = options.EmbeddedFiles;
            export.Data.Script        = options.Script;

            foreach (var cobj in customObjects)
            {
                if (cobj.BehaviorProps.Behavior is object && !cobj.BehaviorProps.Behavior.IsVanilla)
                {
                    var behav = cobj.BehaviorProps.Behavior.FindBehavior();
                    if (behav is object)
                    {
                        export.Data.Behaviors.AddIfNotContainsKey(cobj.BehaviorProps.Behavior, behav);
                    }
                }

                if (cobj.ModelProps is object)
                {
                    var mdl = cobj.ModelProps.Model?.FindModel();
                    if (mdl is object)
                    {
                        export.Data.CustomModels.AddIfNotContainsKey(cobj.ModelProps.Model, mdl);
                    }
                }
            }

            export.Compress();
            export.ID.Generate();

            File.WriteAllText(filePath, JObject.FromObject(export).ToString());
        }
Exemple #2
0
 public static void Export(string filePath, CustomObject customObject, CustomObjectExportOptions options)
 {
     Export(filePath, new CustomObject[] { customObject }, options);
 }
Exemple #3
0
 public void Export(string filePath, CustomObjectExportOptions options)
 {
     Export(filePath, CustomObjects.ToArray(), options);
 }