Пример #1
0
        protected void AssertCorrectProjectConfigInfo(string expectedProjectType, string expectedFramework)
        {
            var info = ProjectConfigInfo.ReadProjectConfiguration();

            Assert.Equal(expectedProjectType, info.ProjectType);
            Assert.Equal(expectedFramework, info.Framework);
        }
        private void SetProjectConfigInfo()
        {
            var configInfo = ProjectConfigInfo.ReadProjectConfiguration();

            if (string.IsNullOrEmpty(configInfo.ProjectType) || string.IsNullOrEmpty(configInfo.Framework) || string.IsNullOrEmpty(configInfo.Platform))
            {
                var vm = new ProjectConfigurationViewModel();
                ProjectConfigurationDialog projectConfig = new ProjectConfigurationDialog(vm);
                projectConfig.Owner = WizardShell.Current;
                projectConfig.ShowDialog();

                if (vm.Result == DialogResult.Accept)
                {
                    configInfo.ProjectType = vm.SelectedProjectType.Name;
                    configInfo.Framework   = vm.SelectedFramework.Name;
                    configInfo.Platform    = vm.SelectedPlatform;
                    ProjectMetadataService.SaveProjectMetadata(configInfo);
                    ConfigFramework   = configInfo.Framework;
                    ConfigProjectType = configInfo.ProjectType;
                    ConfigPlatform    = configInfo.Platform;
                }
                else
                {
                    OnCancel();
                }
            }
            else
            {
                ConfigFramework   = configInfo.Framework;
                ConfigProjectType = configInfo.ProjectType;
                ConfigPlatform    = configInfo.Platform;
            }
        }
        private void SetProjectConfigInfo()
        {
            var configInfo = ProjectConfigInfo.ReadProjectConfiguration();

            if (string.IsNullOrEmpty(configInfo.ProjectType) || string.IsNullOrEmpty(configInfo.Framework))
            {
                var vm = new ProjectConfigurationViewModel();
                ProjectConfigurationDialog projectConfig = new ProjectConfigurationDialog(vm);
                projectConfig.ShowDialog();

                if (vm.Result == DialogResult.Accept)
                {
                    configInfo.ProjectType = vm.SelectedProjectType.Name;
                    configInfo.Framework   = vm.SelectedFramework.Name;
                    ProjectConfigInfo.SaveProjectConfiguration(configInfo.ProjectType, configInfo.Framework);
                    ConfigFramework   = configInfo.Framework;
                    ConfigProjectType = configInfo.ProjectType;
                }
                else
                {
                    OnCancel();
                }
            }
            else
            {
                ConfigFramework   = configInfo.Framework;
                ConfigProjectType = configInfo.ProjectType;
            }
        }
 private static void LoadProjectInfo()
 {
     __info = UnityEngine.Resources.Load <ProjectConfigInfo>(configName);
     if (__info == null)
     {
         Log.E("Open Project Config Window in WindowCollection");
     }
 }
Пример #5
0
    public static ProjectConfigInfo GetProjectConfig()
    {
        byte[] configBytes = LoadConfigFile("LocalConfig/" + ConfigFileName,
                                            ConfigFilePostfix);

        if (configBytes == null)
        {
            return(null);
        }

        string configStr = System.Text.Encoding.UTF8.GetString(configBytes);

        ProjectConfigInfo configInfo =
            LitJson.JsonMapper.ToObject <ProjectConfigInfo>(configStr);

        return(configInfo);
    }
Пример #6
0
        private void SetContext()
        {
            EnsureGenContextInitialized();
            if (GenContext.CurrentLanguage == _shell.GetActiveProjectLanguage())
            {
                var projectConfig = ProjectConfigInfo.ReadProjectConfiguration();
                if (projectConfig.Platform == Platforms.Uwp)
                {
                    DestinationPath = GenContext.ToolBox.Shell.GetActiveProjectPath();
                    ProjectName     = GenContext.ToolBox.Shell.GetActiveProjectName();
                }

                GenerationOutputPath   = GenContext.GetTempGenerationPath(ProjectName);
                ProjectInfo            = new ProjectInfo();
                FilesToOpen            = new List <string>();
                FailedMergePostActions = new List <FailedMergePostActionInfo>();
                MergeFilesFromProject  = new Dictionary <string, List <MergeInfo> >();
                ProjectMetrics         = new Dictionary <ProjectMetricsEnum, double>();

                GenContext.Current = this;
            }
        }
Пример #7
0
        private void SetProjectConfigInfo()
        {
            var configInfo = ProjectConfigInfo.ReadProjectConfiguration();

            if (string.IsNullOrEmpty(configInfo.ProjectType) || string.IsNullOrEmpty(configInfo.Framework))
            {
                InfoShapeVisibility = System.Windows.Visibility.Visible;
                ProjectConfigurationWindow projectConfig = new ProjectConfigurationWindow(MainView);
                if (projectConfig.ShowDialog().Value)
                {
                    configInfo.ProjectType = projectConfig.ViewModel.SelectedProjectType.Name;
                    configInfo.Framework   = projectConfig.ViewModel.SelectedFramework.Name;
                    InfoShapeVisibility    = System.Windows.Visibility.Collapsed;
                }
                else
                {
                    Cancel();
                }
            }
            ConfigFramework   = configInfo.Framework;
            ConfigProjectType = configInfo.ProjectType;
        }
Пример #8
0
#pragma warning restore CS0164

        private void DebugButton_Click(object sender, EventArgs e)
        {
            bool   outputSessionData = checkBox1.Checked;
            bool   parseCodeData     = checkBox2.Checked;
            bool   outputTextCode    = checkBox3.Checked;
            string fileName          = textBox2.Text;

            textBox1.Text = "正在处理...";

            new Task(() =>
            {
                try
                {
                    CodeSectionInfo codeSectionInfo         = null;
                    ResourceSectionInfo resourceSectionInfo = null;
                    LosableSectionInfo losableSectionInfo   = null;
                    Encoding encoding = Encoding.GetEncoding("gbk");
                    var output        = new StringBuilder();
                    using (var projectFileReader = new ProjectFileReader(File.OpenRead(fileName), InputPassword))
                    {
                        while (!projectFileReader.IsFinish)
                        {
                            var section = projectFileReader.ReadSection();
                            if (outputSessionData)
                            {
                                output.AppendLine("---------------" + section.Name + "---------------");
                                output.AppendLine("CanSkip: " + section.CanSkip.ToString());
                                output.AppendLine("Key: 0x" + section.Key.ToString("X8"));
                                output.Append("Data: ");
                            }
                            switch (section.Key)
                            {
                            case ESystemInfo.SectionKey:
                                {
                                    var systemInfo = ESystemInfo.Parse(section.Data);
                                    encoding       = systemInfo.Encoding;
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(systemInfo.ToString());
                                    }
                                }
                                break;

                            case ProjectConfigInfo.SectionKey:
                                {
                                    var projectConfig = ProjectConfigInfo.Parse(section.Data, encoding);
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(projectConfig.ToString());
                                    }
                                }
                                break;

                            case CodeSectionInfo.SectionKey:
                                codeSectionInfo = CodeSectionInfo.Parse(section.Data, encoding, projectFileReader.CryptEc);
                                if (outputSessionData)
                                {
                                    output.AppendLine(codeSectionInfo.ToString());
                                }
                                break;

                            case EPackageInfo.SectionKey:
                                {
                                    var packageInfo = EPackageInfo.Parse(section.Data, encoding);
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(packageInfo.ToString());
                                    }
                                }
                                break;

                            case ResourceSectionInfo.SectionKey:
                                resourceSectionInfo = ResourceSectionInfo.Parse(section.Data, encoding);
                                if (outputSessionData)
                                {
                                    output.AppendLine(resourceSectionInfo.ToString());
                                }
                                break;

                            case InitEcSectionInfo.SectionKey:
                                {
                                    var initEcSectionInfo = InitEcSectionInfo.Parse(section.Data, encoding);
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(initEcSectionInfo.ToString());
                                    }
                                }
                                break;

                            case LosableSectionInfo.SectionKey:
                                {
                                    losableSectionInfo = LosableSectionInfo.Parse(section.Data, encoding);
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(losableSectionInfo.ToString());
                                    }
                                }
                                break;

                            case FolderSectionInfo.SectionKey:
                                {
                                    var folderSectionInfo = FolderSectionInfo.Parse(section.Data, encoding);
                                    if (outputSessionData)
                                    {
                                        output.AppendLine(folderSectionInfo.ToString());
                                    }
                                }
                                break;

                            default:
                                if (outputSessionData)
                                {
                                    output.AppendLine("{");
                                    output.Append("  \"Unknown\": \"");
                                    output.Append(section.Data.ToHexString());
                                    output.AppendLine("\"");
                                    output.AppendLine("}");
                                }
                                break;
                            }
                        }
                        if (parseCodeData)
                        {
                            output.AppendLine("<<<<<<<<<<<<<<<ParseTest>>>>>>>>>>>>>>>");
                            foreach (var method in codeSectionInfo.Methods)
                            {
                                output.AppendLine($"###Method: {(string.IsNullOrEmpty(method.Name) ? "Unknown" : method.Name)}{$"Id: {method.Id})###"}");
                                try
                                {
#pragma warning disable CS0612 // 类型或成员已过时
                                    var block = CodeDataParser.ParseStatementBlock(method.CodeData.ExpressionData, encoding, out var lineOffest, out var blockOffest);
#pragma warning restore CS0612 // 类型或成员已过时
                                    var GenCodeData = block.ToCodeData(encoding);
                                    output.Append("Raw: ");
                                    output.AppendLine(method.CodeData.ToString());
                                    output.Append("FullRewrite: ");
                                    output.AppendLine(GenCodeData.ToString());
                                    output.Append("OldOffestRepairer: ");
                                    output.AppendLine("{");
                                    output.AppendLine("  \"LineOffest\": \"" + lineOffest.ToHexString() + "\"");
                                    output.AppendLine("  \"BlockOffest\": \"" + blockOffest.ToHexString() + "\"");
                                    output.AppendLine("}");
                                }
                                catch (Exception exception)
                                {
                                    output.AppendLine("出现错误:");
                                    output.AppendLine(exception.ToString());
                                    output.AppendLine();
                                }
                            }
                        }
                        if (outputTextCode)
                        {
                            output.AppendLine("<<<<<<<<<<<<<<<TextCode>>>>>>>>>>>>>>>");
                            var nameMap = new IdToNameMap(codeSectionInfo, resourceSectionInfo, losableSectionInfo);
                            output.AppendLine(".版本 2");
                            output.AppendLine();
                            output.AppendLine(codeSectionInfo.ToTextCode(nameMap));
                            output.AppendLine(resourceSectionInfo.ToTextCode(nameMap));
                        }
                    }
                    Invoke(new Action(() =>
                    {
                        textBox1.Text = output.ToString();
                    }));
                }
                catch (Exception exception)
                {
                    Invoke(new Action(() =>
                    {
                        textBox1.Text = $"出现错误:\r\n{exception}\r\n请加群后将文件发送给作者以便修复此问题";
                    }));
                }
            })
            .Start();
        }