public HighWaterMarkQueryService(ILogger logger) { _logger = logger; _configFile = new FileInfo(Path.Combine(WellKnown.GetDataDirectory(), "queries.json")); if (!_configFile.Exists) { var example = new HighWaterMarkQuery() { ConnectionString = "Data Source=;Initial Catalog=;User=;Password=;", Query = "SELECT * FROM Table WHERE ID > @0", EveryNSeconds = 60, HighWaterMarkType = typeof(int), HighWaterMark = "0", HighWaterMarkColumn = "ID", ApiUserName = "******", ApiPassword = "******" }; var list = new List <HighWaterMarkQuery>() { example }; File.WriteAllText(_configFile.FullName, JsonConvert.SerializeObject(list, Formatting.Indented)); _logger.Warning($"No query config found writing example to {_configFile.FullName}."); return; } var queryConfigContents = File.ReadAllText(_configFile.FullName); _configs = JsonConvert.DeserializeObject <List <HighWaterMarkQuery> >(queryConfigContents); }
public ActionResult <WellKnown> GetConfiguration() { var wellKnown = new WellKnown { Slots = _configuration.Slots, Companies = _configuration.Companies, Garages = _configuration.Garages, ReservationSettings = _configuration.Reservation, }; return(Ok(wellKnown)); }
public static GitConfigFile Load(string path = null) { if (path != null && !path.IsDir()) { if (!File.Exists(path)) { throw new Exception($"Expected file to exist at '{path}'."); } return(new User(path)); } var workingDir = path; if (workingDir == null) { workingDir = Environment.CurrentDirectory; } workingDir = workingDir.ToDir(); return(WellKnown.Load(GitNamedConfigFile.Local, workingDir)); }
public DeserializerGenerateContext(SemanticModel model, INamedTypeSymbol serializableType, WellKnown wellKnown) { this.model = model; this.serializableType = serializableType; this.wellKnown = wellKnown; }
public void Execute(GeneratorExecutionContext context) { if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.DebugSerializerGeneration", out var debug) && bool.TryParse(debug, out var bDebug) && bDebug) { Debugger.Launch(); } this.SerializableTypeAttribute = context.Compilation.GetTypeSymbol <SerializableTypeAttribute>(); if (context.SyntaxReceiver is TypeDiscoverer typeDiscoverer) { var wellKnown = new WellKnown(context.Compilation, typeDiscoverer); foreach (var decl in typeDiscoverer.Types) { if (decl.SyntaxTree != null) { var model = context.Compilation.GetSemanticModel(decl.SyntaxTree, ignoreAccessibility: true); if (IsSerializableType(model, decl, out var declType) == false) { continue; } var layoutInfo = LayoutInfo.Create(context.Compilation, declType); var fullName = GetFullTypeName(decl); // Duplicate declarations due to partial class. All member should be generated though, // since we're using the semantic model to get the members? if (generatedFilenames.Contains(fullName)) { continue; } generatedFilenames.Add(fullName); var cls = GetSerializationClass(fullName); var deserCtx = new DeserializerGenerateContext(model, declType, wellKnown); deserCtx.Generate(ref cls, layoutInfo); // TODO: Serialize generation var ns = NamespaceDeclaration(ParseName(context.Compilation.AssemblyName + ".__GeneratedSerializers")) .AddUsings( UsingDirective(ParseName("System")), UsingDirective(ParseName("System.IO")), UsingDirective(ParseName(typeof(BlamSerializer).Namespace)), UsingDirective(ParseName(typeof(SerializationClassAttribute).Namespace)), UsingDirective(ParseName(typeof(SpanByteExtensions).Namespace)), UsingDirective(ParseName(declType.ContainingNamespace.ToDisplayString()))) .AddMembers(cls); var source = ns.NormalizeWhitespace().ToString(); var fileName = fullName + ".GeneratedSerializer.cs"; if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.GenerateSerializersInto", out var p)) { try { if (Directory.Exists(p) == false) { Directory.CreateDirectory(p); } File.WriteAllText(Path.Combine(p, fileName), source); } catch (Exception e) { Console.WriteLine(e.Message); } } context.AddSource(fileName, SourceText.From(source, Encoding.UTF8)); } } } }
public static GitConfigFile LoadGlobal() => WellKnown.Load(GitNamedConfigFile.Global);
public static GitConfigFile LoadSystem() => WellKnown.Load(GitNamedConfigFile.System);