Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 public void AddResource(CTResourceType toAdd, string name)
 {
     m_resources[toAdd].Add(name, new CTResource(name, toAdd));
 }
Ejemplo n.º 5
0
 public CTResource(string filename, CTResourceType resource = CTResourceType.TextFile)
 {
     m_filename     = filename;
     m_resourceType = resource;
 }