protected override void Load(ContainerBuilder builder) { builder.RegisterAssemblyTypes(_assembliesToScan) .Where(t => { var a = typeof(IConsumer).IsAssignableFrom(t); return(a); }) .AsSelf(); builder.Register(context => Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri(_busConfiguration.HostAddress), _busConfiguration.VirtualHost, h => { h.Username(_busConfiguration.Username); h.Password(_busConfiguration.Password); }); cfg.ReceiveEndpoint(host, ThisAssembly.GetName().Name, e => { //Add MassTransit Consumer }); cfg.ReceiveEndpoint(host, ec => { ec.LoadFrom(context.Resolve <ILifetimeScope>()); }); }) ).SingleInstance() .As <IBusControl>() .As <IBus>(); }
protected override void Load(ContainerBuilder builder) { var config = new ConfigurationBuilder(); config.AddJsonFile($"{ThisAssembly.GetName().Name}.Config.Dependency.json"); var module = new ConfigurationModule(config.Build()); builder.RegisterModule(module); }
partial void OverrideDefaultBusEndpointQueueName(IComponentContext componentContext, IRabbitMqBusFactoryConfigurator bus) { var busOptions = componentContext.Resolve <IOptions <BusOptions> >(); var queueName = busOptions.Value.QueueNameFormat .Replace("{MachineName}", HostMetadataCache.Host.MachineName) .Replace("{AssemblyVersion}", HostMetadataCache.Host.AssemblyVersion) .Replace("{ProcessName}", HostMetadataCache.Host.ProcessName) .Replace("{AssemblyName}", ThisAssembly.GetName().Name) .Replace("{NewId}", NewId.Next().ToString(new ZBase32Formatter())); bus.OverrideDefaultBusEndpointQueueName(queueName); }
public virtual void Initialize(CacheOptions cacheOptions) { #if DEBUG new InternalDebugDiagnostics().ValidateCore(this); #endif Settings.CacheOptions = cacheOptions; if (!_initalized) { _initalized = true; RaiseIsInitializedChanged(); } try { DateTime startTime = DateTime.Now; lock (_assembliesLock) { Console.WriteLine("NetOffice Core.Initialize() Core Version:{0}; Deep Loading:{1}; Load Assemblies Unsafe:{2}; AppDomain:{3}", ThisAssembly.GetName().Version, Settings.EnableDeepLoading, Settings.LoadAssembliesUnsafe, AppDomain.CurrentDomain.Id.ToString() + "-" + AppDomain.CurrentDomain.FriendlyName); if (Settings.EnableMoreDebugOutput) { string localPath = Resolver.UriResolver.ResolveLocalPath(ThisAssembly.CodeBase); Console.WriteLine("Local Bind Path:{0}", localPath); } CoreDomain.TryLoadAssemblies(this); ClearCaches(false); InternalFactories.LoadAPIFactories(); InternalFactories.LoadDependentAPIFactories(); InitializedTime = DateTime.Now - startTime; if (Settings.EnableMoreDebugOutput) { Console.WriteLine("NetOffice Core contains {0} assemblies", InternalFactories.FactoryAssemblies.Count); Console.WriteLine("NetOffice Core.Initialize() passed in {0} milliseconds", InitializedTime.TotalMilliseconds); } } } catch (Exception exception) { DebugConsole.Default.WriteException(exception); throw new NetOfficeInitializeException(exception); } }
/// <summary> /// Retrieves an icon from resources. /// Icon must be specified by resource name, /// for convenience .ico extension is optional. /// </summary> public static Icon GetIconFromResource(string IconName) { // load the icon from resources Stream iconStream; String tempStr = String.Format("{0}.{1}", ThisAssembly.GetName().Name, IconName); if (DisplayResolution == DisplayResolution.QVGA) { iconStream = ThisAssembly.GetManifestResourceStream(tempStr + ".ico"); } else { iconStream = ThisAssembly.GetManifestResourceStream(tempStr + "32.ico"); } Icon theIcon = new Icon(iconStream); iconStream.Close(); return(theIcon); }
/// <summary> /// Initializes variables of Executor Program instance on program startup. /// </summary> private void Initialize() { ThisAssembly = Assembly.GetExecutingAssembly(); ExeID = string.Format(CultureInfo.InvariantCulture, "{0}, Version={1}", ThisAssembly.GetName().Name, ThisAssembly.GetName().Version); ExeName = ThisAssembly.ManifestModule.Name; ExeDir = Path.GetDirectoryName(ThisAssembly.Location); _enlistment = new Office14Enlistment(); }
public static int Main(string[] args) { var now = DateTimeOffset.Now; var app = new CommandLineApplication(); app.Name = "VersionGenerator.exe"; app.FullName = "Version Generator"; app.ValueParsers.AddOrReplace(new DateTimeOffsetValueParser()); app.HelpOption(); app.VersionOption("-v|--version", ThisAssembly.GetName().Version.ToString()); app.Command("A", command => { command.Description = "Generate a type-A version"; command.HelpOption(); var optionTimestamp = command.OptionTimestamp(); var optionMajor = command.OptionMajorVersion(); var optionMinor = command.OptionMinorVersion(); command.OnExecute(() => { var version = VersionTypeA.GenerateFromTimestamp( timestamp: optionTimestamp.ParsedValue ?? now, major: optionMajor.ParsedValue ?? 1, minor: optionMinor.ParsedValue ?? 0); Console.WriteLine(version); return(0); }); }); app.Command("B", command => { command.Description = "Generate a type-B version"; command.HelpOption(); var optionTimestamp = command.OptionTimestamp(); var optionMajor = command.OptionMajorVersion(); var optionMinor = command.OptionMinorVersion(); command.OnExecute(() => { var version = VersionTypeB.GenerateFromTimestamp( timestamp: optionTimestamp.ParsedValue ?? now); Console.WriteLine(version); return(0); }); }); app.Command("C", command => { command.Description = "Generate a type-C version"; command.HelpOption(); var optionTimestamp = command.OptionTimestamp(); var optionMajor = command.OptionMajorVersion(); command.OnExecute(() => { var version = VersionTypeC.GenerateFromTimestamp( timestamp: optionTimestamp.ParsedValue ?? now, major: optionMajor.ParsedValue ?? 1); Console.WriteLine(version); return(0); }); }); // When executing without a command, just show the help. app.OnExecute(() => { app.ShowHelp(); }); // Run the app. try { return(app.Execute(args)); } catch (Exception) { app.ShowHelp(); return(-1); } }
protected string FormatResourceName(string resourceName) { return(ThisAssembly.GetName().Name + "." + resourceName.Replace(" ", "_") .Replace("\\", ".") .Replace("/", ".")); }
/// <summary> /// Initializes variables of Configurator program instance on program startup. /// </summary> private void Initialize() { ThisAssembly = Assembly.GetExecutingAssembly(); ExeID = string.Format(CultureInfo.InvariantCulture, "{0}, Version={1}", ThisAssembly.GetName().Name, ThisAssembly.GetName().Version); ExeName = ThisAssembly.ManifestModule.Name; ExeDir = Path.GetDirectoryName(ThisAssembly.Location); _enlistment = new Office14Enlistment(); _asimo = new DatabaseAsimo(_enlistment); if (_enlistment.IsDetected) { _asimo.CheckFolderPath = Path.Combine(_enlistment.CerberusHomeDir, "Checks"); } Database = new CheckConfiguration(); _uiTheme = new StandardTheme(); }