Exemple #1
0
        private void WriteIdFile(PhactoryHost.Database.Resource resource)
        {
            var destFilename = Host.GetFileInfo(resource).FullName + ".h";

            App.Controller.UserConfig.AddExistingResourceFullPath = destFilename;

            string relativePath = StringHelper.MakeRelativePath(destFilename);

            PhactoryHost.Database.Resource idResource = Host.GuessResource(new FileInfo(destFilename));
            if (idResource == null)
            {
                idResource              = new PhactoryHost.Database.Resource();
                idResource.Id           = App.Controller.Entities.CreateNewResourceId();
                idResource.DisplayName  = new FileInfo(destFilename).Name;
                idResource.RelativePath = relativePath;
                App.Controller.Entities.AddResource(idResource);

                App.Controller.CreateNewResource(idResource);

                var project = Host.GetEntities();

                Node folderNode = null;
                project.GetParentFolderTreeNode(project.TreeNode, ref folderNode, resource);
                if (folderNode != null)
                {
                    Node childTreeNode = new Node();
                    childTreeNode.IsFolder   = false;
                    childTreeNode.ResourceId = idResource.Id;

                    folderNode.ChildNodes.Add(childTreeNode);
                }

                App.Controller.SaveProject();
                Host.RefreshDB();
            }

            File.Delete(destFilename);
            WriteIdFileContent(resource, destFilename);

            Host.Log(idResource.DisplayName + " written");
        }