Пример #1
0
        public static void OpenProject(string file)
        {
            if (isProjectOpened)
            {
                throw new InvalidOperationException("A project has already been opened. ");
            }

            try
            {
                projectFile     = file;
                projectDir      = System.IO.Path.GetDirectoryName(file);
                projectDocument = new ProjectDocumentFile(file);
                components      = new Dictionary <string, object>();
                ResourceManager.SearchPaths.Add(projectDir);
                foreach (var item in projectDocument.Components)
                {
                    if (item.Attributes["ID"] != null)
                    {
                        var dict = new Dictionary <string, object>();
                        foreach (XmlNode property in item.ChildNodes)
                        {
                            if (property.HasChildNodes && property.ChildNodes.Count == 1 && (property.FirstChild is XmlText))
                            {
                                dict.Add(
                                    property.Attributes["Name"].Value,
                                    property.FirstChild.Value
                                    );
                            }
                            else
                            {
                                dict.Add(
                                    property.Attributes["Name"].Value,
                                    property.ChildNodes
                                    );
                            }
                        }

                        try
                        {
                            components.Add(
                                item.Attributes["ID"].Value,
                                NekoKun.Core.ReflectionHelper.CreateInstanceFromTypeName(item.Attributes["Name"].Value, dict)
                                );
                        }
                        catch (TypeLoadException)
                        {
                        }
                    }
                }

                isProjectOpened = true;
            }
            catch (Exception e)
            {
                Clean();
                NekoKun.Core.Application.Logger.Log(NekoKun.Core.ExceptionHelper.ExceptionMessage(e));
                CannotOpenProjectException j = new CannotOpenProjectException(string.Format("Error when opening {0}", file), e);
                throw j;
            }
        }
Пример #2
0
 private static void Clean()
 {
     isProjectOpened = false;
     projectDocument = null;
     projectDir      = null;
     projectFile     = null;
     components      = null;
 }
Пример #3
0
 public ProjectDocumentFileEditor(ProjectDocumentFile file)
     : base(file)
 {
 }
Пример #4
0
        public static void OpenProject(string file)
        {
            if (isProjectOpened)
                throw new InvalidOperationException("A project has already been opened. ");

            try
            {
                projectFile = file;
                projectDir = System.IO.Path.GetDirectoryName(file);
                projectDocument = new ProjectDocumentFile(file);
                components = new Dictionary<string, object>();
                ResourceManager.SearchPaths.Add(projectDir);
                foreach (var item in projectDocument.Components)
                {
                    if (item.Attributes["ID"] != null)
                    {
                        var dict = new Dictionary<string, object>();
                        foreach (XmlNode property in item.ChildNodes)
                        {
                            if (property.HasChildNodes && property.ChildNodes.Count == 1 && (property.FirstChild is XmlText))
                                dict.Add(
                                    property.Attributes["Name"].Value,
                                    property.FirstChild.Value
                                );
                            else
                                dict.Add(
                                    property.Attributes["Name"].Value,
                                    property.ChildNodes
                                );

                        }

                        try
                        {
                            components.Add(
                                item.Attributes["ID"].Value,
                                NekoKun.Core.ReflectionHelper.CreateInstanceFromTypeName(item.Attributes["Name"].Value, dict)
                            );
                        }
                        catch (TypeLoadException)
                        {
                        }

                    }
                }

                isProjectOpened = true;
            }
            catch (Exception e)
            {
                Clean();
                NekoKun.Core.Application.Logger.Log(NekoKun.Core.ExceptionHelper.ExceptionMessage(e));
                CannotOpenProjectException j = new CannotOpenProjectException(string.Format("Error when opening {0}", file), e);
                throw j;
            }
        }
Пример #5
0
 private static void Clean()
 {
     isProjectOpened = false;
     projectDocument = null;
     projectDir = null;
     projectFile = null;
     components = null;
 }