Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 public static ModuleVersionRange Minimum(ModuleVersion version)
 {
     return(new ModuleVersionRange(version.MajorVersion,
                                   version.MinorVersion,
                                   version.Revision,
                                   version.IsPreRelease));
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 public ModuleReleaseIdentifier(ModuleIdentifier module, ModuleVersion version)
 {
     if (module == ModuleIdentifier.UnknownModule || version == ModuleVersion.Unknown)
     {
         this = UnknownModuleRelease;
     }
     else
     {
         Module  = module;
         Version = version;
     }
 }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        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;
        }