GetFileVersion() public static method

Retrieves a semver compliant version from a Type.
public static GetFileVersion ( Type type ) : string
type System.Type to retrieve version from.
return string
Ejemplo n.º 1
0
        public GenericHost(IConfigureThisEndpoint specifier, string[] args, List <Type> defaultProfiles, string endpointName, IEnumerable <string> scannableAssembliesFullName = null)
        {
            this.specifier = specifier;

            if (String.IsNullOrEmpty(endpointName))
            {
                endpointName = specifier.GetType().Namespace ?? specifier.GetType().Assembly.GetName().Name;
            }


            endpointNameToUse    = endpointName;
            endpointVersionToUse = FileVersionRetriever.GetFileVersion(specifier.GetType());

            if (scannableAssembliesFullName == null || !scannableAssembliesFullName.Any())
            {
                var assemblyScanner = new AssemblyScanner();
                assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IHandleMessages <>).Assembly);
                assembliesToScan = assemblyScanner
                                   .GetScannableAssemblies()
                                   .Assemblies;
            }
            else
            {
                assembliesToScan = scannableAssembliesFullName
                                   .Select(Assembly.Load)
                                   .ToList();
            }

            profileManager = new ProfileManager(assembliesToScan, args, defaultProfiles);

            wcfManager = new WcfManager();
        }
Ejemplo n.º 2
0
        public void InitializeWithInternallyManagedContainer()
        {
            ownsContainer = true;

            var container = customContainer;

            if (container == null)
            {
                settings.AddStartupDiagnosticsSection("Container", new
                {
                    Type = "internal"
                });

                container = new LightInjectObjectBuilder();
            }
            else
            {
                var containerType = container.GetType();

                settings.AddStartupDiagnosticsSection("Container", new
                {
                    Type    = containerType.FullName,
                    Version = FileVersionRetriever.GetFileVersion(containerType)
                });
            }

            var commonObjectBuilder = new CommonObjectBuilder(container);

            ContainerConfiguration = commonObjectBuilder;
            Builder = commonObjectBuilder;

            ApplyRegistrations();
        }
Ejemplo n.º 3
0
        protected internal sealed override void Setup(FeatureConfigurationContext context)
        {
            var mapper   = new MessageMapper();
            var settings = context.Settings;
            var messageMetadataRegistry = settings.Get <MessageMetadataRegistry>();

            mapper.Initialize(messageMetadataRegistry.GetAllMessages().Select(m => m.MessageType));

            var defaultSerializerAndDefinition = settings.GetMainSerializer();

            var defaultSerializer = CreateMessageSerializer(defaultSerializerAndDefinition, mapper, settings);

            var additionalDeserializerDefinitions = context.Settings.GetAdditionalSerializers();
            var additionalDeserializers           = new List <IMessageSerializer>();

            var additionalDeserializerDiagnostics = new List <object>();

            foreach (var definitionAndSettings in additionalDeserializerDefinitions)
            {
                var deserializer = CreateMessageSerializer(definitionAndSettings, mapper, settings);
                additionalDeserializers.Add(deserializer);

                var deserializerType = definitionAndSettings.Item1.GetType();

                additionalDeserializerDiagnostics.Add(new
                {
                    Type    = deserializerType.FullName,
                    Version = FileVersionRetriever.GetFileVersion(deserializerType),
                    deserializer.ContentType
                });
            }

            var resolver = new MessageDeserializerResolver(defaultSerializer, additionalDeserializers);

            var logicalMessageFactory = new LogicalMessageFactory(messageMetadataRegistry, mapper);

            context.Pipeline.Register(new DeserializeLogicalMessagesConnector(resolver, logicalMessageFactory, messageMetadataRegistry, mapper), "Deserializes the physical message body into logical messages");
            context.Pipeline.Register(new SerializeMessageConnector(defaultSerializer, messageMetadataRegistry), "Converts a logical message into a physical message");

            context.Container.ConfigureComponent(_ => mapper, DependencyLifecycle.SingleInstance);
            context.Container.ConfigureComponent(_ => messageMetadataRegistry, DependencyLifecycle.SingleInstance);
            context.Container.ConfigureComponent(_ => logicalMessageFactory, DependencyLifecycle.SingleInstance);

            LogFoundMessages(messageMetadataRegistry.GetAllMessages().ToList());

            context.Settings.AddStartupDiagnosticsSection("Serialization", new
            {
                DefaultSerializer = new
                {
                    Type    = defaultSerializerAndDefinition.Item1.GetType().FullName,
                    Version = FileVersionRetriever.GetFileVersion(defaultSerializerAndDefinition.Item1.GetType()),
                    defaultSerializer.ContentType
                },
                AdditionalDeserializers = additionalDeserializerDiagnostics
            });
        }
Ejemplo n.º 4
0
        public static async Task <IStartableEndpoint> CreateWithInternallyManagedContainer(EndpointConfiguration endpointConfiguration)
        {
            var settings = endpointConfiguration.Settings;

            CheckIfSettingsWhereUsedToCreateAnotherEndpoint(settings);

            var assemblyScanningComponent = AssemblyScanningComponent.Initialize(settings.Get <AssemblyScanningComponent.Configuration>(), settings);

            endpointConfiguration.FinalizeConfiguration(assemblyScanningComponent.AvailableTypes);

            var hostingSetting    = settings.Get <HostingComponent.Settings>();
            var useDefaultBuilder = hostingSetting.CustomObjectBuilder == null;
            var container         = useDefaultBuilder ? new LightInjectObjectBuilder() : hostingSetting.CustomObjectBuilder;

            var commonObjectBuilder = new CommonObjectBuilder(container);

            IConfigureComponents internalContainer = commonObjectBuilder;
            IBuilder             internalBuilder   = commonObjectBuilder;

            //for backwards compatibility we need to make the IBuilder available in the container
            internalContainer.ConfigureComponent(_ => internalBuilder, DependencyLifecycle.SingleInstance);

            var hostingConfiguration = HostingComponent.PrepareConfiguration(settings.Get <HostingComponent.Settings>(), assemblyScanningComponent, internalContainer);

            if (useDefaultBuilder)
            {
                hostingConfiguration.AddStartupDiagnosticsSection("Container", new
                {
                    Type = "internal"
                });
            }
            else
            {
                var containerType = internalContainer.GetType();

                hostingConfiguration.AddStartupDiagnosticsSection("Container", new
                {
                    Type    = containerType.FullName,
                    Version = FileVersionRetriever.GetFileVersion(containerType)
                });
            }

            var endpointCreator = EndpointCreator.Create(settings, hostingConfiguration);

            var hostingComponent = HostingComponent.Initialize(hostingConfiguration);

            var startableEndpoint = endpointCreator.CreateStartableEndpoint(internalBuilder, hostingComponent);

            hostingComponent.RegisterBuilder(internalBuilder, true);

            await hostingComponent.RunInstallers().ConfigureAwait(false);

            return(new InternallyManagedContainerHost(startableEndpoint, hostingComponent));
        }
        public static AssemblyScanningComponent Initialize(Configuration configuration, SettingsHolder settings)
        {
            var shouldScanBinDirectory = configuration.UserProvidedTypes == null;

            List <Type>     availableTypes;
            AssemblyScanner assemblyScanner;

            if (shouldScanBinDirectory)
            {
                var directoryToScan = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;

                assemblyScanner = new AssemblyScanner(directoryToScan);
                availableTypes  = new List <Type>();
            }
            else
            {
                assemblyScanner = new AssemblyScanner(Assembly.GetExecutingAssembly());
                availableTypes  = configuration.UserProvidedTypes;
            }

            var assemblyScannerSettings = configuration.AssemblyScannerConfiguration;

            assemblyScanner.AssembliesToSkip               = assemblyScannerSettings.ExcludedAssemblies;
            assemblyScanner.TypesToSkip                    = assemblyScannerSettings.ExcludedTypes;
            assemblyScanner.ScanNestedDirectories          = assemblyScannerSettings.ScanAssembliesInNestedDirectories;
            assemblyScanner.ThrowExceptions                = assemblyScannerSettings.ThrowExceptions;
            assemblyScanner.ScanAppDomainAssemblies        = assemblyScannerSettings.ScanAppDomainAssemblies;
            assemblyScanner.AdditionalAssemblyScanningPath = assemblyScannerSettings.AdditionalAssemblyScanningPath;

            var scannableAssemblies = assemblyScanner.GetScannableAssemblies();

            availableTypes = availableTypes.Union(scannableAssemblies.Types).ToList();

            configuration.SetDefaultAvailableTypes(availableTypes);

            if (shouldScanBinDirectory)
            {
                settings.AddStartupDiagnosticsSection("AssemblyScanning", new
                {
                    Assemblies = scannableAssemblies.Assemblies.Select(a => new
                    {
                        a.FullName,
                        FileVersion = FileVersionRetriever.GetFileVersion(a)
                    }),
                    scannableAssemblies.ErrorsThrownDuringScanning,
                    scannableAssemblies.SkippedFiles,
                    Settings = assemblyScannerSettings
                });
            }

            return(new AssemblyScanningComponent(availableTypes));
        }
Ejemplo n.º 6
0
        public static TransportSeam Create(Settings transportSettings, HostingComponent.Configuration hostingConfiguration)
        {
            var transportDefinition = transportSettings.TransportDefinition;
            var connectionString    = transportSettings.TransportConnectionString.GetConnectionStringOrRaiseError(transportDefinition);

            var transportInfrastructure = transportDefinition.Initialize(transportSettings.settings, connectionString);

            //RegisterTransportInfrastructureForBackwardsCompatibility
            transportSettings.settings.Set(transportInfrastructure);

            hostingConfiguration.AddStartupDiagnosticsSection("Transport", new
            {
                Type    = transportInfrastructure.GetType().FullName,
                Version = FileVersionRetriever.GetFileVersion(transportInfrastructure.GetType())
            });

            return(new TransportSeam(transportInfrastructure, transportSettings.QueueBindings));
        }
Ejemplo n.º 7
0
        public static TransportComponent Initialize(Configuration configuration, HostingComponent.Configuration hostingConfiguration)
        {
            var transportComponent = new TransportComponent(configuration.transportInfrastructure, configuration.QueueBindings);

            if (configuration.ReceivingEnabled)
            {
                transportComponent.ConfigureReceiveInfrastructure();
            }

            hostingConfiguration.Container.ConfigureComponent(() => transportComponent.GetOrCreateDispatcher(), DependencyLifecycle.SingleInstance);

            hostingConfiguration.AddStartupDiagnosticsSection("Transport", new
            {
                Type    = configuration.TransportType.FullName,
                Version = FileVersionRetriever.GetFileVersion(configuration.TransportType)
            });

            return(transportComponent);
        }
Ejemplo n.º 8
0
        public static TransportComponent Initialize(Configuration configuration, SettingsHolder settings)
        {
            var transportDefinition = configuration.TransportDefinition;
            var connectionString    = configuration.TransportConnectionString.GetConnectionStringOrRaiseError(transportDefinition);

            var transportInfrastructure = transportDefinition.Initialize(settings, connectionString);

            //for backwards compatibility
            settings.Set(transportInfrastructure);

            var transportType = transportDefinition.GetType();

            settings.AddStartupDiagnosticsSection("Transport", new
            {
                Type    = transportType.FullName,
                Version = FileVersionRetriever.GetFileVersion(transportType)
            });

            return(new TransportComponent(transportInfrastructure, configuration.QueueBindings));
        }
        IContainer ConfigureContainer()
        {
            if (customBuilder == null)
            {
                Settings.AddStartupDiagnosticsSection("Container", new
                {
                    Type = "internal"
                });
                return(new LightInjectObjectBuilder());
            }

            var containerType = customBuilder.GetType();

            Settings.AddStartupDiagnosticsSection("Container", new
            {
                Type    = containerType.FullName,
                Version = FileVersionRetriever.GetFileVersion(containerType)
            });

            return(customBuilder);
        }
Ejemplo n.º 10
0
        public void Run(SettingsHolder settings)
        {
            if (!settings.TryGet("PersistenceDefinitions", out List <EnabledPersistence> definitions))
            {
                return;
            }

            var enabledPersistences = PersistenceStorageMerger.Merge(definitions, settings);

            ValidateSagaAndOutboxUseSamePersistence(enabledPersistences, settings);

            var resultingSupportedStorages = new List <Type>();
            var diagnostics = new Dictionary <string, object>();

            foreach (var definition in enabledPersistences)
            {
                var persistenceDefinition = definition.DefinitionType.Construct <PersistenceDefinition>();

                persistenceDefinition.ApplyDefaults(settings);

                foreach (var storageType in definition.SelectedStorages)
                {
                    Logger.DebugFormat("Activating persistence '{0}' to provide storage for '{1}' storage.", definition.DefinitionType.Name, storageType);
                    persistenceDefinition.ApplyActionForStorage(storageType, settings);
                    resultingSupportedStorages.Add(storageType);

                    diagnostics.Add(storageType.Name, new
                    {
                        Type    = definition.DefinitionType.FullName,
                        Version = FileVersionRetriever.GetFileVersion(definition.DefinitionType)
                    });
                }
            }

            settings.Set("ResultingSupportedStorages", resultingSupportedStorages);

            settings.AddStartupDiagnosticsSection("Persistence", diagnostics);
        }
Ejemplo n.º 11
0
        TransportInfrastructure InitializeTransportComponent()
        {
            if (!settings.HasExplicitValue <TransportDefinition>())
            {
                throw new Exception("A transport has not been configured. Use 'EndpointConfiguration.UseTransport()' to specify a transport.");
            }

            var transportDefinition     = settings.Get <TransportDefinition>();
            var connectionString        = settings.Get <TransportConnectionString>().GetConnectionStringOrRaiseError(transportDefinition);
            var transportInfrastructure = transportDefinition.Initialize(settings, connectionString);

            settings.Set(transportInfrastructure);

            var transportType = transportDefinition.GetType();

            settings.AddStartupDiagnosticsSection("Transport", new
            {
                Type    = transportType.FullName,
                Version = FileVersionRetriever.GetFileVersion(transportType)
            });

            return(transportInfrastructure);
        }