Exemplo n.º 1
0
 public void Save(PersistableObject obj, int version)
 {
     using (var writer = new BinaryWriter(File.Open(savePath, FileMode.Create))) {
         writer.Write(-version);
         obj.Save(new GameDataWriter(writer));
     }
 }
Exemplo n.º 2
0
    public void Load(PersistableObject o)
    {
        Debug.Log("Loading file: " + this.savePath);

        #if UNITY_WEBGL
        if (!PlayerPrefs.HasKey("0"))
        {
            Debug.Log("First time playing. Loading canceled!");
            return;
        }

        o.Load(new GameDataReader(null));
        #else
        if (!File.Exists(this.savePath))
        {
            Debug.Log("First time playing. Loading canceled!");
            return;
        }

        using (
            var reader = new BinaryReader(File.Open(savePath, FileMode.Open))
            ) {
            o.Load(new GameDataReader(reader));
        }
        #endif
    }
Exemplo n.º 3
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Requirement";
            return(obj);
        }
Exemplo n.º 4
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = new ReportableObject();

            obj.Type = "Test Step";
            return(obj);
        }
 public void Load(PersistableObject pO)
 {
     using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open)))
     {
         pO.Load(new GameDataReader(reader, -reader.ReadInt32()));
     }
 }
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Module Attribute";
            return(obj);
        }
Exemplo n.º 7
0
        public override object Execute(PersistableObject obj, ITaskContext context)
        {
            var filePath = context.GetFilePath("Save ElementJs", false, "%TOSCA_PROJECTS%", false, "ts", true);

            context.ShowWaitCursor();
            context.ShowProgressInfo(100, 10, "Generating Json");
            var toscaJson = FloodToolHelper.ExecutionToJson(obj);

            try
            {
                context.ShowProgressInfo(100, 40, "Generating Element Script");
                var     jsonPostResponse = FloodToolHelper.MessagePost(Tosca2ElementUrl + "/generate", toscaJson);
                dynamic postResponse     = JsonConvert.DeserializeObject(jsonPostResponse);
                var     downloadPath     = postResponse.scripts[0];

                context.ShowProgressInfo(100, 70, "Downloading Element Script");
                var elementJs = FloodToolHelper.MessageGet(Tosca2ElementUrl + downloadPath);

                context.ShowProgressInfo(100, 90, "Saving Element Script");
                File.AppendAllText(filePath, elementJs);

                context.ShowProgressInfo(100, 100, "Element Script successfully generated");
            }
            catch (Exception e)
            {
                context.ShowErrorMessage("Error", "The element script could not be generated. " +
                                         "Check your internet conection or try it manually at https://tosca2element.flood.io \r\n" +
                                         "Error: '" + e.Message + "'");
            }

            context.HideWaitCursor();

            return(null);
        }
Exemplo n.º 8
0
    public void Load(PersistableObject o)
    {
        byte[] data   = File.ReadAllBytes(savePath);
        var    reader = new BinaryReader(new MemoryStream(data));

        o.Load(new GameDataReader(reader, -reader.ReadInt32()));
    }
Exemplo n.º 9
0
    public void Load(PersistableObject obj)
    {
        byte[] data   = File.ReadAllBytes(savePath);
        var    reader = new BinaryReader(File.Open(savePath, FileMode.Open));

        obj.Load(new GameDataReader(reader, reader.ReadInt32()));
    }
Exemplo n.º 10
0
        public override int ColumnSettingForDetailView(PersistableObject obj)
        {
            switch (obj.GetType().Name)
            {
            case "TCFolder":
                TCFolder folder = obj as TCFolder;
                if (folder != null)
                {
                    TCFolderPolicy policy = folder.ContentPolicy;
                    if (policy.OnlyTestCaseDesignAllowed)
                    {
                        return((int)ColumnsSetting.TestCaseDesign);
                    }
                }
                break;

            default:
                if (obj.GetType().Assembly == this.GetType().Assembly)
                {
                    return((int)ColumnsSetting.TestCaseDesign);
                }
                break;
            }
            return((int)ColumnsSetting.Unknown);
        }
Exemplo n.º 11
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Execution Log";
            return(obj);
        }
Exemplo n.º 12
0
        public static string ExecutionToJson(PersistableObject obj)
        {
            var executionTaskBuilder = new ExecutionTaskBuilder();
            var executionEntries     = new List <ExecutionEntry>();
            var executionTasks       = new List <ExecutionTask>();

            if (obj is ExecutionEntryFolder folder)
            {
                executionEntries = folder.GetAllExecutionEntries().Where(e => !e.Disabled).ToList();
            }

            if (obj is ExecutionList list)
            {
                executionEntries = list.AllExecutionEntries.Where(e => !e.Disabled).ToList();
            }

            if (obj is ExecutionEntry entry)
            {
                executionEntries = new List <ExecutionEntry> {
                    entry
                };
            }

            executionTasks = executionEntries.Select(e => executionTaskBuilder.Build(e, true)).ToList();

            var jsonText = AutomationObjectsSerializer.Serialize(executionTasks);

            return(jsonText);
        }
Exemplo n.º 13
0
    public void Load(GameDataReader reader)
    {
        // get world position
        //GetComponent<Camera>().getWorldPosition();

        int count = reader.ReadInt();

        Debug.Log("Count is: " + count);
        for (int i = 0; i < count; i++)
        {
            // need to handle differenct objects
            Debug.Log("Load object:" + i);

            // todo - check for type to decide if text should be read or not (else we will get corrupt readings from file)
            PersistableObject o = new PersistableObject();
            o.Load(reader);
            objects.Add(o);


            // Add obj to map (need cloud anchors)
            TextObj.transform.localPosition = o.localPosition;
            TextObj.transform.localRotation = o.localRotation;
            TextObj.transform.localScale    = o.localScale;

            TextObj.transform.GetChild(0).GetComponent <TMP_Text>().text = "I AM AT INDEX " + i;

            Instantiate(TextObj);
        }
    }
Exemplo n.º 14
0
    public void Load(PersistableObject o)
    {
        byte[]       data   = File.ReadAllBytes(savePath);
        BinaryReader reader = new BinaryReader(new MemoryStream(data));

        o.Load(new GameDataReader(reader)); // Load Version
    }
Exemplo n.º 15
0
        protected override void HandleAspectChangedNow(ChangeAspect changedAspect, PersistableObject changedObject)
        {
            base.HandleAspectChangedNow(changedAspect, changedObject);

            // detect name and value change, keep in mind you want the ORIGINAL NAME (so upon creation it might be null which is fine)
            string aspectName = changedAspect.Name;
            string objName    = changedObject.DisplayedName;
            string objValue   = changedObject.GetAttributeValue("Value") as string;

            if (aspectName == "Buffer.Value")   // Change value of buffer
            {
                Helper.UpdateBufferValue(objName, objValue);
            }
            else if (aspectName == "NamedObject.Name")   // changeAspect.Name
            {
                if (!Helper.BufferExists(objName))
                {
                    Helper.SaveNewBuffer(objName, objValue);
                }
                else
                {
                    Helper.UpdateBufferValue(objName, objValue);
                }
            }
            else if (aspectName == "PersistableObject.Deleting")   // Delete buffers from xml
            {
                Helper.DeleteBuffer(objName);
            }
        }
Exemplo n.º 16
0
        public override ReportableObject Convert(PersistableObject toscaObject)
        {
            ReportableObject obj = base.Convert(toscaObject);

            obj.Type = "Test Step Value";
            return(obj);
        }
Exemplo n.º 17
0
 public void Save(PersistableObject o)
 {
     using (var writer = new BinaryWriter(File.Open(savePath, FileMode.Create)))
     {
         o.Save(new GameDataWriter(writer));
     }
 }
Exemplo n.º 18
0
 public void Load(PersistableObject o)
 {
     using (var reader = new BinaryReader(File.Open(savePath, FileMode.Open)))
     {
         o.Load(new GameDataReader(reader));
     }
 }
Exemplo n.º 19
0
 public override object Execute(PersistableObject obj, ITaskContext context)
 {
     if (!TaskPossibleForProject(obj) /*&& !IsPossibleFor(obj)*/)
     {
         return(null);
     }
     return(CreateNewFolder(obj, context));
 }
 public override void GetTasks(PersistableObject obj, List <Task> tasks)
 {
     if (obj is ExecutionList)
     {
         tasks.Add(TaskFactory.Instance.GetTask <ExportAutomationObjectsJsonTask>());
         tasks.Add(TaskFactory.Instance.GetTask <ExportElementJsTask>());
     }
 }
Exemplo n.º 21
0
 public override void GetTasks(PersistableObject obj, List <TCCore.Persistency.Task> tasks)
 {
     if (!CreateBuffertopFolderTask.TaskPossibleForProject(obj))
     {
         return;
     }
     tasks.Add(TaskFactory.Instance.GetTask(typeof(CreateBuffertopFolderTask)));
 }
Exemplo n.º 22
0
    public void Load(PersistableObject o)
    {
        //load에서 using을 활용하면, game에서 코루틴을 활용한 load에 문제가 생기므로, buffer를 사용해서 임시로 데이터 저장
        byte[] data   = File.ReadAllBytes(savePath);
        var    reader = new BinaryReader(new MemoryStream(data));

        o.Load(new GameDataReader(reader, -reader.ReadInt32()));
    }
Exemplo n.º 23
0
 public override void GetTasks(PersistableObject obj, List <TCCore.Persistency.Task> tasks)
 {
     if (CreateBufferTask.IsTaskPossible(obj as TCFolder))
     {
         tasks.Add(TaskFactory.Instance.GetTask(typeof(CreateBufferTask)));
         tasks.Add(TaskFactory.Instance.GetTask(typeof(ReloadBuffersTask)));
     }
 }
 public override void GetTasks(PersistableObject obj, List <Task> tasks)
 {
     if (!AssistantTask.IsPossibleForObject(obj))
     {
         return;
     }
     tasks.Add(TaskFactory.Instance.GetTask(typeof(AssistantTask)));
 }
Exemplo n.º 25
0
 public override void CreateTopFolder(PersistableObject obj)
 {
     if (CreateBuffertopFolderTask.TaskPossibleForProject(obj))
     {
         Task task = TaskFactory.Instance.GetTask(typeof(CreateBuffertopFolderTask));
         task.Execute(obj, null);
     }
 }
        public override object Execute(PersistableObject obj, ITaskContext context)
        {
            var filePath = context.GetFilePath("Save AutomationObjects", false, "%TOSCA_PROJECTS%", false, "json", true);
            var jsonText = FloodToolHelper.ExecutionToJson(obj);

            File.AppendAllText(filePath, jsonText);

            return(null);
        }
Exemplo n.º 27
0
 public void Save(PersistableObject o)
 {
     using (  //automatically handle exception of closing file
         BinaryWriter writer = new BinaryWriter(File.Open(savePath, FileMode.Create))
         )
     {
         o.Save(new GameDataWriter(writer));
     }
 }
Exemplo n.º 28
0
 public void Load(PersistableObject o)
 {
     using (  //automatically handle exception of closing file
         BinaryReader reader = new BinaryReader(File.Open(savePath, FileMode.Open))
         )
     {
         o.Load(new GameDataReader(reader));
     }
 }
 public void Save(PersistableObject o, int version)
 {
     using (
         var writer = new BinaryWriter(File.Open(savePath, FileMode.Create))
         ) {
         writer.Write(-version);              // do no confuse count (from a previous save) and version -> save version as negative.
         o.Save(new GameDataWriter(writer));
     }
 }
 public void Save(PersistableObject obj)
 {
     // The using (something) {} format will dispose of the something after the code block even if an exception occurs
     // Basically it's shorthand for a try catch block, only works with IDisposable types
     using (var writer = new BinaryWriter(File.Open(_savePath, FileMode.Create)))
     {
         obj.Save(new GameDataWriter(writer));
     }
 }