/// <summary> /// Adds scope registry. /// </summary> /// <param name="registry">An entry to add.</param> public void AddScopeRegistry(ScopeRegistry registry) { if (!IsRegistryExists(registry.Url)) { m_ScopeRegistries.Add(registry.Url, registry); } }
/// <summary> /// Read the Manifest file and deserialize its content from JSON. /// </summary> public void Fetch() { var manifestText = File.ReadAllText(Path); m_RawContent = (Dictionary <string, object>)Json.Deserialize(manifestText); if (m_RawContent.TryGetValue(k_ScopedRegistriesKey, out var registriesBlob)) { if (registriesBlob is List <object> registries) { foreach (var registry in registries) { var registryDict = (Dictionary <string, object>)registry; var scopeRegistry = new ScopeRegistry(registryDict); m_ScopeRegistries.Add(scopeRegistry.Url, scopeRegistry); } } } if (m_RawContent.TryGetValue(k_DependenciesKey, out var dependenciesBlob)) { if (dependenciesBlob is Dictionary <string, object> dependencies) { foreach (var dependencyData in dependencies) { var dependency = new Dependency(dependencyData.Key, dependencyData.Value.ToString()); m_Dependencies.Add(dependency.Name, dependency); } } } }
/// <summary> /// Adds <see cref="ScopeRegistry"/> with the provided properties. If manifest already contains <see cref="ScopeRegistry"/> with given url, /// provided scopes will be merged with existing <see cref="ScopeRegistry"/> scopes. /// Name of existing <see cref="ScopeRegistry"/> won't be updated. /// </summary> /// <param name="url">Scope registry url.</param> /// <param name="name">Scope registry name.</param> /// <param name="scopes">Scope registry scopes.</param> /// <returns>New <see cref="ScopeRegistry"/> with provided properties or existing with updated scopes, if <see cref="Manifest"/> /// already contains <see cref="ScopeRegistry"/> with given name.</returns> public ScopeRegistry AddScopeRegistry(string url, string name, IEnumerable <string> scopes) { ScopeRegistry registry; if (!IsScopeRegistryExists(url)) { registry = new ScopeRegistry(name, url, scopes); SetScopeRegistry(url, registry); } else { registry = GetScopeRegistry(url); foreach (var scope in scopes) { if (!registry.HasScope(scope)) { registry.AddScope(scope); } } } return(registry); }
/// <summary> /// Gets the <see cref="ScopeRegistry"/> associated with the specified url. /// </summary> /// <param name="url">The url of the <see cref="ScopeRegistry"/> to get.</param> /// <param name="registry">When this method returns, contains the <see cref="ScopeRegistry"/> associated with the specified url, /// if the url is found; otherwise, `null`. This parameter is passed uninitialized.</param> /// <returns>true if the <see cref="Manifest"/> contains a <see cref="ScopeRegistry"/> with the specified url; otherwise, false.</returns> public bool TryGetScopeRegistry(string url, out ScopeRegistry registry) { return(m_ScopeRegistries.TryGetValue(url, out registry)); }
/// <summary> /// Sets <see cref="ScopeRegistry"/> by given url. If manifest already contains <see cref="ScopeRegistry"/> with given url, /// existing <see cref="ScopeRegistry"/> will be overwritten. /// </summary> /// <param name="url">Scope registry url.</param> /// <param name="registry"><see cref="ScopeRegistry"/> to set.</param> public void SetScopeRegistry(string url, ScopeRegistry registry) { m_ScopeRegistries[url] = registry; }