// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { if (this.ParameterSetName == "Path") { foreach (var filepath in SessionLocation.GetResolvedPath(this.SessionState, this.Path)) { // Validation (File Existence Check): if (!File.Exists(filepath)) { throw new FileNotFoundException(); } // Should Process if (this.ShouldProcess($"ファイル '{filepath}'", "HTML コンテンツの構文解析")) { // GET Parsed HTML Contents var contents = HtmlSyntaxParser.Read(filepath, this.Encoding); // OUTPUT HTML Contents this.WriteContents(contents); } } } else if (this.ParameterSetName == "InputObject") { // Should Process if (this.ShouldProcess($"入力文字列", "HTML コンテンツの構文解析")) { // GET Parsed HTML Contents var contents = HtmlSyntaxParser.Parse(this.InputObject); // OUTPUT HTML Contents this.WriteContents(contents); } } else { throw new InvalidOperationException(); } }
// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { if (this.ParameterSetName == "Path") { foreach (var filepath in SessionLocation.GetResolvedPath(this.SessionState, this.Path)) { // Validation (File Existence Check): if (!File.Exists(filepath)) { throw new FileNotFoundException(); } // Open INI File Stream by READ-ONLY Mode using (var profile = new PrivateProfile(filepath, true, this.IgnoreDuplicatedEntry)) { // OUTPUT Profile (according parameter) WriteProfile(profile, $"ファイル '{filepath}'"); } } } else if (this.ParameterSetName == "InputObject") { // NEW PrivateProfile var profile = new PrivateProfile(this.IgnoreDuplicatedEntry); // IMPORT content from InputObject profile.Import(this.InputObject); // OUTPUT Profile (according parameter) WriteProfile(profile, $"パラメーター '{nameof(InputObject)}'"); } else { throw new InvalidOperationException(); } }
// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { foreach (var filepath in SessionLocation.GetResolvedPath(this.SessionState, this.Path)) { // Validation (File Existence Check): if (!File.Exists(filepath)) { throw new FileNotFoundException(); } // Open INI File Stream by READ-WRITE Mode using (var profile = new PrivateProfile(filepath, false)) { // SECTION Existence Check: if (profile.Contains(this.Section)) { // UPDATE SECTION this.Section = (from section_name in profile.Sections.Keys where string.Compare(section_name, this.Section, true) == 0 select section_name).First(); // KEY Existence Check) if (profile.Sections[this.Section].Entries.ContainsKey(this.Key)) { // UPDATE KEY this.Key = (from key in profile.Sections[this.Section].Entries.Keys where string.Compare(key, this.Key, true) == 0 select key).First(); } } // Should Process if (this.ShouldProcess($"ファイル '{filepath}'", $"セクション '{this.Section}' に含まれるキー '{this.Key}' の値の設定")) { // SET & Write VALUE profile.SetValue(this.Section, this.Key, this.Value).Write(); } } } }
// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { foreach (var src_zipfilepath in SessionLocation.GetResolvedPath(this.SessionState, this.Path)) { // Validation (Source File Existence Check): if (!File.Exists(src_zipfilepath)) { throw new FileNotFoundException(); } // SET Destination Directory Path var dest_dirpath = this.DestinationPath is null? Directory.CreateDirectory(SessionLocation.GetUnresolvedPath(this.SessionState, System.IO.Path.GetFileNameWithoutExtension(src_zipfilepath))).FullName: SessionLocation.GetUnresolvedPath(this.SessionState, this.DestinationPath); // Validation (Destination Directory Existence Check): if (!Directory.Exists(dest_dirpath)) { throw new DirectoryNotFoundException(); } // Should Process if (this.ShouldProcess($"Source: '{src_zipfilepath}', Destination:'{dest_dirpath}'", "ファイルの展開")) { // using ZipFile using (ZipFile zip = ZipFile.Read(src_zipfilepath, new ReadOptions() { Encoding = this.Encoding ?? Encoding.UTF8 })) { // Set FileAction (Overwirte or NOT) ExtractExistingFileAction fileAction = this.Force ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite; // ProgressRecord (Main): ProgressRecord mainProgress = new ProgressRecord(0, $"{this.MyInvocation.MyCommand}: '{src_zipfilepath}' を展開しています", "準備中..."); // ProgressRecord (Sub): ProgressRecord subProgress = new ProgressRecord(1, "準備中...", "準備中...") { ParentActivityId = 0 }; // Register Event Handler only if needed if (!this.SuppressProgress || !this.SuppressOutput || this.PassThru) { // Root Entries for Output List <string> outputEntryRoots = new List <string>(); // Count(s) int entryCount = 0; int eventCount = 0; int eventIntervalCount = 150; // ZipFile.ExtractProgress Event Handler zip.ExtractProgress += (object sender, ExtractProgressEventArgs e) => { #if DEBUG // DEBUG Output this.WriteDebug(""); this.WriteDebug($"e.{nameof(e.EventType)} = {e.EventType}"); this.WriteDebug($"e.{nameof(e.ArchiveName)} = {e.ArchiveName}"); this.WriteDebug($"e.{nameof(e.BytesTransferred)} = {e.BytesTransferred}"); this.WriteDebug($"e.{nameof(e.TotalBytesToTransfer)} = {e.TotalBytesToTransfer}"); this.WriteDebug($"e.{nameof(e.EntriesTotal)} = {e.EntriesTotal}"); this.WriteDebug($"e.{nameof(e.CurrentEntry)} = {e.CurrentEntry}"); this.WriteDebug($"e.{nameof(e.EntriesExtracted)} = {e.EntriesExtracted}"); #endif // for ProgressRecord(s) if (!this.SuppressProgress) { switch (e.EventType) { // Before Extracting Entry case ZipProgressEventType.Extracting_BeforeExtractEntry: // Increment count of Entry entryCount++; mainProgress.Activity = (zip.Count > 1) ? $"{this.MyInvocation.MyCommand}: '{src_zipfilepath}' ({entryCount} / {zip.Count}) を展開しています" : $"{this.MyInvocation.MyCommand}: '{src_zipfilepath}' を展開しています"; mainProgress.StatusDescription = $"'{e.CurrentEntry.FileName}' を展開中..."; mainProgress.PercentComplete = 100 * (entryCount - 1) / zip.Count; // Write Progress (Main) this.WriteProgress(mainProgress); break; // Entry Bytes are written case ZipProgressEventType.Extracting_EntryBytesWritten: // Increment event count if (++eventCount > eventIntervalCount) { // UPDATE Progress (Main) mainProgress.StatusDescription = $"'{e.CurrentEntry.FileName}' ({e.BytesTransferred} / {e.TotalBytesToTransfer} バイト) を展開中..."; mainProgress.PercentComplete = ((100 * (entryCount - 1)) + (int)(100 * e.BytesTransferred / e.TotalBytesToTransfer)) / zip.Count; // Write Progress (Main) this.WriteProgress(mainProgress); // for Sub Progress if (this.MyInvocation.BoundParameters.ContainsKey("Verbose")) { // UPDATE Progress (Sub) subProgress.Activity = $"'{e.CurrentEntry}' を展開しています"; subProgress.StatusDescription = $"{e.BytesTransferred} / {e.TotalBytesToTransfer} バイトを展開中..."; subProgress.PercentComplete = (int)(100 * e.BytesTransferred / e.TotalBytesToTransfer); // Write Progress (Sub) this.WriteProgress(subProgress); } // Reset event count eventCount = 0; } break; default: break; } } // for ProgressRecord(s) // for Entry Output if (e.EventType == ZipProgressEventType.Extracting_AfterExtractEntry) { if (this.PassThru) { // PassThru: // Convert '/' -> '\' (System.IO.Path.DirectorySeparatorChar) string filename = e.CurrentEntry.FileName.Replace('/', System.IO.Path.DirectorySeparatorChar); // Output if (e.CurrentEntry.IsDirectory) { // Directory: this.WriteObject(new DirectoryInfo(System.IO.Path.Combine(e.ExtractLocation, filename))); } else { // File: this.WriteObject(new FileInfo(System.IO.Path.Combine(e.ExtractLocation, filename))); } } else { // NOT PassThru: if (!this.SuppressOutput) { // NOT PassThru & NOT SuppressOutput: string[] separated = e.CurrentEntry.FileName.Split(new char[] { '/' }); string root = separated[0]; if (!outputEntryRoots.Contains(root)) { // Add File Name of Root Entry outputEntryRoots.Add(root); // Output if (e.CurrentEntry.IsDirectory || (separated.Length > 1)) { // Directory: this.WriteObject(new DirectoryInfo(System.IO.Path.Combine(dest_dirpath, root))); } else { // File: this.WriteObject(new FileInfo(System.IO.Path.Combine(dest_dirpath, root))); } } } } } // for Entry Output }; // ZipFile.ExtractProgress Event Handler } // UnZip (Extract) foreach (var entry in zip) { // Extract each Zip entries if (string.IsNullOrEmpty(this.Password)) { // w/o Password entry.Extract(dest_dirpath, fileAction); } else { // with Password entry.ExtractWithPassword(dest_dirpath, fileAction, this.Password); } } // Completion of ProgressRecord(s): foreach (var progress in new ProgressRecord[] { subProgress, mainProgress }) { if (progress != null) { // Complete the Progress progress.PercentComplete = 100; progress.RecordType = ProgressRecordType.Completed; // Write Progress this.WriteProgress(progress); } } } // using ZipFile } // Should Process } }
// Input Processing Operations protected override void ProcessRecord() { this.WriteObject(SessionLocation.GetUnresolvedPath(this.SessionState, this.Path)); }
public void Save() { if(Board.master != null){ // Save Pictures pictures = new List<SessionPicture>(); foreach(Picture picture in Board.master.pictures){ SessionPicture sessionPicture = new SessionPicture(); sessionPicture.position = picture.position; sessionPicture.rotation = picture.rotation; sessionPicture.subject = picture.subject; pictures.Add(sessionPicture); } // Save Pins pins = new List<SessionPin>(); foreach(Pin pin in Board.master.pins){ SessionPin sessionPin = new SessionPin(); sessionPin.position = pin.position; sessionPin.colour = pin.colour; pins.Add(sessionPin); } // Save PostIts postits = new List<SessionPostIt>(); foreach(PostIt postit in Board.master.postits){ SessionPostIt sessionPostIt = new SessionPostIt(); sessionPostIt.position = postit.position; sessionPostIt.rotation = postit.rotation; sessionPostIt.message = postit.simpleText; postits.Add(sessionPostIt); } // Save Strings strings = new List<SessionString>(); foreach(String currentString in Board.master.strings){ SessionString sessionString = new SessionString(); sessionString.startPoint = currentString.startPoint; sessionString.endPoint = currentString.endPoint; strings.Add(sessionString); } } // Save Time/Events if(TimeManager.master){ day = TimeManager.master.currentDayReference; time = TimeManager.master.time; completedEvents = EventManager.completedEvents; failedEvents = EventManager.failedEvents; dayEvents = new Dictionary<string,List<string>>(); foreach (Day currentDay in TimeManager.master.days){ List<string> eventList = new List<string>(); foreach (Event eventCheck in currentDay.events){ if(eventCheck.eventHappened == true){ eventList.Add(eventCheck.eventName); } } dayEvents.Add(currentDay.dayName, eventList); } } // Save Items if(Inventory.master){ items = new Dictionary<string, SessionItem>(); foreach(KeyValuePair<string,Item> item in Inventory.master.itemDictionary){ SessionItem sessionItem = new SessionItem(); sessionItem.position = item.Value.position; sessionItem.location = item.Value.currentLocation.id; if(item.Value.owner != null){ sessionItem.owner = item.Value.owner.id; } else { sessionItem.owner = null; } if(item.Value.holder != null){ sessionItem.holder = item.Value.holder.id; } else { sessionItem.holder = null; } sessionItem.health = item.Value.health; sessionItem.uses = item.Value.uses; sessionItem.cost= item.Value.cost; sessionItem.power = item.Value.power; sessionItem.range = item.Value.range; sessionItem.state = item.Value.state; items.Add(item.Value.id, sessionItem); } } // Save Locations if(Map.master){ locations = new Dictionary<string, SessionLocation>(); foreach (string key in Map.master.locationDictionary.Keys){ Location location = Map.master.locationDictionary[key]; SessionLocation sessionLocation = new SessionLocation(); sessionLocation.accessable = location.accessable; if(location.owner != null){ sessionLocation.owner = location.owner.name; } else { sessionLocation.owner = null; } sessionLocation.state = location.state; locations.Add(location.id, sessionLocation); } } // Save People if(Population.master){ people = new Dictionary<string, SessionPerson>(); foreach(KeyValuePair<string,Person> person in Population.master.peopleDictionary){ SessionPerson sessionPerson = new SessionPerson(); sessionPerson.position = person.Value.transform.position; sessionPerson.location = person.Value.currentLocation.id; sessionPerson.health = person.Value.health; sessionPerson.energy = person.Value.energy; sessionPerson.hunger = person.Value.hunger; sessionPerson.money = person.Value.money; sessionPerson.power = person.Value.power; sessionPerson.speed = person.Value.speed; sessionPerson.range = person.Value.range; sessionPerson.state = person.Value.state; sessionPerson.emotion = person.Value.emotion; sessionPerson.reputations = new Dictionary<string, float>(); foreach(Person key in person.Value.reputation.reputations.Keys){ sessionPerson.reputations.Add(key.id, person.Value.reputation.reputations[key]); } people.Add(person.Value.id, sessionPerson); } } //Save Conversations if(ConversationManager.master){ conversations = new List<SessionConversation>(); foreach(Conversation _conversation in ConversationManager.master.conversations){ SessionConversation sessionConversation = new SessionConversation(); sessionConversation.id = _conversation.conversationReference; foreach(Person _participant in _conversation.participants){ string id = _participant.id; sessionConversation.participants.Add(id); } sessionConversation.lineReference = _conversation.currentLineRef; sessionConversation.currentTime = _conversation.currentTime; conversations.Add(sessionConversation); } } }
// ---------------------------------------------------------------------------------------------------- // Pre-Processing Operations // ---------------------------------------------------------------------------------------------------- // (None) // ---------------------------------------------------------------------------------------------------- // Input Processing Operations // ---------------------------------------------------------------------------------------------------- protected override void ProcessRecord() { foreach (var src_paths in this.Path) { string dest_zipfilepath = null; foreach (var src_path in SessionLocation.GetResolvedPath(this.SessionState, src_paths)) { // SET Destination ZIP File Path if (dest_zipfilepath is null) { // Destination ZIP File Path is not yet set. // SET Destination ZIP File Path dest_zipfilepath = this.DestinationPath is null? SessionLocation.GetUnresolvedPath(this.SessionState, System.IO.Path.GetFileNameWithoutExtension(src_path)) + ".zip" : SessionLocation.GetUnresolvedPath(this.SessionState, this.DestinationPath); // Validation (Destination Path Existence Check: Directory): if (Directory.Exists(dest_zipfilepath)) { throw new IOException(); } // Validation (Destination Path Existence Check: File): if (File.Exists(dest_zipfilepath)) { if (this.Force) { File.Delete(dest_zipfilepath); } else { throw new IOException(); } } } // Should Process if (this.ShouldProcess($"Source: '{src_path}', Destination:'{dest_zipfilepath}'", "ファイルの圧縮")) { // using ZipFile using (ZipFile zip = new ZipFile(dest_zipfilepath, this.Encoding ?? Encoding.UTF8)) { // SET Password if (!string.IsNullOrEmpty(this.Password)) { zip.Password = this.Password; } // SET ZIP64 extension zip.UseZip64WhenSaving = Zip64Option.AsNecessary; // Workaround of DotNetZip bug zip.ParallelDeflateThreshold = -1; // SET Flag for workaround not to save timestamp zip.EmitTimesInWindowsFormatWhenSaving = false; zip.EmitTimesInUnixFormatWhenSaving = false; // ProgressRecord (Main): ProgressRecord mainProgress = new ProgressRecord(0, $"{this.MyInvocation.MyCommand}: '{src_path}' を圧縮しています", "準備中..."); // ProgressRecord (Sub): ProgressRecord subProgress = new ProgressRecord(1, "準備中...", "準備中...") { ParentActivityId = 0 }; // Register Event Handler only if needed if (!this.SuppressProgress) { // Count(s) int entryCount = 0; int eventCount = 0; int eventIntervalCount = 150; // ZipFile.ExtractProgress Event Handler zip.SaveProgress += (object sender, SaveProgressEventArgs e) => { #if DEBUG // DEBUG Output this.WriteDebug(""); this.WriteDebug($"e.{nameof(e.EventType)} = {e.EventType}"); this.WriteDebug($"e.{nameof(e.ArchiveName)} = {e.ArchiveName}"); this.WriteDebug($"e.{nameof(e.BytesTransferred)} = {e.BytesTransferred}"); this.WriteDebug($"e.{nameof(e.TotalBytesToTransfer)} = {e.TotalBytesToTransfer}"); this.WriteDebug($"e.{nameof(e.EntriesTotal)} = {e.EntriesTotal}"); this.WriteDebug($"e.{nameof(e.CurrentEntry)} = {e.CurrentEntry}"); this.WriteDebug($"e.{nameof(e.EntriesSaved)} = {e.EntriesSaved}"); #endif // for ProgressRecord(s) switch (e.EventType) { case ZipProgressEventType.Saving_AfterWriteEntry: break; case ZipProgressEventType.Saving_EntryBytesRead: break; default: break; } switch (e.EventType) { // Before Write Entry case ZipProgressEventType.Saving_BeforeWriteEntry: // Increment count of Entry entryCount++; mainProgress.Activity = (zip.Count > 1) ? $"{this.MyInvocation.MyCommand}: '{src_path}' ({entryCount} / {zip.Count}) を圧縮しています" : $"{this.MyInvocation.MyCommand}: '{src_path}' を圧縮しています"; mainProgress.StatusDescription = $"'{e.CurrentEntry.FileName}' を圧縮中..."; mainProgress.PercentComplete = 100 * (entryCount - 1) / zip.Count; // Write Progress (Main) this.WriteProgress(mainProgress); break; // Entry Bytes are read case ZipProgressEventType.Saving_EntryBytesRead: if (e.TotalBytesToTransfer != 0) { // Increment event count if (++eventCount > eventIntervalCount) { // UPDATE Progress (Main) mainProgress.StatusDescription = $"'{e.CurrentEntry.FileName}' ({e.BytesTransferred} / {e.TotalBytesToTransfer} バイト) を圧縮中..."; mainProgress.PercentComplete = ((100 * (entryCount - 1)) + (int)(100 * e.BytesTransferred / e.TotalBytesToTransfer)) / zip.Count; // Write Progress (Main) this.WriteProgress(mainProgress); // for Sub Progress if (this.MyInvocation.BoundParameters.ContainsKey("Verbose")) { // UPDATE Progress (Sub) subProgress.Activity = $"'{e.CurrentEntry}' を圧縮しています"; subProgress.StatusDescription = $"{e.BytesTransferred} / {e.TotalBytesToTransfer} バイトを圧縮中..."; subProgress.PercentComplete = (int)(100 * e.BytesTransferred / e.TotalBytesToTransfer); // Write Progress (Sub) this.WriteProgress(subProgress); } // Reset event count eventCount = 0; } } break; default: break; } // for ProgressRecord(s) }; // ZipFile.ExtractProgress Event Handler } // Add to Zip (Archive) if (File.Exists(src_path)) { // File zip.AddFile(src_path, string.Empty); } else if (Directory.Exists(src_path)) { // Directory zip.AddDirectory(src_path, new DirectoryInfo(src_path).Name); } else { throw new InvalidDataException(); } // Save as file zip.Save(); // Completion of ProgressRecord(s): foreach (var progress in new ProgressRecord[] { subProgress, mainProgress }) { if (progress != null) { // Complete the Progress progress.PercentComplete = 100; progress.RecordType = ProgressRecordType.Completed; // Write Progress this.WriteProgress(progress); } } // Output (PassThru) if (this.PassThru) { this.WriteObject(new FileInfo(dest_zipfilepath)); } } // using ZipFile } // Should Process } } }
public void Read() { // Load Time/Events Session.master.time = time; Session.master.day = currentDay; Session.master.completedEvents = completedEvents; Session.master.failedEvents = failedEvents; Session.master.dayEvents = new Dictionary<string, List<string>>(); foreach(DaySave day in days){ Session.master.dayEvents.Add(day.dayName, day.events); } //Load Locations Session.master.locations = new Dictionary<string, SessionLocation>(); foreach(LocationSave locationSave in mapSave){ SessionLocation sessionLocation = new SessionLocation(); sessionLocation.accessable = bool.Parse(locationSave.accessable); sessionLocation.owner = locationSave.owner; sessionLocation.state = locationSave.state; Session.master.locations.Add(locationSave.id, sessionLocation); } //Load People Session.master.people = new Dictionary<string, SessionPerson>(); foreach(PersonSave personSave in peopleSave){ SessionPerson sessionPerson = new SessionPerson(); sessionPerson.location = personSave.location; sessionPerson.position = new Vector3(personSave.position[0], personSave.position[1], personSave.position[2]); sessionPerson.health = personSave.health; sessionPerson.energy = personSave.energy; sessionPerson.hunger = personSave.hunger; sessionPerson.money = personSave.money; sessionPerson.power = personSave.power; sessionPerson.speed = personSave.speed; sessionPerson.range = personSave.range; sessionPerson.state = personSave.state; sessionPerson.emotion = personSave.emotion; sessionPerson.reputations = new Dictionary<string, float>(); for(int i=0; i<personSave.reputationPeople.Count; i++){ sessionPerson.reputations.Add(personSave.reputationPeople[i], personSave.reputations[i]); } Session.master.people.Add(personSave.id, sessionPerson); } // Load Items Session.master.items = new Dictionary<string, SessionItem>(); foreach(ItemSave itemSave in inventorySave){ SessionItem sessionItem = new SessionItem(); sessionItem.location = itemSave.location; sessionItem.position = new Vector3(itemSave.position[0], itemSave.position[1], itemSave.position[2]); sessionItem.owner = itemSave.owner; sessionItem.holder = itemSave.holder; sessionItem.properties = itemSave.properties; sessionItem.health = itemSave.health; sessionItem.uses = itemSave.uses; sessionItem.cost = itemSave.cost; sessionItem.power = itemSave.power; sessionItem.range = itemSave.range; sessionItem.state = itemSave.state; Session.master.items.Add(itemSave.name, sessionItem); } // Load Pictures Session.master.pictures = new List<SessionPicture>(); foreach(PictureSave pictureSave in picturesSave){ SessionPicture sessionPicture = new SessionPicture(); sessionPicture.position = new Vector3(pictureSave.position[0], pictureSave.position[1], pictureSave.position[2]); sessionPicture.subject = pictureSave.subject; sessionPicture.rotation = pictureSave.rotation; Session.master.pictures.Add(sessionPicture); } // Load Pins Session.master.pins = new List<SessionPin>(); foreach(PinSave pinSave in pinsSave){ SessionPin sessionPin = new SessionPin(); sessionPin.position = new Vector3(pinSave.position[0], pinSave.position[1], pinSave.position[2]); sessionPin.colour = new Color(pinSave.colour[0], pinSave.colour[1], pinSave.colour[2]); Session.master.pins.Add(sessionPin); } // Load PostIts Session.master.postits = new List<SessionPostIt>(); foreach(PostItSave postitSave in postitsSave){ SessionPostIt sessionPostIt = new SessionPostIt(); sessionPostIt.position = new Vector3(postitSave.position[0], postitSave.position[1], postitSave.position[2]); sessionPostIt.message = postitSave.message; sessionPostIt.rotation = postitSave.rotation; Session.master.postits.Add(sessionPostIt); } // Load Strings Session.master.strings = new List<SessionString>(); foreach(StringSave stringSave in stringsSave){ SessionString sessionString = new SessionString(); sessionString.startPoint = new Vector3(stringSave.startPoint[0], stringSave.startPoint[1], stringSave.startPoint[2]); sessionString.endPoint = new Vector3(stringSave.endPoint[0], stringSave.endPoint[1], stringSave.endPoint[2]); Session.master.strings.Add(sessionString); } }