public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag { ITextDocument textDocument; buffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <ITagger <T> > sc = delegate { return(RuntimeLoader.CreateErrorTagger <T>(textDocument.FilePath, serviceProvider, buffer)); }; return(buffer.Properties.GetOrCreateSingletonProperty(sc)); }
public IMouseProcessor GetAssociatedProcessor(IWpfTextView wpfTextView) { ITextDocument textDocument; wpfTextView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <IMouseProcessor> sc = delegate { return(RuntimeLoader.GetObject <IMouseProcessor>(textDocument.FilePath, t => t.Name == "MouseProcessor", serviceProvider, wpfTextView)); }; return(wpfTextView.Properties.GetOrCreateSingletonProperty(sc)); }
public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer) { ITextDocument textDocument; textBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <IQuickInfoSource> sc = delegate { return(RuntimeLoader.GetObject <IQuickInfoSource>(textDocument.FilePath, t => t.Name == "QuickInfoSource", serviceProvider, textBuffer)); }; return(textBuffer.Properties.GetOrCreateSingletonProperty(sc)); }
public ITagger <T> CreateTagger <T>(ITextBuffer buffer) where T : ITag { ITextDocument textDocument; buffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <ITagger <T> > sc = delegate { return(RuntimeLoader.GetObject <ITagger <T> >(textDocument.FilePath, t => t.Name == "IntraTextAdornmentTagger", _serviceProvider, buffer)); }; return(buffer.Properties.GetOrCreateSingletonProperty(sc)); }
public IIntellisenseController TryCreateIntellisenseController(ITextView textView, IList <ITextBuffer> subjectBuffers) { ITextDocument textDocument; textView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <IIntellisenseController> sc = delegate { return(RuntimeLoader.GetObject <IIntellisenseController>(textDocument.FilePath, t => t.Name == "IntellisenseController", _serviceProvider, textView, subjectBuffers)); }; return(textView.Properties.GetOrCreateSingletonProperty(sc)); }
public void TextViewCreated(IWpfTextView textView) { ITextDocument textDocument; textView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); Func <object> sc = delegate { return(RuntimeLoader.GetObject <object>(textDocument.FilePath, t => t.Name == "WpfTextViewHandler", serviceProvider, textView)); }; textView.Properties.GetOrCreateSingletonProperty(sc); }
// This method gets called by the runtime. Use this method to add services to the container public void ConfigureServices(IServiceCollection services) { services.Configure <FormOptions>(x => { x.ValueLengthLimit = int.MaxValue; x.ValueCountLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue; x.MemoryBufferThreshold = int.MaxValue; }); var settings = new JsonSerializerSettings { ContractResolver = new SignalRContractResolver() }; var serializer = JsonSerializer.Create(settings); GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); var moduleMappings = services.BuildServiceProvider().GetService <IOptions <ApplicationSettings> >().Value.Modules; IConfigurationRoot config; services.AddModules(moduleMappings, (configBuilder, env) => { configBuilder .SetBasePath(env.ContentRootPath) .AddJsonFile("./bin/appsettings.json", true) .AddJsonFile($"./bin/appsettings.{env.EnvironmentName}.json", true) .AddJsonFile("appsettings.json", true, true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true); #if DEBUG configBuilder.AddJsonFile("appsettings.Development.json", true); #endif }, out config); Configuration = config; services.Configure <ApplicationSettings>(Configuration.GetSection("Settings")); services .AddMvc(options => { options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build())); }) .AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; }); services.AddSingleton <ILogging, Logging.Logging>(); services.AddScoped <ISettingsSource, FileSettingsSource>(); services.AddScoped <IPortalSettingsService, PortalSettingsService>(); services.AddScoped <ITokenService, TokenService>(); var runtimeLoader = RuntimeLoader.Initialize(services.BuildServiceProvider().GetService <IOptions <ApplicationSettings> >()); services.AddSingleton <IRuntimeLoader, RuntimeLoader>(_ => runtimeLoader); services.Configure <PortalSettings>(Configuration.Bind); services.AddOptions(); }
public IClassifier GetClassifier(ITextBuffer buffer) { ITextDocument textDocument; buffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); IClassifier ammyClassifier; if (buffer.Properties.TryGetProperty(TextBufferProperties.AmmyClassifier, out ammyClassifier)) { return(ammyClassifier); } ammyClassifier = RuntimeLoader.GetClassifier(textDocument.FilePath, serviceProvider, buffer, (ITextDocument)textDocument, ClassificationRegistry, _classificationFormatMapService); buffer.Properties.AddProperty(TextBufferProperties.AmmyClassifier, ammyClassifier); return(ammyClassifier); }
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) { ICompletionSource completionSource; textBuffer.Properties.TryGetProperty(typeof(ICompletionSource), out completionSource); if (completionSource != null) { return(completionSource); } ITextDocument textDocument; textBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); completionSource = RuntimeLoader.CreateCompletionSource(textDocument.FilePath, _serviceProvider, textBuffer); textBuffer.Properties.AddProperty(typeof(ICompletionSource), completionSource); return(completionSource); }
public void VsTextViewCreated(IVsTextView textViewAdapter) { ITextView textView = _adapterService.GetWpfTextView(textViewAdapter); if (textView == null) { return; } ITextDocument textDocument; textView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument); object commandHandler; if (!textView.Properties.TryGetProperty("CompletionCommandHandler", out commandHandler)) { var handler = RuntimeLoader.CreateCommandHandler(textDocument.FilePath, _serviceProvider, textViewAdapter, textView, _navigatorService, _signatureHelpBroker, _completionBroker); textView.Properties.AddProperty("CompletionCommandHandler", handler); } }
static void Main(string[] args) { Console.WriteLine( "Units of Measurement for C# applications. Copyright (©) Marek Anioła.\n" + "This program is provided to you under the terms of the license\n" + "as published at https://github.com/mangh/unitsofmeasurement." ); Console.WriteLine(); Console.WriteLine("Before loading supplementary units:"); Console.WriteLine("=================================="); TestSupplementaryUnits("converting \"{0}\" (runtime unit):", "1 nmi"); TestSupplementaryScales("converting \"{0}\" (runtime scale):", "-80 deg.Re"); TestSupplementaryUnits("converting \"{0}\" (compile-time unit):", "1 km"); TestSupplementaryScales("converting \"{0}\" (compile-time scale):", "100 deg.C"); RuntimeLoader ldr = new RuntimeLoader(); if (!ldr.LoadFromFile(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "LateUnits.txt"))) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nInvalid definitions:"); foreach (var e in ldr.Errors) { Console.WriteLine(e); } Console.ResetColor(); return; } Console.WriteLine(); Console.WriteLine("After loading supplementary units:"); Console.WriteLine("================================="); TestSupplementaryUnits("converting \"{0}\" (runtime unit):", "1 nmi"); TestSupplementaryScales("converting \"{0}\" (runtime scale):", "-80 deg.Re"); TestSupplementaryUnits("converting \"{0}\" (compile-time unit):", "1 km"); TestSupplementaryScales("converting \"{0}\" (compile-time scale):", "100 deg.C"); }
public void Types_Should_Be_Loaded_From_The_Assemblies_At_Given_Directory() { // Arrange var options = Substitute.For <IOptions <ApplicationSettings> >(); options.Value.Returns(new ApplicationSettings() { Runtime = Directory.GetCurrentDirectory() }); // Act var loader = RuntimeLoader.Initialize(options); // Assert Assert.NotEmpty(loader.Receivers); Assert.NotEmpty(loader.Transformers); Assert.NotEmpty(loader.Steps); Assert.NotEmpty(loader.AttachmentUploaders); Assert.NotEmpty(loader.CertificateRepositories); Assert.NotEmpty(loader.DeliverSenders); Assert.NotEmpty(loader.DynamicDiscoveryProfiles); Assert.NotEmpty(loader.NotifySenders); Assert.NotEmpty(loader.MetaData); }