private void FindToken() { try { if (String.IsNullOrEmpty(txtOldToken.Text)) { string file = PathUtils.GetFullFileName(_rows, 0, _sourceDir); if (!String.IsNullOrEmpty(file)) { string token = GetFirstPublicKeyToken(file); if (!String.IsNullOrEmpty(token)) { txtOldToken.Text = token; } } } string fileName = _replKeyFile; if (!String.IsNullOrEmpty(fileName) && File.Exists(fileName)) { txtNewToken.Text = TokenUtils.GetPublicKeyTokenString(TokenUtils.GetPublicKeyTokenFromKeyFile(fileName)); } else { txtNewToken.Text = String.Empty; } } catch (Exception ex) { SimpleMessage.ShowException(ex); } }
public void CheckDropFile(string droppedFile) { if (droppedFile != null) { _fileDrop = droppedFile; } try { if (!String.IsNullOrEmpty(_fileDrop)) { for (int i = 0; i < dgvData.Rows.Count; i++) { string fileName = PathUtils.GetFullFileName(dgvData.Rows, i, treeView1.SelectedNode.FullPath); if (_fileDrop.Equals(fileName, StringComparison.OrdinalIgnoreCase)) { dgvData.CurrentCell = dgvData.Rows[i].Cells[0]; if (Config.ClassEditorAutoOpenDroppedAssemblyEnabled) { _form.cmClassEditor_Click(null, null); } break; } } } } catch { throw; } finally { _fileDrop = null; } }
private void cmProfiler_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count < 1) { SimpleMessage.ShowInfo("Please select assembly to profile."); return; } try { string appFile = PathUtils.GetFullFileName(dgvData.SelectedRows, 0, treeView1.SelectedNode.FullPath); frmProfilerApp frm = new frmProfilerApp(appFile); frm.Show(); } catch (Exception ex) { SimpleMessage.ShowException(ex); } }
public virtual void Go() { var rows = Options.Rows; //no rows if (rows == null || rows.Length == 0 || Options.IgnoreRows) { try { ShowStartTextInfo(); Go(String.Empty); } catch { throw; } finally { ShowCompleteTextInfo(); } return; } //has rows bool showProgress = (rows != null && rows.Length > 1); try { ShowStartTextInfo(); if (showProgress) { InitProgress(rows.Length); } for (int i = 0; i < rows.Length; i++) { string fileName = PathUtils.GetFullFileName(rows, i, Options.SourceDir); if (String.IsNullOrEmpty(fileName)) { continue; } fileName = GetSourceFile(fileName); SetStatusText(String.Format("Processing {0} ...", fileName)); if (Options.ShowFileNoTextInfo) { AppendTextInfo(String.Format("\r\nFile: {0}\r\n", i + 1)); } Go(fileName); //if (Options.ShowFileNoTextInfo) //{ //AppendTextInfo("\r\n\r\n"); //} if (showProgress) { SetProgress(i + 1); } } } catch { throw; } finally { if (showProgress) { ResetProgress(); } ShowCompleteTextInfo(); } }
private void Sign() { SN sn = new SN(Options); sn.ShowStartTextInfo(); string keyFile = Options.KeyFile; StrongNameKeyPair snkp = null; try { using (FileStream fs = new FileStream(keyFile, FileMode.Open, FileAccess.Read)) { snkp = new StrongNameKeyPair(fs); } } catch { throw; } string[] rows = Options.Rows; for (int i = 0; i < rows.Length; i++) { string file = PathUtils.GetFullFileName(rows, i, Options.SourceDir); Sign(file, snkp); } foreach (string file in _allAssemblies.Keys) { AssemblyDefinition ad = _allAssemblies[file]; FixAssemblyNameReference(ad, snkp); ad = null; } //we free something to release memory, use lots of memory... _changedAssemblies.Clear(); string[] keys = new string[_allAssemblies.Count]; int count = 0; foreach (object key in _allAssemblies.Keys) { keys[count] = key as string; count++; } for (int i = 0; i < keys.Length; i++) { string file = keys[i]; AssemblyDefinition ad = _allAssemblies[file]; #region get output file string outputFile; if (Options.chkOverwriteOriginalFileChecked) { outputFile = file; } else if (Options.SourceDir == Options.OutputDir) { outputFile = Path.ChangeExtension(file, ".SN" + Path.GetExtension(file)); } else { outputFile = Path.Combine(Options.OutputDir, Path.GetFileName(file)); } #endregion get output file Options.AppendTextInfo(String.Format("Saving assembly: {0}\r\n", ad.Name.Name)); ad.Write(outputFile); Resign(outputFile, keyFile); _allAssemblies.Remove(file); ad = null; } sn.ShowCompleteTextInfo(); }