public void ListLine3Matches() { string expected = " A third value with leading and trailing whitespace "; ListFile file = new ListFile(string.Concat(Constants.TestData.DBFILEPATHS[0])); Assert.AreEqual(expected, file.Data[2]); }
public MonoTorrentClient(string applicationDataDirectoryPath) { // Make directories. var monoTorrentClientApplicationDataDirectoryPath = Path.Combine(applicationDataDirectoryPath, this.GetType().Name); if (!Directory.Exists(monoTorrentClientApplicationDataDirectoryPath)) { Directory.CreateDirectory(monoTorrentClientApplicationDataDirectoryPath); } TorrentFileDirectory = Path.Combine(monoTorrentClientApplicationDataDirectoryPath, "torrents"); if (!Directory.Exists(TorrentFileDirectory)) { Directory.CreateDirectory(TorrentFileDirectory); } BrokenTorrentFileDirectory = Path.Combine(monoTorrentClientApplicationDataDirectoryPath, "broken"); if (!Directory.Exists(BrokenTorrentFileDirectory)) { Directory.CreateDirectory(BrokenTorrentFileDirectory); } // Make files. DHTNodeFile = Path.Combine(monoTorrentClientApplicationDataDirectoryPath, "dhtNodes"); FastResumeFile = Path.Combine(monoTorrentClientApplicationDataDirectoryPath, "fastResume"); TorrentMappingsCacheFile = Path.Combine(monoTorrentClientApplicationDataDirectoryPath, "torrentMappingsCache"); // Make mappings cache. TorrentMappingsCache = new ListFile <TorrentMapping> (TorrentMappingsCacheFile); // Make default torrent settings. DefaultTorrentSettings = new TorrentSettings(DefaultTorrentUploadSlots, DefaultTorrentOpenConnections, 0, 0); }
public void ListLine2Matches() { string expected = "Another value"; ListFile file = new ListFile(string.Concat(Constants.TestData.DBFILEPATHS[0])); Assert.AreEqual(expected, file.Data[1]); }
public MonoTorrentClient(string applicationDataDirectoryPath) { // Make directories. var monoTorrentClientApplicationDataDirectoryPath = Path.Combine (applicationDataDirectoryPath, this.GetType().Name); if (!Directory.Exists (monoTorrentClientApplicationDataDirectoryPath)) Directory.CreateDirectory (monoTorrentClientApplicationDataDirectoryPath); TorrentFileDirectory = Path.Combine (monoTorrentClientApplicationDataDirectoryPath, "torrents"); if (!Directory.Exists (TorrentFileDirectory)) Directory.CreateDirectory (TorrentFileDirectory); BrokenTorrentFileDirectory = Path.Combine (monoTorrentClientApplicationDataDirectoryPath, "broken"); if (!Directory.Exists (BrokenTorrentFileDirectory)) Directory.CreateDirectory (BrokenTorrentFileDirectory); // Make files. DHTNodeFile = Path.Combine (monoTorrentClientApplicationDataDirectoryPath, "dhtNodes"); FastResumeFile = Path.Combine (monoTorrentClientApplicationDataDirectoryPath, "fastResume"); TorrentMappingsCacheFile = Path.Combine (monoTorrentClientApplicationDataDirectoryPath, "torrentMappingsCache"); // Make mappings cache. TorrentMappingsCache = new ListFile<TorrentMapping> (TorrentMappingsCacheFile); // Make default torrent settings. DefaultTorrentSettings = new TorrentSettings (DefaultTorrentUploadSlots, DefaultTorrentOpenConnections, 0, 0); }
private void putToList() { Maker.Instance.Items.Clear(); foreach (Object obj in _listFiles.Items) { CListItem item = obj as CListItem; if (item == null) { continue; } ListFileType type = (ListFileType)((ComboBox)item.SubItems[0].Control).SelectedItem; String fileName = item.SubItems[1].Text; if (type == ListFileType.IGNORED) { continue; } ListFile file = new ListFile(); file.FileName = fileName; file.SourceDirectoryName = Path; file.DescriptionDirectoryName = MakeTo; file.FileType = type; Maker.Instance.Items.Add(file); } }
/// <summary> /// 直接增加一项,这里肯定是增加光谱文件名 /// </summary> /// <param name="itemName"></param> /// <param name="isSelected"></param> /// <param name="data"></param> public void AddItem(string itemName, bool isSelected, object data = null) { //查找是否已经加载了 if (data == null) { data = itemName; } if (FileListData.FirstOrDefault(subitem => subitem.Tag == data) != null) { return; } int index = FileListData.Count; StringAndColorList item = new StringAndColorList(itemName, AllColorList[index % AllColorList.Length], data); FileListData.Add(item); ListFile.SelectedIndex = ListFile.Items.Count - 1; ListFile.ScrollIntoView(item); ListFile.Items.Refresh(); if (isSelected) { item.IsChecked = isSelected; } }
static private void testMove() { Console.WriteLine("=testMove()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); bigList.Move("cache1/"); bigList.Move("cache2/"); bigList.Move("cache3/"); bigList.Move("cache4/"); bigList.Move("C:/cache/"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
public void CanAddAndRemoveNewEntryInListFile() { string newEntry = "UnitTestEntry"; ListFile tempFile = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); {// ADD ENTRY Assert.IsFalse(tempFile.Data.Contains(newEntry)); tempFile.Add(newEntry); Assert.IsTrue(tempFile.Data.Contains(newEntry)); } {// COMMIT ListFile tempFile2 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsFalse(tempFile2.Data.Contains(newEntry)); tempFile.Commit(); Assert.IsTrue(tempFile.Data.Contains(newEntry)); ListFile tempFile3 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile3.Data.Contains(newEntry)); } {// REMOVE ENTRY ListFile tempFile4 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile4.Data.Contains(newEntry)); tempFile4.Remove(newEntry); Assert.IsFalse(tempFile4.Data.Contains(newEntry)); ListFile tempFile5 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsTrue(tempFile5.Data.Contains(newEntry)); tempFile4.Commit(); ListFile tempFile6 = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, Constants.TestData.LIST_FILENAME)); Assert.IsFalse(tempFile6.Data.Contains(newEntry)); } }
public void ResetCPU(bool ResetMemory) { CPU.Halt(); gpu.Refresh(); // This fontset is loaded just in case the kernel doesn't provide one. gpu.LoadFontSet("Foenix", @"Resources\Bm437_PhoenixEGA_8x8.bin", 0, CharacterSet.CharTypeCodes.ASCII_PET, CharacterSet.SizeCodes.Size8x8); if (Configuration.Current.StartUpHexFile.EndsWith(".fnxml", true, null)) { FoeniXmlFile fnxml = new FoeniXmlFile(MemoryManager, Resources, CPUWindow.Instance.breakpoints); fnxml.Load(Configuration.Current.StartUpHexFile); } else { Configuration.Current.StartUpHexFile = HexFile.Load(MemoryManager, Configuration.Current.StartUpHexFile); if (Configuration.Current.StartUpHexFile != null) { if (ResetMemory) { lstFile = new ListFile(Configuration.Current.StartUpHexFile); } else { // TODO: We should really ensure that there are no duplicated PC in the list ListFile tempList = new ListFile(Configuration.Current.StartUpHexFile); lstFile.Lines.InsertRange(0, tempList.Lines); } } } // If the reset vector is not set in Bank 0, but it is set in Bank 18, then copy bank 18 into bank 0. if (MemoryManager.ReadLong(0xFFE0) == 0 && MemoryManager.ReadLong(0x18_FFE0) != 0) //if (MemoryManager.ReadLong(0xFFFC) == 0 && MemoryManager.ReadLong(0x18_FFFC) != 0) { MemoryManager.Copy(0x180000, MemoryMap.RAM_START, MemoryMap.PAGE_SIZE); // See if lines of code exist in the 0x18_0000 to 0x18_FFFF block List <DebugLine> copiedLines = new List <DebugLine>(); if (lstFile.Lines.Count > 0) { List <DebugLine> tempLines = new List <DebugLine>(); foreach (DebugLine line in lstFile.Lines) { if (line.PC >= 0x18_0000 && line.PC < 0x19_0000) { DebugLine dl = (DebugLine)line.Clone(); dl.PC -= 0x18_0000; copiedLines.Add(dl); } } } if (copiedLines.Count > 0) { lstFile.Lines.InsertRange(0, copiedLines); } } CPU.Reset(); }
/// <summary> /// 获取文件列表 /// </summary> /// <param name="fileType"></param> /// <returns></returns> public ActionResult GetFileList(string fileType) { string callback = Request["callback"]; ListFile listFile = new ListFile(); if (fileType == "listimage") { listFile.SearchExtensions = UEditorConfig.GetStringList("imageManagerAllowFiles"); listFile.PathToList = UEditorConfig.GetString("imageManagerListPath"); } if (fileType == "listfile") { listFile.SearchExtensions = UEditorConfig.GetStringList("fileManagerAllowFiles"); listFile.PathToList = UEditorConfig.GetString("fileManagerListPath"); } try { listFile.Start = String.IsNullOrEmpty(Request["start"]) ? 0 : Convert.ToInt32(Request["start"]); listFile.Size = String.IsNullOrEmpty(Request["size"]) ? UEditorConfig.GetInt("imageManagerListSize") : Convert.ToInt32(Request["size"]); } catch (FormatException) { listFile.State = ResultState.InvalidParam; return(Content(WriteFileResult(callback, listFile), string.IsNullOrWhiteSpace(callback) ? "text/plain" : "application/javascript")); } string result = string.Empty; var buildingList = new List <String>(); try { var localPath = Server.MapPath(listFile.PathToList); buildingList.AddRange(Directory.GetFiles(localPath, "*", SearchOption.AllDirectories) .Where(x => listFile.SearchExtensions.Contains(Path.GetExtension(x).ToLower())) .Select(x => listFile.PathToList + x.Substring(localPath.Length).Replace("\\", "/"))); listFile.Total = buildingList.Count; listFile.FileList = buildingList.OrderBy(x => x).Skip(listFile.Start).Take(listFile.Size).ToArray(); } catch (UnauthorizedAccessException) { listFile.State = ResultState.AuthorizError; } catch (DirectoryNotFoundException) { listFile.State = ResultState.PathNotFound; } catch (IOException) { listFile.State = ResultState.IOError; } finally { result = WriteFileResult(callback, listFile); } return(Content(result, string.IsNullOrWhiteSpace(callback) ? "text/plain" : "application/javascript")); }
public void CanReadFilesInDB() { foreach (string filename in Constants.TestData.FILENAMES) { ListFile file = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, filename)); Assert.IsTrue(File.Exists(file.FilePath)); ListFile tempfile = new ListFile(string.Concat(Constants.TestData.DBPATH, Path.DirectorySeparatorChar, Constants.TestData.TEMPFILENAME_PREFIX, filename)); Assert.IsTrue(File.Exists(tempfile.FilePath)); } }
private string WriteFileResult(string callback, ListFile listFile) { return(WriteJson(callback, new { state = GetStateString(listFile.State), list = listFile.FileList == null ? null : listFile.FileList.Select(x => new { url = x }), start = listFile.Start, size = listFile.Size, total = listFile.Total })); }
public void putToList() { foreach (object obj in _filesList.Items) { var file = new ListFile { FileName = obj.ToString(), SourceDirectoryName = SelectedPath, DescriptionDirectoryName = DescriptionPath }; _files.Add(file); } }
/// <summary> /// Процесс по ФЛ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void worker_DoworkFL(object sender, DoWorkEventArgs e) { try { var logica = new Face.GroupReportTable.AnyUlOnFlReport(); var workbookreport = new XLWorkbook(); var selectzaprosfl = new Face.FL.SqlParamSelect.ZaprosFl(); var colection = new AddColection.AddColection(); var filedbffl = new Face.FL.File.SqlParamFile.AddFileFl(); Detal.Invoke(new MethodInvoker(delegate { Detal.StatusFl.Text = @"Собираем выборки!!!"; })); var parametr = selectzaprosfl.GenerateParam(Fl.InnFl, Fl.SeriaNomerPasport, Fl.Familia, Fl.Name, Fl.MiddleName); TableSqlFl = selectzaprosfl.ZaprosSql(parametr, Yers.SelectYears.Years, Detal); Detal.Invoke(new MethodInvoker(delegate { Detal.StatusFl.Text = @"Собираем файлы!!!"; })); CollectionFileFl = filedbffl.AddF(Yers.SelectYears.Years, parametr, Detal); Detal.Invoke(new MethodInvoker(delegate { Detal.StatusFl.Text = @"Формируем таблицы!!!"; })); TableSqlFl = logica.Generatexsls(TableSqlFl, workbookreport, Arhivator.Pathing.PathName.Path4 + Fl.InnFl + "_" + Fl.SeriaNomerPasport + "_" + Fl.Familia + "_" + Yers.SelectYears.Years); DispatcherHelper.CheckBeginInvokeOnUI(() => { Dispatcher.CurrentDispatcher.Invoke(() => { ListFile.UpdateOn(); Tab.UpdateOn(); Report.UpdateOn(); Task.Run(async() => { await Task.Run(() => { try { colection.FilesDbf(CollectionFileFl, ListFile, Fl.InnFl + "_" + Fl.SeriaNomerPasport + "_" + Fl.Familia); logica.GenereteReport(TableSqlFl, Tab); colection.UpdateReport(Report); ListFile.UpdateOff(); Tab.UpdateOff(); Report.UpdateOff(); } catch (Exception exception) { System.Windows.Forms.MessageBox.Show(exception.ToString()); } }); }); }); }); Detal.BeginInvoke(new MethodInvoker(() => WorkerFl.CancelAsync())); } catch (Exception exception) { System.Windows.Forms.MessageBox.Show(exception.ToString()); } }
public void CanIdentifyListFileWhenEntriesAreUrlsWithParameters() { Db db = new Db(Constants.TestData.DBPATH); KeyValuePairFile keyValuePairFile = db.GetKeyValuePairFile(Constants.TestData.DBFILEPATHS[4].Replace(".txt", "")); Assert.IsNull(keyValuePairFile); ListFile listFile = db.GetListFile(Constants.TestData.DBFILEPATHS[4].Replace(".txt", "")); Assert.IsNotNull(listFile); Assert.IsNotNull(listFile.Data); Assert.IsTrue(listFile.Data.Count == 1); }
public Model.ListFile listaArquivoCircular(Model.File oFile) { ListFile oListFile = new ListFile(); FileDAO oFileDAO = new FileDAO(); try { return(oListFile = oFileDAO.listaArquivoCircular(oFile)); } catch (Exception) { throw; } }
public Model.ListFile listaArquivoCircular(Model.File oFile) { ListFile oListFile = new ListFile(); FileDAO oFileDAO = new FileDAO(); try { return oListFile = oFileDAO.listaArquivoCircular(oFile); } catch (Exception) { throw; } }
public ActionResult ListFile() { var ff = new ListFile { PathToList = GetString("fileManagerListPath"), SearchExtensions = GetStringList("fileManagerAllowFiles"), ListSize = GetInt("fileManagerListSize"), Start = Request["start"].ToInt(), Size = Request["size"].ToInt(), }; var rs = ff.Process(); return(Json(rs, JsonRequestBehavior.AllowGet)); }
private void Awake() { var spr = ReadFile.ToSpite(picture); var rd = new ReadFile(); rd.sprite = spr; ListFile.Insert(0, rd); Material mat = new Material(PictureMaterial); mat.SetTexture("_MainTex", picture); Material[] arrM = { FrameMaterial, mat }; var rend = gameObject.GetComponent <Renderer>(); rend.materials = arrM; }
//フォルダリストを読み込みます。 private void LoadFolderList() { if (ListFile == null) { if (!string.IsNullOrWhiteSpace(BootSetting.ListFilePath)) { ListFile = new FolderListFile(BootSetting.ListFilePath); } else { ListFile = new FolderListFile(Path.Combine(Util.StartupPath, "default" + FolderListFile.Extension)); } } ListFile.Load(); ClearButtons(); SetButtons(); }
public ListFile listArquivosCircularByAnoMes(DataTable dt) { ListFile olistFile = new ListFile(); foreach (DataRow dr in dt.Rows) { File oFileModel = new File(); oFileModel.assunto = dr["ASSUNTO"].ToString(); oFileModel.mes = Convert.ToInt32(dr["MES"]); oFileModel.ano = Convert.ToInt32(dr["ANO"]); oFileModel.nameFile = dr["NOME_ARQUIVO"].ToString(); oFileModel.dataPublicacao = Convert.ToDateTime(dr["DATA_GRAVACAO"]); oFileModel.nomeAreaPublicacao = dr["SITE_PUBLICACAO"].ToString(); olistFile.Add(oFileModel); } return(olistFile); }
public IActionResult Index(ListFile model) { //Authorize when Access page //string token = HttpContext.Session.GetString("Session.Token"); //if (string.IsNullOrEmpty(token)) //{ // HttpContext.Session.Clear(); // return RedirectToAction("Login", "Accounts"); //} var response = new RequestHelper(factory).GetRequest("api/FillDocx/GetAllFile"); if (response.StatusCode == 200) { model.FileList = JsonConvert.DeserializeObject <List <TblFileDetail> >(response.Content.ToString()); return(View(model)); } return(View(null)); }
public void CanIdentifyListFileWithSingleEntry() { ListFile file = new ListFile(string.Concat(Constants.TestData.DBFILEPATHS[3])); Assert.IsNotNull(file); Assert.IsNotNull(file.Data); Assert.IsTrue(file.Data.Count == 1); Db db = new Db(Constants.TestData.DBPATH); try { ListFile file2 = db.GetListFile(Constants.TestData.LISTWITHSINGLEENTRY_FILENAME.Replace(".txt", "")); Assert.IsNotNull(file2); Assert.IsNotNull(file2.Data); Assert.IsTrue(file2.Data.Count == 1); } catch (Exception ex) { Assert.Fail(ex.Message + ex.StackTrace); } }
//ボタンパネル部にドラッグドロップ private void ButtonPanel_DragDrop(object sender, DragEventArgs e) { var aPath = (e.Data.GetData(DataFormats.FileDrop) as string[])?.FirstOrDefault(); if (e.Effect == DragDropEffects.Copy) { if (File.Exists(aPath) && aPath.EndsWith(FolderListFile.Extension)) { ListFile.FilePath = aPath; LoadFolderList(); } else if (Directory.Exists(aPath)) { ListFile.FolderButtons.Add(new FolderButton(aPath, "") { BackColor = FolderButton.RandomSampleColor() }); ListFile.Save(); LoadFolderList(); } } }
public IActionResult Index(ListFile model) { string token = HttpContext.Session.GetString("Session.Token"); string username = HttpContext.Session.GetString("Session.Username"); string password = HttpContext.Session.GetString("Session.Password"); if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { HttpContext.Session.Clear(); return(RedirectToAction("Login", "Accounts")); } TblUser u = new ApitemplatereportContext().TblUsers.Where(x => x.Username == username).FirstOrDefault(); var validatetoken = new RequestHelper(factory).PostRequest("api/Token/ValidateToken", token, u); if (validatetoken.StatusCode == 200) { var us = JsonConvert.DeserializeObject <UserLogin>(validatetoken.Content.ToString()); string newPass = new HashMd5().CreateMD5Hash(us.Password); if (newPass == password) { var response = new RequestHelper(factory).GetRequest("api/Files/GetAllFile", token); if (response.StatusCode == 200) { model.FileList = JsonConvert.DeserializeObject <List <TblFileDetail> >(response.Content.ToString()); return(View(model)); } else { HttpContext.Session.Clear(); return(RedirectToAction("Login", "Accounts")); } } } return(View(null)); }
public void DownloadFile(ListFile file) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, true); return; } string path = Directory.GetCurrentDirectory(); string fileName = path + file.FileName.Replace("/", "\\") + ".new"; var url = new Uri("http://jdevelopstation.com/awlauncher" + file.FileName + ".zip"); var info = new FileInfo(fileName); if (info.Directory != null) { if (!info.Directory.Exists) { info.Directory.Create(); } } var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); response.Close(); long iSize = response.ContentLength; int iRunningByteTotal = 0; var client = new WebClient(); Stream remoteStream; try { remoteStream = client.OpenRead(url); } catch (WebException) { GoEnd(WordEnum.PROBLEM_WITH_INTERNET, true); return; } catch (Exception) { GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); return; } var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None); var byteBuffer = new byte[8192]; string word = LanguageHolder.Instance()[WordEnum.DOWNLOADING_S1]; AssemblyPage.Instance().UpdateStatusLabel(String.Format(word, info.Name.Replace(".zip", "")), true); bool exception = false; try { int oldPersent = 0; int iByteSize; while ((iByteSize = remoteStream.Read(byteBuffer, 0, byteBuffer.Length)) > 0) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, false); break; } fileStream.Write(byteBuffer, 0, iByteSize); iRunningByteTotal += iByteSize; var persent = (int)((100F * iRunningByteTotal) / iSize); if (persent != oldPersent) { oldPersent = persent; AssemblyPage.Instance().UpdateProgressBar(persent, false); } } } catch (WebException) { exception = true; GoEnd(WordEnum.PROBLEM_WITH_INTERNET, true); } catch (Exception) { exception = true; GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); } remoteStream.Close(); fileStream.Close(); if (!exception) { UnpackFile(file); } }
static private void testPath() { Console.WriteLine("=testPath()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0, Path.GetTempPath() + "ListFile Cache\\"); Console.WriteLine(bigList.RootPath); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
static private void testNested3() { Console.WriteLine("=testNestedSerialization()="); Random RNG = new Random(); ListFile<ListFile<ListFile<string>>> outerList = new ListFile<ListFile<ListFile<string>>>(999); for (int z = 0; z < 2; z++) { ListFile<ListFile<string>> bigList = new ListFile<ListFile<string>>(z, "cache/midList" + z + "/"); for (int j = 0; j < 2; j++) { ListFile<string> tempList = new ListFile<string>(j, "cache/innerList" + z + j + "/"); for (int i = 0; i < 2; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } outerList.Add(bigList); } foreach (ListFile<ListFile<string>> bigList in outerList) { foreach (ListFile<string> innerList in bigList) { Console.WriteLine(innerList[0]); innerList.Destroy(); } bigList.Destroy(); } outerList.Destroy(); }
public ListFile listArquivosCircularByAnoMes(DataTable dt) { ListFile olistFile = new ListFile(); foreach (DataRow dr in dt.Rows) { File oFileModel = new File(); oFileModel.assunto = dr["ASSUNTO"].ToString(); oFileModel.mes = Convert.ToInt32(dr["MES"]); oFileModel.ano = Convert.ToInt32(dr["ANO"]); oFileModel.nameFile = dr["NOME_ARQUIVO"].ToString(); oFileModel.dataPublicacao = Convert.ToDateTime(dr["DATA_GRAVACAO"]); oFileModel.nomeAreaPublicacao = dr["SITE_PUBLICACAO"].ToString(); olistFile.Add(oFileModel); } return olistFile; }
public void UnpackFile(ListFile file) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, true); return; } string path = Directory.GetCurrentDirectory(); string fileName = path + file.FileName.Replace("/", "\\"); // var descFile = new FileInfo(fileName); var newFile = new FileInfo(fileName + ".new"); string word = LanguageHolder.Instance()[WordEnum.UNPACKING_S1]; AssemblyPage.Instance().UpdateStatusLabel(String.Format(word, newFile.Name.Replace(".new", "")), true); AssemblyPage.Instance().UpdateProgressBar(0, false); var zipStream = new ZipInputStream(newFile.OpenRead()); ZipEntry fileEntry; byte[] bytes = null; if ((fileEntry = zipStream.GetNextEntry()) != null) { bytes = new byte[zipStream.Length]; zipStream.Read(bytes, 0, bytes.Length); } zipStream.Close(); newFile.Delete(); //удаляем зип файл // descFile.Delete(); //удаляем старый файл if (bytes == null) { GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); return; } FileStream fileStream = newFile.Create(); int size = bytes.Length; int oldPersent = 0; for (int i = 0; i < bytes.Length; i++) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, false); break; } fileStream.WriteByte(bytes[i]); var persent = (int)((100F * i) / size); if (persent != oldPersent) { oldPersent = persent; AssemblyPage.Instance().UpdateProgressBar(persent, false); } } AssemblyPage.Instance().UpdateProgressBar(100, false); fileStream.Close(); newFile.LastWriteTime = fileEntry.DateTime; _temp.Remove(file); CheckNextFile(); }
public void CheckNextFile() { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, true); return; } ListFile file = FirstFile(); if (file == null) { GoEnd(WordEnum.UPDATE_DONE, true); return; } int currentCount = _maxSize - _temp.Count; var persent = (int)((100F * (currentCount)) / _maxSize); AssemblyPage.Instance().UpdateProgressBar(persent, true); string path = Directory.GetCurrentDirectory(); string fileName = path + file.FileName.Replace("/", "\\"); var info = new FileInfo(fileName); string word = LanguageHolder.Instance()[WordEnum.CHECKING_S1]; AssemblyPage.Instance().UpdateStatusLabel(String.Format(word, info.Name.Replace(".zip", "")), true); /* if (FileUtils.IsFileOpen(info)) * { * GoEnd(WordEnum.FILE_S1_IS_OPENED_UPDATE_CANCEL, true, info.Name.Replace(".zip", "")); * return; * }*/ String checkSum; try { checkSum = DTHasher.GetMD5Hash(fileName); } catch (Exception) { try { info.Delete(); } catch {} GoEnd(WordEnum.FILE_S1_IS_PROBLEMATIC_UPDATE_CANCEL_PLEASE_RECHECK, true, info.Name.Replace(".zip", "")); return; } if (checkSum == null) { GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); return; } if (!info.Exists) { DownloadFile(file); //грузим } else if (!checkSum.Equals(file.md5Checksum)) //файл не совпадает { DownloadFile(file); //грузим } else { _temp.Remove(file); CheckNextFile(); //идем дальше } }
public static void Generate() { float progressbarStep; float progressbarState; DirectoryInfo d = new DirectoryInfo(Application.dataPath + @"\Textures\objects\hydroponics\growing"); FileInfo[] Files = d.GetFiles("*.png"); // \\Getting Text files var ListFiles = new List <string>(); dictonaryErrors = new Dictionary <string, string>(); var PlantDictionary = new Dictionary <string, DefaultPlantData>(); var PlantDictionaryObject = new Dictionary <string, System.Object>(); foreach (FileInfo file in Files) { ListFiles.Add(file.Name); } var food = (Resources.Load(@"Prefabs\Items\Botany\food") as GameObject); var json = (Resources.Load(@"Metadata\plants") as TextAsset).ToString(); var plats = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(json); progressbarStep = 1f / (plats.Count * ListFiles.Count); progressbarState = 0; foreach (var plat in plats) { EditorUtility.DisplayProgressBar("Step 1/3 Setting Sprites", "Loading plant: " + plat["name"], progressbarState); //\\foreach (var Datapiece in plat) //\\{ //\\ Logger.Log(Datapiece.Key); //\\} var plantdata = PlantData.CreateNewPlant((PlantData)null); plantdata.ProduceObject = food; plantdata.Name = plat["name"] as string; if (plat.ContainsKey("plantname")) { plantdata.Plantname = plat["plantname"] as string; } plantdata.Description = plat["Description"] as string; var species = ""; if (plat.ContainsKey("species")) { species = (plat["species"] as string); } else { Debug.Log($"Unable to find 'species' tag for plant {plantdata.Name}, using 'seed_packet' instead"); species = (plat["seed_packet"] as string); if (species.Contains("seed-")) { species = species.Replace("seed-", ""); } else if (species.Contains("mycelium-")) { species = species.Replace("mycelium-", ""); } }; plantdata.PacketsSprite = new SpriteSheetAndData(); plantdata.PacketsSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\seeds\" + (plat["seed_packet"] as string) + ".png", typeof(Texture2D)) as Texture2D); plantdata.PacketsSprite.setSprites(); SpriteSheetAndData produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + ".png", typeof(Texture2D)) as Texture2D); if (produceSprite.Texture == null) { produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + "pile.png", typeof(Texture2D)) as Texture2D); } if (produceSprite.Texture == null) { produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + "_leaves.png", typeof(Texture2D)) as Texture2D); } if (produceSprite.Texture == null) { produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + "pod.png", typeof(Texture2D)) as Texture2D); } if (produceSprite.Texture == null) { produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + "s.png", typeof(Texture2D)) as Texture2D); } if (produceSprite.Texture == null) { produceSprite = new SpriteSheetAndData(); produceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\" + species + "pepper.png", typeof(Texture2D)) as Texture2D); } produceSprite.setSprites(); var dead_sprite = (plat.ContainsKey("dead_Sprite")) ? (plat["dead_Sprite"] as string) : species + "-dead"; plantdata.DeadSprite = new SpriteSheetAndData(); plantdata.DeadSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + dead_sprite + ".png", typeof(Texture2D)) as Texture2D); plantdata.DeadSprite.setSprites(); plantdata.GrowthSprites = new List <SpriteSheetAndData>(); foreach (var ListFile in ListFiles) { if (ListFile.Contains(species)) { var Namecheck = ListFile; /*Namecheck = Namecheck.Replace("growing_flowers_", ""); * Namecheck = Namecheck.Replace("growing_fruits_", ""); * Namecheck = Namecheck.Replace("growing_mushrooms_", ""); * Namecheck = Namecheck.Replace("growing_vegetables_", ""); * Namecheck = Namecheck.Replace("growing_", "");*/ Namecheck = Namecheck.Split('-')[0]; if (Namecheck == species) { EditorUtility.DisplayProgressBar("Step 1/3 Setting Sprites", $"Loading sprite '{ListFile}' for plant {plantdata.Name}", progressbarState); if (!ListFile.Contains("-dead")) { if (!ListFile.Contains("-harvest")) { //\Assets\Resources\textures\objects\hydroponics\growing\growing_ambrosia_gaia-grow6.png var _SpriteSheetAndData = new SpriteSheetAndData(); _SpriteSheetAndData.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + ListFile, typeof(Texture2D)) as Texture2D); _SpriteSheetAndData.setSprites(); plantdata.GrowthSprites.Add(_SpriteSheetAndData); //If not found do at end } else { var _SpriteSheetAndData = new SpriteSheetAndData(); _SpriteSheetAndData.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + ListFile, typeof(Texture2D)) as Texture2D); _SpriteSheetAndData.setSprites(); plantdata.FullyGrownSprite = _SpriteSheetAndData; } } } } if (plantdata.FullyGrownSprite == null) { if (plantdata.GrowthSprites.Count > 0) { //This seems to be normal plantdata.FullyGrownSprite = plantdata.GrowthSprites[plantdata.GrowthSprites.Count - 1]; } } progressbarState += progressbarStep; } //check if sprites are missing if (plantdata.PacketsSprite.Texture == null) { AppendError(plantdata.Name, $"Unable to find seed packet sprite for plant {plantdata.Name}"); } //if (plantdata.ProduceSprite.Texture == null) { } if (plantdata.DeadSprite.Texture == null) { AppendError(plantdata.Name, $"Unable to find dead sprite"); } if (plantdata.GrowthSprites.Count == 0) { AppendError(plantdata.Name, $"Unable to find growth sprites for plant {plantdata.Name}"); } if (plantdata.FullyGrownSprite == null) { AppendError(plantdata.Name, $"Unable to find fully grown sprite"); } plantdata.WeedResistance = int.Parse(plat["weed_resistance"].ToString()); plantdata.WeedGrowthRate = int.Parse(plat["weed_growth_rate"].ToString()); plantdata.Potency = int.Parse(plat["potency"].ToString()); plantdata.Endurance = int.Parse(plat["endurance"].ToString()); plantdata.Yield = int.Parse(plat["plant_yield"].ToString()); plantdata.Lifespan = int.Parse(plat["lifespan"].ToString()); plantdata.GrowthSpeed = int.Parse(plat["production"].ToString()); if (plat.ContainsKey("genes")) { var genes = JsonConvert.DeserializeObject <List <string> >(plat["genes"].ToString()); foreach (var gene in genes) { if (gene == "Perennial_Growth") { plantdata.PlantTrays.Add(PlantTrays.Perennial_Growth); } else if (gene == "Fungal Vitality") { plantdata.PlantTrays.Add(PlantTrays.Fungal_Vitality); } else if (gene == "Liquid Contents") { plantdata.PlantTrays.Add(PlantTrays.Liquid_Content); } else if (gene == "Slippery Skin") { plantdata.PlantTrays.Add(PlantTrays.Slippery_Skin); } else if (gene == "Bluespace Activity") { plantdata.PlantTrays.Add(PlantTrays.Bluespace_Activity); } else if (gene == "Densified Chemicals") { plantdata.PlantTrays.Add(PlantTrays.Densified_Chemicals); } else if (gene == "Capacitive Cell Production") { plantdata.PlantTrays.Add(PlantTrays.Capacitive_Cell_Production); } else if (gene == "Weed Adaptation") { plantdata.PlantTrays.Add(PlantTrays.Weed_Adaptation); } else if (gene == "Hypodermic Prickles") { plantdata.PlantTrays.Add(PlantTrays.Hypodermic_Needles); } else if (gene == "Shadow Emission") { plantdata.PlantTrays.Add(PlantTrays.Shadow_Emission); } else if (gene == "Red Electrical Glow") { plantdata.PlantTrays.Add(PlantTrays.Red_Electrical_Glow); } else if (gene == "Electrical Activity") { plantdata.PlantTrays.Add(PlantTrays.Electrical_Activity); } else if (gene == "Strong Bioluminescence") { plantdata.PlantTrays.Add(PlantTrays.Strong_Bioluminescence); } else if (gene == "Bioluminescence") { plantdata.PlantTrays.Add(PlantTrays.Bioluminescence); } else if (gene == "Separated Chemicals") { plantdata.PlantTrays.Add(PlantTrays.Separated_Chemicals); } } } //Creating/updating food prefabs if (plat.ContainsKey("produce_name")) { //load existing prefab variant if possible GameObject prefabVariant = (GameObject)AssetDatabase.LoadAssetAtPath(@"Assets/Resources/Prefabs/Items/Botany/" + plantdata.Name + ".prefab", typeof(GameObject)); if (prefabVariant == null) { GameObject originalPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(@"Assets/Resources/Prefabs/Items/Botany/food.prefab", typeof(GameObject)); prefabVariant = PrefabUtility.InstantiatePrefab(originalPrefab) as GameObject; } else { prefabVariant = PrefabUtility.InstantiatePrefab(prefabVariant) as GameObject; } var itemAttr = prefabVariant.GetComponent <ItemAttributesV2>(); //Commented since this are normally private //itemAttr.initialName = plat["produce_name"] as string; //itemAttr.initialDescription = plat["description"] as string; //itemAttr.itemSprites = (new ItemsSprites() { InventoryIcon = produceSprite }); //add sprite to food var spriteRenderer = prefabVariant.GetComponentInChildren <SpriteRenderer>(); spriteRenderer.sprite = SpriteFunctions.SetupSingleSprite(produceSprite).ReturnFirstSprite(); var newFood = prefabVariant.GetComponent <GrownFood>(); //Set plant data for food newFood.plantData = plantdata; var newReagents = prefabVariant.GetComponent <ReagentContainer>(); //add reagents to food if (plat.ContainsKey("reagents_add")) { var Chemicals = JsonConvert.DeserializeObject <Dictionary <string, float> >(plat["reagents_add"].ToString()); var reagents = new List <string>(); var amounts = new List <float>(); foreach (var Chemical in Chemicals) { //ChemicalDictionary[Chemical.Key] = (((int)(Chemical.Value * 100)) * (plantdata.Potency / 100f)); reagents.Add(Chemical.Key); amounts.Add(((int)(Chemical.Value * 100)) * (plantdata.Potency / 100f)); } //newReagents.Reagents = reagents; //newReagents.Amounts = amounts; } plantdata.ProduceObject = PrefabUtility.SaveAsPrefabAsset(prefabVariant, @"Assets/Resources/Prefabs/Items/Botany/" + plantdata.Name + ".prefab"); } else { plantdata.ProduceObject = null; } var DefaultPlantData = ScriptableObject.CreateInstance <DefaultPlantData>(); DefaultPlantData.plantData = plantdata; //\\ Creates the folder path //\\ Creates the file in the folder path Logger.Log(plantdata.Name + " < PlantDictionary"); PlantDictionary[plantdata.Name] = DefaultPlantData; if (plat.ContainsKey("mutates_into")) { PlantDictionaryObject[plantdata.Name] = plat["mutates_into"]; } //\\Logger.Log(plantdata.GrowthSprites.Count.ToString()); } progressbarStep = 1f / PlantDictionary.Count; progressbarState = 0; var mutationNameList = new List <string>(); foreach (var pant in PlantDictionary) { EditorUtility.DisplayProgressBar("Step 2/3 Setting Mutations", "Loading mutations for: " + pant.Value.plantData.Name, progressbarState += progressbarStep); if (PlantDictionaryObject.ContainsKey(pant.Value.plantData.Name)) { var Mutations = JsonConvert.DeserializeObject <List <string> >(PlantDictionaryObject[pant.Value.plantData.Name].ToString()); foreach (var Mutation in Mutations) { if (!mutationNameList.Contains(Mutation)) { mutationNameList.Add(Mutation); } if (Mutation.Length != 0) { if (PlantDictionary.ContainsKey(Mutation)) { MutationComparison(pant.Value, PlantDictionary[Mutation]); pant.Value.plantData.MutatesInTo.Add((DefaultPlantData)AssetDatabase.LoadAssetAtPath(@"Assets\Resources\ScriptableObjects\Plant default\" + PlantDictionary[Mutation].plantData.Name + ".asset", typeof(DefaultPlantData))); if (PlantDictionary[Mutation].plantData.DeadSprite?.Texture == null) { if (pant.Value.plantData.DeadSprite?.Texture != null) { PlantDictionary[Mutation].plantData.DeadSprite = new SpriteSheetAndData(); PlantDictionary[Mutation].plantData.DeadSprite.Texture = pant.Value.plantData.DeadSprite.Texture; PlantDictionary[Mutation].plantData.DeadSprite.setSprites(); } } if (PlantDictionary[Mutation].plantData.GrowthSprites.Count == 0) { PlantDictionary[Mutation].plantData.GrowthSprites = pant.Value.plantData.GrowthSprites; } } } } } } progressbarStep = 1f / PlantDictionary.Count; progressbarState = 0; foreach (var pant in PlantDictionary) { DefaultPlantData defaultPlant = AssetDatabase.LoadMainAssetAtPath(@"Assets\Resources\ScriptableObjects\Plant default\" + pant.Value.plantData.Name + ".asset") as DefaultPlantData; if (defaultPlant != null) { EditorUtility.DisplayProgressBar("Step 3/3 Saving ScriptObjects", "Updating asset: " + pant.Value.plantData.Name, progressbarState += progressbarStep); EditorUtility.CopySerialized(pant.Value, defaultPlant); AssetDatabase.SaveAssets(); } else { EditorUtility.DisplayProgressBar("Step 3/3 Saving ScriptObjects", "Creating asset: " + pant.Value.plantData.Name, progressbarState += progressbarStep); defaultPlant = ScriptableObject.CreateInstance <DefaultPlantData>(); EditorUtility.CopySerialized(pant.Value, defaultPlant); AssetDatabase.CreateAsset(pant.Value, @"Assets\Resources\ScriptableObjects\Plant default\" + pant.Value.plantData.Name + ".asset"); } if (dictonaryErrors.ContainsKey(pant.Value.plantData.Name)) { if (mutationNameList.Contains(pant.Value.plantData.Name)) { dictonaryErrors[pant.Value.plantData.Name] = $"Mutation {pant.Value.plantData.Name} has some missing sprites\n{dictonaryErrors[pant.Value.plantData.Name]}"; Debug.LogWarning(dictonaryErrors[pant.Value.plantData.Name]); } else { dictonaryErrors[pant.Value.plantData.Name] = $"Plant {pant.Value.plantData.Name} has some missing sprites\n{dictonaryErrors[pant.Value.plantData.Name]}"; Debug.LogError(dictonaryErrors[pant.Value.plantData.Name]); } } } EditorUtility.ClearProgressBar(); EditorUtility.DisplayDialog("Complete", "Generating default plant ScriptObjects complete", "Close"); }
public void UnpackFile(ListFile file) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, true); return; } string path = CurrentProperty.Path; string fileName = path + file.FileName.Replace("/", "\\"); FileInfo descFile = new FileInfo(fileName); FileInfo zipFile = new FileInfo(fileName + ".zip"); if (!zipFile.Exists) { GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); return; } MainForm.Instance.UpdateStatusLabel(WordEnum.UNPACKING_S1, zipFile.Name.Replace(".zip", "")); MainForm.Instance.UpdateProgressBar(0, false); ZipInputStream zipStream = new ZipInputStream(zipFile.OpenRead()) { Password = "******" }; ZipEntry fileEntry; byte[] listDate = null; if ((fileEntry = zipStream.GetNextEntry()) != null) { listDate = new byte[zipStream.Length]; zipStream.Read(listDate, 0, listDate.Length); } zipStream.Close(); zipFile.Delete(); //удаляем зип файл descFile.Delete(); //удаляем старый файл if (listDate == null) { GoEnd(WordEnum.PROBLEM_WITH_SERVER, true); return; } Stream stream = descFile.Create(); int size = listDate.Length; int oldPersent = 0; for (int i = 0; i < listDate.Length; i++) { if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER, false); break; } stream.WriteByte(listDate[i]); int persent = (int)((100F * i) / size); if (persent != oldPersent) { oldPersent = persent; MainForm.Instance.UpdateProgressBar(persent, false); } } MainForm.Instance.UpdateProgressBar(100, false); stream.Close(); descFile.LastWriteTime = fileEntry.DateTime; }
/// <summary> /// С текущего масива грузит список файлов /// </summary> /// <param name="zipArray"></param> private void GoNextStep(byte[] zipArray) { try { byte[] array = null; ZipInputStream zipStream = new ZipInputStream(new MemoryStream(zipArray)) { Password = "******" }; if ((zipStream.GetNextEntry()) != null) { array = new byte[zipStream.Length]; zipStream.Read(array, 0, array.Length); } zipStream.Close(); if (array == null) { if (_log.IsDebugEnabled) { _log.Info("Error: array is null"); } GoEnd(WordEnum.PROBLEM_WITH_SERVER); return; } string encodingBytes = Encoding.UTF8.GetString(array); string[] lines = encodingBytes.Split('\n'); foreach (string line in lines) { if (line.Trim().Equals("")) { continue; } if (Status == Status.CANCEL) { GoEnd(WordEnum.CANCEL_BY_USER); return; } if (line.StartsWith("#Revision:")) { Revision = int.Parse(line.Replace("#Revision:", "").Trim()); continue; } if (line.StartsWith("#")) { continue; } try { ListFile file = ListFile.parse(line); _list[file.Type].AddLast(file); } catch (Exception e) { _log.Info("Exception for line " + line + " " + e, e); } } GoEnd(WordEnum.ENDING_DOWNLOAD_LIST); } catch (Exception e) { GoEnd(WordEnum.PROBLEM_WITH_SERVER); _log.Info("Exception: " + e, e); } }
static private void testPack() { Console.WriteLine("=testArchive()="); Random RNG = new Random(); ListFile<List<string>> bigList = new ListFile<List<string>>(0); for (int j = 0; j < 5; j++) { List<string> tempList = new List<string>(); for (int i = 0; i < 10; i++) { string tempString = ""; for (int k = 0; k < 5; k++) { tempString += Convert.ToString(RNG.Next(100000, 999999)) + " "; } tempList.Add(tempString); } bigList.Add(tempList); Console.WriteLine(j); } Console.WriteLine("Done generating"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Pack(); Console.WriteLine("Packed"); bigList.Destroy(); Console.WriteLine("Destroyed"); bigList = new ListFile<List<string>>(0); bigList.Unpack(); Console.WriteLine("Unpacked"); bigList.Load(); Console.WriteLine("Loaded"); foreach (List<string> smallList in bigList) { Console.WriteLine(smallList[0]); } bigList.Destroy(); }
public static void Generate() { DirectoryInfo d = new DirectoryInfo(Application.dataPath + @"\Textures\objects\hydroponics\growing"); FileInfo[] Files = d.GetFiles("*.png");// \\Getting Text files var ListFiles = new List <string>(); var PlantDictionary = new Dictionary <string, DefaultPlantData>(); var PlantDictionaryObject = new Dictionary <string, System.Object>(); foreach (FileInfo file in Files) { ListFiles.Add(file.Name); } var food = (Resources.Load(@"Prefabs\Items\Botany\food") as GameObject); var json = (Resources.Load(@"Metadata\plants") as TextAsset).ToString(); var plats = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(json); foreach (var plat in plats) { //\\foreach (var Datapiece in plat) //\\{ //\\ Logger.Log(Datapiece.Key); //\\} var plantdata = new PlantData { ProduceObject = food, Name = plat["name"] as string }; if (plat.ContainsKey("plantname")) { plantdata.Plantname = plat["plantname"] as string; } plantdata.Description = plat["Description"] as string; var seed_packet = ""; if (plat.ContainsKey("species")) { seed_packet = (plat["species"] as string); } else { seed_packet = (plat["seed_packet"] as string); if (seed_packet.Contains("seed-")) { seed_packet = seed_packet.Replace("seed-", ""); } else if (seed_packet.Contains("mycelium-")) { seed_packet = seed_packet.Replace("mycelium-", ""); } } // Logger.Log(seed_packet); //Logger.Log(plat["seed_packet"] as string); //Logger.Log("harvest_" + seed_packet); plantdata.PacketsSprite = new SpriteSheetAndData(); plantdata.PacketsSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\seeds\seeds_" + (plat["seed_packet"] as string) + ".png", typeof(Texture2D)) as Texture2D); plantdata.PacketsSprite.setSprites(); plantdata.ProduceSprite = new SpriteSheetAndData(); plantdata.ProduceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\harvest_" + seed_packet + ".png", typeof(Texture2D)) as Texture2D); //Application.dataPath if (plantdata.ProduceSprite.Texture == null) { plantdata.ProduceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\harvest_" + seed_packet + "pile" + ".png", typeof(Texture2D)) as Texture2D); } if (plantdata.ProduceSprite.Texture == null) { var EEEseed_packet = (plat["seed_packet"] as string); if (EEEseed_packet.Contains("seed-")) { EEEseed_packet = EEEseed_packet.Replace("seed-", ""); } else if (EEEseed_packet.Contains("mycelium-")) { EEEseed_packet = EEEseed_packet.Replace("mycelium-", ""); } plantdata.ProduceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\harvest_" + EEEseed_packet + ".png", typeof(Texture2D)) as Texture2D); if (plantdata.ProduceSprite.Texture == null) { plantdata.ProduceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\harvest_" + EEEseed_packet + "s" + ".png", typeof(Texture2D)) as Texture2D); } if (plantdata.ProduceSprite.Texture == null) { plantdata.ProduceSprite.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\harvest\harvest_" + seed_packet + "s" + ".png", typeof(Texture2D)) as Texture2D); } } plantdata.ProduceSprite.setSprites(); plantdata.GrowthSprites = new List <SpriteSheetAndData>(); //var Growingsprites = new List<string>(); foreach (var ListFile in ListFiles) { if (ListFile.Contains(seed_packet)) { var Namecheck = ListFile; Namecheck = Namecheck.Replace("growing_flowers_", ""); Namecheck = Namecheck.Replace("growing_fruits_", ""); Namecheck = Namecheck.Replace("growing_mushrooms_", ""); Namecheck = Namecheck.Replace("growing_vegetables_", ""); Namecheck = Namecheck.Replace("growing_", ""); Namecheck = Namecheck.Split('-')[0]; if (Namecheck == seed_packet) { if (!ListFile.Contains("-dead")) { if (!ListFile.Contains("-harvest")) { //var _ListFile = ListFile.Replace(".png", ""); //\\Growingsprites.Add(ListFile); //\Assets\Resources\textures\objects\hydroponics\growing\growing_ambrosia_gaia-grow6.png var _SpriteSheetAndData = new SpriteSheetAndData(); _SpriteSheetAndData.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + ListFile, typeof(Texture2D)) as Texture2D); _SpriteSheetAndData.setSprites(); plantdata.GrowthSprites.Add(_SpriteSheetAndData); //\\If not found do at end } else { //Logger.Log("got harvest"); var _SpriteSheetAndData = new SpriteSheetAndData(); _SpriteSheetAndData.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + ListFile, typeof(Texture2D)) as Texture2D); _SpriteSheetAndData.setSprites(); plantdata.FullyGrownSprite = _SpriteSheetAndData; } } else { //Logger.Log("got DeadSprite"); //var _ListFile = ListFile.Replace(".png", ""); var _SpriteSheetAndData = new SpriteSheetAndData(); _SpriteSheetAndData.Texture = (AssetDatabase.LoadAssetAtPath(@"Assets\textures\objects\hydroponics\growing\" + ListFile, typeof(Texture2D)) as Texture2D); _SpriteSheetAndData.setSprites(); plantdata.DeadSprite = _SpriteSheetAndData; } } } if (plantdata.FullyGrownSprite == null) { if (plantdata.GrowthSprites.Count > 0) { plantdata.FullyGrownSprite = plantdata.GrowthSprites[plantdata.GrowthSprites.Count - 1]; } } } plantdata.WeedResistance = int.Parse(plat["weed_resistance"].ToString()); plantdata.WeedGrowthRate = int.Parse(plat["weed_growth_rate"].ToString()); plantdata.Potency = int.Parse(plat["potency"].ToString()); plantdata.Endurance = int.Parse(plat["endurance"].ToString()); plantdata.Yield = int.Parse(plat["plant_yield"].ToString()); plantdata.Lifespan = int.Parse(plat["lifespan"].ToString()); plantdata.GrowthSpeed = int.Parse(plat["production"].ToString()); if (plat.ContainsKey("genes")) { var genes = JsonConvert.DeserializeObject <List <string> >(plat["genes"].ToString()); foreach (var gene in genes) { if (gene == "Perennial_Growth") { plantdata.PlantTrays.Add(PlantTrays.Perennial_Growth); } else if (gene == "Fungal Vitality") { plantdata.PlantTrays.Add(PlantTrays.Fungal_Vitality); } else if (gene == "Liquid Contents") { plantdata.PlantTrays.Add(PlantTrays.Liquid_Content); } else if (gene == "Slippery Skin") { plantdata.PlantTrays.Add(PlantTrays.Slippery_Skin); } else if (gene == "Bluespace Activity") { plantdata.PlantTrays.Add(PlantTrays.Bluespace_Activity); } else if (gene == "Densified Chemicals") { plantdata.PlantTrays.Add(PlantTrays.Densified_Chemicals); } else if (gene == "Capacitive Cell Production") { plantdata.PlantTrays.Add(PlantTrays.Capacitive_Cell_Production); } else if (gene == "Weed Adaptation") { plantdata.PlantTrays.Add(PlantTrays.Weed_Adaptation); } else if (gene == "Hypodermic Prickles") { plantdata.PlantTrays.Add(PlantTrays.Hypodermic_Needles); } else if (gene == "Shadow Emission") { plantdata.PlantTrays.Add(PlantTrays.Shadow_Emission); } else if (gene == "Red Electrical Glow") { plantdata.PlantTrays.Add(PlantTrays.Red_Electrical_Glow); } else if (gene == "Electrical Activity") { plantdata.PlantTrays.Add(PlantTrays.Electrical_Activity); } else if (gene == "Strong Bioluminescence") { plantdata.PlantTrays.Add(PlantTrays.Strong_Bioluminescence); } else if (gene == "Bioluminescence") { plantdata.PlantTrays.Add(PlantTrays.Bioluminescence); } else if (gene == "Separated Chemicals") { plantdata.PlantTrays.Add(PlantTrays.Separated_Chemicals); } } } if (plat.ContainsKey("reagents_add")) { var Chemicals = JsonConvert.DeserializeObject <Dictionary <string, float> >(plat["reagents_add"].ToString()); foreach (var Chemical in Chemicals) { var SInt = new Reagent(); SInt.Ammount = (int)(Chemical.Value * 100); SInt.Name = Chemical.Key; plantdata.ReagentProduction.Add(SInt); } } var DefaultPlantData = new DefaultPlantData { plantData = plantdata }; //\\ Creates the folder path //\\ Creates the file in the folder path Logger.Log(plantdata.Name + " < PlantDictionary"); PlantDictionary[plantdata.Name] = DefaultPlantData; if (plat.ContainsKey("mutates_into")) { PlantDictionaryObject[plantdata.Name] = plat["mutates_into"]; } //\\Logger.Log(plantdata.GrowthSprites.Count.ToString()); } foreach (var pant in PlantDictionary) { if (PlantDictionaryObject.ContainsKey(pant.Value.plantData.Name)) { var Mutations = JsonConvert.DeserializeObject <List <string> >(PlantDictionaryObject[pant.Value.plantData.Name].ToString()); foreach (var Mutation in Mutations) { if (Mutation.Length != 0) { if (PlantDictionary[Mutation] != null) { MutationComparison(pant.Value, PlantDictionary[Mutation]); pant.Value.plantData.MutatesInTo.Add((DefaultPlantData)AssetDatabase.LoadAssetAtPath(@"Assets\Resources\ScriptableObjects\Plant default\" + PlantDictionary[Mutation].plantData.Name + ".asset", typeof(DefaultPlantData))); } if (PlantDictionary[Mutation].plantData.DeadSprite?.Texture == null) { if (pant.Value.plantData.DeadSprite?.Texture != null) { PlantDictionary[Mutation].plantData.DeadSprite = new SpriteSheetAndData(); PlantDictionary[Mutation].plantData.DeadSprite.Texture = pant.Value.plantData.DeadSprite.Texture; PlantDictionary[Mutation].plantData.DeadSprite.setSprites(); } } if (PlantDictionary[Mutation].plantData.GrowthSprites.Count == 0) { PlantDictionary[Mutation].plantData.GrowthSprites = pant.Value.plantData.GrowthSprites; } } } } } foreach (var pant in PlantDictionary) { AssetDatabase.CreateAsset(pant.Value, @"Assets\Resources\ScriptableObjects\Plant default\" + pant.Value.plantData.Name + ".asset"); } }
internal static void WriteListFile(this StreamWriter writer, ListFile listFile) => listFile.WriteTo(writer);