Example #1
0
 public INodeDataGenerator GetNode(Id <NodeTypeTemp> guid)
 {
     if (m_nodes.ContainsKey(guid))
     {
         return(m_nodes[guid].Item2);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        private void TryAddToLoadList(List <Tuple <Id <FileInProject>, DocumentPath, TElement> > toLoad, Id <FileInProject> fileId, DocumentPath path)
        {
            if (!FileLocationOk(path.AbsolutePath))
            {
                throw new InvalidOperationException("Attempting to load file that is not in a subfolder of the project's parent folder");
            }

            //var existing = m_data.FirstOrDefault(e => e.File.File.FullName == fileInfo.FullName);
            var existing = m_data.ContainsKey(fileId) ? m_data[fileId] : null;

            if (existing != null)
            {
                try
                {
                    if (existing.File.CanClose())
                    {
                        //Ignore the fact that the new file might be missing stuff the conversation needs
                        m_data.Remove(fileId); //Callback on the list informs the domain file it has been removed thereby triggering domain update
                        toLoad.Add(Tuple.Create(fileId, path, existing));
                    }
                    else
                    {
                        //Don't try to load it
                    }
                }
                catch (MyFileLoadException e)
                {
                    Console.Out.WriteLine(e.Message);
                    Console.Out.WriteLine(e.StackTrace);
                    Console.Out.WriteLine(e.InnerException.Message);
                    Console.Out.WriteLine(e.InnerException.StackTrace);
                    MessageBox.Show("Failed to access " + existing.File.File.FullName + " for saving");
                    //Don't try to load it
                }
            }
            else
            {
                toLoad.Add(new Tuple <Id <FileInProject>, DocumentPath, TElement>(fileId, path, null));
            }
        }