private async ValueTask <IModuleMetadata> GetMetadataCoreAsync(Assembly entryAssembly, string metadataPath, CancellationToken cancellation) { if (File.Exists(metadataPath)) { try { using (var stream = new FileStream(metadataPath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true)) { return(await _metadataReader.ReadMetadataAsync(stream, cancellation)); } } catch (FileNotFoundException) { } catch (DirectoryNotFoundException) { } } // If we reach this point, we cannot find a manifest resource/file. // We now assembly our own metadata var asmName = entryAssembly.GetName(); var asmVersion = asmName.Version; var module = new ModuleIdentifier(asmName.Name); var version = new ModuleVersion(asmVersion.Major, asmVersion.Minor, asmVersion.Revision, isPreRelease: false); return(new ModuleMetadata(module, version)); }
public static ModuleVersionRange Minimum(ModuleVersion version) { return(new ModuleVersionRange(version.MajorVersion, version.MinorVersion, version.Revision, version.IsPreRelease)); }
public VersionedModule(string name, ModuleVersion version) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("The argument must neither be null nor an empty string or a string that consists of whitespace only.", nameof(name)); } Name = name; Version = version; }
public ModuleReleaseIdentifier(ModuleIdentifier module, ModuleVersion version) { if (module == ModuleIdentifier.UnknownModule || version == ModuleVersion.Unknown) { this = UnknownModuleRelease; } else { Module = module; Version = version; } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { switch (value) { case ModuleVersion moduleVersion: return(moduleVersion); case string str: return(ModuleVersion.Parse(str)); default: return(base.ConvertFrom(context, culture, value)); } }
public ModuleMetadata(ModuleIdentifier module, ModuleVersion version) { if (module == default) { throw new ArgumentDefaultException(nameof(module)); } if (version == default) { throw new ArgumentDefaultException(nameof(version)); } _version = version; _module = module; }
public ModuleDetails(string name, ModuleVersion version, string descriptiveName, string description, ImmutableArray <VersionedModule> dependencies) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("The argument must neither be null nor an empty string or a string that consists of whitespace only.", nameof(name)); } if (string.IsNullOrWhiteSpace(descriptiveName)) { throw new ArgumentException("The argument must neither be null nor an empty string or a string that consists of whitespace only.", nameof(descriptiveName)); } if (string.IsNullOrWhiteSpace(description)) { throw new ArgumentException("The argument must neither be null nor an empty string or a string that consists of whitespace only.", nameof(description)); } Name = name; Version = version; DescriptiveName = descriptiveName; Description = description; Dependencies = dependencies; }