public ComponentProviderEntry GetComponent(string type, string category, string name) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (category == null) { throw new ArgumentNullException(nameof(category)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } var resourceLibrary = DatabaseResourceLibrary.Load(m_quiltContextFactory, category); var resourceLibraryEntry = resourceLibrary.GetEntry(name); if (resourceLibraryEntry == null || resourceLibraryEntry.Type != ResourceTypePrefix + type) { return(null); } var entry = CreateEntry(category, resourceLibraryEntry); return(entry); }
private IResourceLibrary GetResourceLibrarySync(string category) { if (string.IsNullOrEmpty(category)) { throw new ArgumentNullException(nameof(category)); } if (!m_resourceLibraries.TryGetValue(category, out IResourceLibrary resourceLibrary)) { resourceLibrary = DatabaseResourceLibrary.Load(m_quiltContextFactory, category); m_resourceLibraries[category] = resourceLibrary; } return(resourceLibrary); }
public static void CreateStandardResources(IQuiltContextFactory quiltContextFactory) { var library = DatabaseResourceLibrary.Load(quiltContextFactory, Constants.DefaultComponentCategory); foreach (var nodeGenerator in GetNodeGenerators()) { foreach (var item in nodeGenerator.Generate()) { var entry = library.GetEntry(item.Name); if (entry == null) { library.CreateEntry(item.Name, DatabaseBlockComponentProvider.ResourceTypePrefix + BlockComponent.TypeName, item.Node.JsonSave().ToString(), item.Tags); } else { library.UpdateEntry(item.Name, item.Node.JsonSave().ToString(), item.Tags); } } } }
public List <ComponentProviderEntry> GetComponents(string type, string category) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (category == null) { throw new ArgumentNullException(nameof(category)); } var result = new List <ComponentProviderEntry>(); var resourceLibrary = DatabaseResourceLibrary.Load(m_quiltContextFactory, category); foreach (var resourceLibraryEntry in resourceLibrary.GetEntries().Where(r => r.Type == ResourceTypePrefix + type)) { var entry = CreateEntry(category, resourceLibraryEntry); result.Add(entry); } return(result); }