public static string GetId(GameObject gameObject) { if (Instance == null || gameObject == null) { return(string.Empty); } var entry = Instance.Reference[gameObject]; if (entry != null) { return(entry.Id); } // TODO: Keep an eye on this. Application.isLoadingLevel was deprecated without any equivalent replacement. It still works though, so I won't touch it for now. #pragma warning disable if (Application.isLoadingLevel && !Application.isPlaying) { return(null); } #pragma warning restore entry = new StoredEntry { gameObject = gameObject }; Instance.Reference[entry.Id] = entry; return(entry.Id); }
public static PassEntry GetPfpEntry(PwEntry pwEntry) { var entry = new PwEntryIndexer(pwEntry, null); var result = new StoredEntry(); var fields = new SortedDictionary <string, string> { { PwDefs.UserNameField, EmptyUsername }, { PwDefs.PasswordField, EmptyPassword }, { PwDefs.UrlField, EmptyUrl }, { PwDefs.NotesField, "" }, { RevisionField, "" } }; result.notes = "%fields%"; result.notes += ParseNotes(entry[PwDefs.NotesField] ?? "", fields) .Replace("\r\n", "\n").Replace("\r", "\n"); foreach (var field in pwEntry.Strings) { if (!entry[field.Key].Equals("")) { fields[field.Key] = entry[field.Key]; } } result.site = fields[PwDefs.UrlField]; result.name = fields[PwDefs.UserNameField]; result.password = fields[PwDefs.PasswordField]; result.revision = fields[RevisionField]; fields.Remove(PwDefs.TitleField); fields.Remove(PwDefs.UserNameField); fields.Remove(PwDefs.PasswordField); fields.Remove(PwDefs.UrlField); fields.Remove(PwDefs.NotesField); fields.Remove(RevisionField); foreach (var field in fields) { var value = field.Value.Replace("\r\n", " ").Replace("\n", " "); result.notes = result.notes.Replace("%fields%", $"{field.Key}: {value}\n%fields%"); } result.site = GetSitePart(result.site); result.notes = result.notes.Replace("%fields%", "\n").Trim(); if (result.notes.Equals("")) { result.notes = null; } return(result); }
private StoredEntry ConvertValue(IStoredEntry value) { StoredEntry convertedValue = null; if (value != null) { convertedValue = value as StoredEntry ?? new StoredEntry(value); Assert(convertedValue != null); Assert(convertedValue.Id == value.Path.EscapedPath.ConvertToString()); } return(convertedValue); }
public void SetId(GameObject gameObject, string id) { var rr = Instance.Reference[gameObject] ?? Instance.Reference[id]; if(rr != null) { Instance.Reference.Remove(rr.gameObject); rr.Id = id; rr.gameObject = gameObject; } else { rr =new StoredEntry { gameObject = gameObject, Id = id }; } Instance.Reference[rr.Id] = rr; }
public void SetId(GameObject gameObject, string id) { var rr = Instance.Reference[gameObject] ?? Instance.Reference[id]; if (rr != null) { Instance.Reference.Remove(rr.gameObject); rr.Id = id; rr.gameObject = gameObject; } else { rr = new StoredEntry { gameObject = gameObject, Id = id }; } Instance.Reference[rr.Id] = rr; }
public static string GetId(GameObject gameObject) { if (Instance == null || gameObject == null) { return(string.Empty); } var entry = Instance.Reference[gameObject]; if (entry != null) { return(entry.Id); } if (Application.isLoadingLevel && !Application.isPlaying) { return(null); } entry = new StoredEntry { gameObject = gameObject }; Instance.Reference[entry.Id] = entry; return(entry.Id); }
public static string GetId(GameObject gameObject) { if(Instance == null || gameObject == null) return string.Empty; var entry = Instance.Reference[gameObject]; if(entry != null) return entry.Id; if(Application.isLoadingLevel && !Application.isPlaying) { return null; } entry = new StoredEntry { gameObject = gameObject}; Instance.Reference[entry.Id] = entry; return entry.Id; }
public static string GetId(GameObject gameObject) { if(Instance == null || gameObject == null) return string.Empty; var entry = Instance.Reference[gameObject]; if(entry != null) return entry.Id; // TODO: Keep an eye on this. Application.isLoadingLevel was deprecated without any equivalent replacement. It still works though, so I won't touch it for now. if(Application.isLoadingLevel && !Application.isPlaying) { return null; } entry = new StoredEntry { gameObject = gameObject}; Instance.Reference[entry.Id] = entry; return entry.Id; }