public string GetResourcePath(CTResourceType type, string name, bool force = false, bool saveIfForced = true) { CTResource res = null; if (m_resources[type].ContainsKey(name)) { res = m_resources[type][name]; } else if (force) { if (saveIfForced) { AddResource(type, name); res = m_resources[type][name]; } else { res = new CTResource(name, type); } } if (res != null) { return(res.Path); } else { throw new KeyNotFoundException(); } }
public void SaveResource(CTResourceType type, string name, string[] value) { string path = GetResourcePath(type, name, true); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } System.IO.File.WriteAllLines(path, value); }
internal CTResource[] GetAllResourcesOfType(CTResourceType resType) { List <CTResource> ret = new List <CTResource>(); foreach (CTResource doc in m_resources[resType].Values) { if (doc.ResourceType == resType) { ret.Add(doc); } } return(ret.ToArray()); }
public void AddResource(CTResourceType toAdd, string name) { m_resources[toAdd].Add(name, new CTResource(name, toAdd)); }
public CTResource(string filename, CTResourceType resource = CTResourceType.TextFile) { m_filename = filename; m_resourceType = resource; }