public void Add( BitmapPage page, string fontname, int fontsize ) { var key = new EntryKey() { Name = fontname, Size = fontsize }; if ( !entries.ContainsKey(key) ) entries.Add( key, new Entry() { FontName = fontname, FontSize = fontsize } ); var entry = entries[key]; entry.BitmapPages.Add( page ); }
internal void Initialize(string patchesFolder, Stream indexStream) { _patchesRootFolder = patchesFolder; using (var reader = new StreamReader(indexStream)) { var lineNumber = 0; for (var line = reader.ReadLine(); line != null; line = reader.ReadLine()) { lineNumber += 1; if (line.StartsWith("#") || string.IsNullOrWhiteSpace(line)) { continue; } var parts = line.Split(new[] { '=' }, 2); if (parts.Length != 2) { Logger.TraceInformation("[{0}]. Line {1}: malformed servicing file", GetType().Name, lineNumber); continue; } parts[0] = parts[0].Trim(); parts[1] = parts[1].Trim(); if (parts[0].Length == 0 || parts[1].Length == 0) { Logger.TraceInformation("[{0}]. Line {1}: malformed servicing file", GetType().Name, lineNumber); continue; } var fields = parts[0].Split(new[] { '|' }); if (String.Equals(fields[0], "nupkg", StringComparison.Ordinal)) { if (fields.Length != 4) { Logger.TraceInformation("[{0}]. Line {1}: malformed servicing key", GetType().Name, lineNumber); continue; } SemanticVersion version; if (!SemanticVersion.TryParseStrict(fields[2], out version)) { Logger.TraceInformation("[{0}]. Line {1}: malformed servicing version ", GetType().Name, lineNumber); continue; } var key = new EntryKey(fields[1], version); Entry entry; if (!_entries.TryGetValue(key, out entry)) { Logger.TraceInformation("[{0}]: Adding entry for {1} {2}", GetType().Name, key.Id, key.Version); entry = new Entry(); _entries.Add(key, entry); } entry.Mappings.Add(new EntryMapping(fields[3], parts[1])); } } } }
//TODO: process_* should return false if they encounter error so execution does not continue async void process_inserts() { if (!await db.OpenConnection()) { MessageBox.Show("Failed to open a connection to the database!", "SQL Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int total = inserts.Count; int progress = 0; progressBar.Maximum = total; for (int i = total - 1; i >= 0; i--) { EntryKey key = inserts[i]; if (key != null) { MarketEntry entry = entries.Find(m => m.SortID == key.SortID && m.MarketName == key.MarketName); if (entry != null) { string cmd = (!useArena) ? marketInsert[0] : marketInsert[1]; db.NewCommand(cmd); db.AddParameter("@sort_id", entry.SortID, SqlDbType.Int); db.AddParameter("@name", entry.MarketName, SqlDbType.VarChar); db.AddParameter("@code", entry.Code, SqlDbType.Int); db.AddParameter("@price_ratio", entry.PriceRatio, SqlDbType.Decimal); db.AddParameter("@huntaholic_ratio", entry.HuntaholicRatio, SqlDbType.Decimal); if (useArena) { db.AddParameter("@arena_ratio", entry.ArenaRatio, SqlDbType.Decimal); } await db.Execute(); cmd = (!useArena) ? itemUpdate[0] : itemUpdate[1]; db.NewCommand(cmd); db.AddParameter("@price", entry.Price, SqlDbType.Int); db.AddParameter("@huntaholic_point", entry.HuntaholicPoint, SqlDbType.Int); db.AddParameter("@id", entry.Code, SqlDbType.Int); if (useArena) { db.AddParameter("@arena_point", entry.ArenaPoint, SqlDbType.Int); } await db.Execute(); } } inserts.RemoveAt(i); progress = total - i; if ((i * 100 / total) != ((i - 1) * 100 / total)) { progressBar.Value = progress; } } db.CloseConnection(); reset_progress(); }
public bool Equals(EntryKey other) => other.HashLeft == HashLeft && other.HashRightAndRealm == HashRightAndRealm;
private CallInvoker CreateInvoker(EntryKey key) { var(name, type) = (key.Name, key.Type); var scope = _scopeFactory.CreateScope(); var services = scope.ServiceProvider; try { var httpClientFactoryOptions = _httpClientFactoryOptionsMonitor.Get(name); if (httpClientFactoryOptions.HttpClientActions.Count > 0) { throw new InvalidOperationException($"The ConfigureHttpClient method is not supported when creating gRPC clients. Unable to create client with name '{name}'."); } var clientFactoryOptions = _grpcClientFactoryOptionsMonitor.Get(name); var httpHandler = _messageHandlerFactory.CreateHandler(name); if (httpHandler == null) { throw new ArgumentNullException(nameof(httpHandler)); } var channelOptions = new GrpcChannelOptions(); channelOptions.HttpHandler = httpHandler; channelOptions.LoggerFactory = _loggerFactory; channelOptions.ServiceProvider = services; if (clientFactoryOptions.ChannelOptionsActions.Count > 0) { foreach (var applyOptions in clientFactoryOptions.ChannelOptionsActions) { applyOptions(channelOptions); } } var address = clientFactoryOptions.Address; if (address == null) { throw new InvalidOperationException($@"Could not resolve the address for gRPC client '{name}'. Set an address when registering the client: services.AddGrpcClient<{type.Name}>(o => o.Address = new Uri(""https://*****:*****@"client.AddCallCredentials((context, metadata) => {}).ConfigureChannel(o => o.UnsafeUseInsecureChannelCallCredentials = true)"); } var channel = GrpcChannel.ForAddress(address, channelOptions); var httpClientCallInvoker = channel.CreateCallInvoker(); var resolvedCallInvoker = GrpcClientFactoryOptions.BuildInterceptors( httpClientCallInvoker, services, clientFactoryOptions, InterceptorScope.Channel); return(resolvedCallInvoker); } catch { // If something fails while creating the handler, dispose the services. scope?.Dispose(); throw; } }
protected void Add(StreamType type, int index, EntryKey entry, string value) { Add(type, index, entry, value, null); }
protected void Add(StreamType type, int index, EntryKey entry, Func <string> value, string unit) { try { Add(type, index, entry, value(), unit); } catch (Exception ex) { Debug.Print(entry.ToString()); } }
public StreamTypeEntryPair(StreamType type, int index, EntryKey entry) { Type = type; Index = index; Entry = entry; }
protected void Add(EntryKey entry, Func <string> value, string unit) { Add(StreamType.General, 0, entry, value, unit); }
public void Initialize(string folderPath) { _folderPath = folderPath; var indexFilePath = Path.Combine(folderPath, "index.txt"); if (!File.Exists(indexFilePath)) { Trace.TraceInformation("[{0}]: Servicing index not found at {1}", GetType().Name, indexFilePath); return; } else { Trace.TraceInformation("[{0}]: Servicing index loaded from {1}", GetType().Name, indexFilePath); } using (var stream = new FileStream(indexFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete)) { using (var reader = new StreamReader(stream)) { var lineNumber = 0; for (var line = reader.ReadLine(); line != null; line = reader.ReadLine()) { lineNumber += 1; if (line.StartsWith("#") || string.IsNullOrWhiteSpace(line)) { continue; } var parts = line.Split(new[] { '=' }, 2); if (parts.Length != 2) { Trace.TraceInformation("[{0}]: {1}({2}): malformed servicing file", GetType().Name, indexFilePath, lineNumber); continue; } parts[0] = parts[0].Trim(); parts[1] = parts[1].Trim(); if (parts[0].Length == 0 || parts[1].Length == 0) { Trace.TraceInformation("[{0}]: {1}({2}): malformed servicing file", GetType().Name, indexFilePath, lineNumber); continue; } var fields = parts[0].Split(new[] { '|' }); if (String.Equals(fields[0], "nupkg", StringComparison.Ordinal)) { if (fields.Length != 4) { Trace.TraceInformation("[{0}]: {1}({2}): malformed servicing key", GetType().Name, indexFilePath, lineNumber); continue; } SemanticVersion version; if (!SemanticVersion.TryParseStrict(fields[2], out version)) { Trace.TraceInformation("[{0}]: {1}({2}): malformed servicing version ", GetType().Name, indexFilePath, lineNumber); continue; } var key = new EntryKey(fields[1], version); Entry entry; if (!_entries.TryGetValue(key, out entry)) { Trace.TraceInformation("[{0}]: Adding entry for {1} {2}", GetType().Name, key.Id, key.Version); entry = new Entry(); _entries.Add(key, entry); } entry.Mappings.Add(new EntryMapping(fields[3], parts[1])); } } } } }
public virtual InfoEntry this[StreamType type, int index, EntryKey key] { get { InfoEntry entry; return(infos.TryGetValue(new StreamTypeEntryPair(type, index, key), out entry) ? entry : null); } }
public void SetValue <T>(EntryKey key, T value) { var readingValue = this.Data.GetValue(key); readingValue.Set(value); }
public Descriptor(object instance, EntryKey k) { Debug.Assert(instance != null); Key = k; Settings = instance; }
/// <summary> /// Add the parameters section for the provided <paramref name="mathod"/>. /// </summary> /// <param name="method">The method to add the parameters for.</param> /// <param name="parsedBlocks">The parsed comments.</param> protected void AddParametersForMethod(MethodDef method, List <Block> parsedBlocks) { // Add the parameter information if available List <Param> parameterComments = Parser.ParseElement <Param>(parsedBlocks); if (method.Parameters != null && method.Parameters.Count > 0) { ParameterList parameters = null; foreach (ParamDef methodParam in method.Parameters) { if (methodParam.Sequence != 0) { // Find the parameter comments Param paramComment = null; foreach (Param current in parameterComments) { if (current.Name == methodParam.Name) { paramComment = current; break; } } TypeRef typeRef = method.ResolveParameter(methodParam.Sequence); EntryKey typeKey = null; string typeName = typeRef.Name; if (parameters == null) { parameters = new ParameterList(); } if (typeRef != null) { if (typeRef is TypeDef) { typeKey = new EntryKey(typeRef.GetGloballyUniqueId()); } else { CRefPath path = new CRefPath(typeRef); Documentation.Entry found = LiveDocumentorFile.Singleton.LiveDocument.Find(path); if (found != null) { typeKey = new EntryKey(found.Key); typeName = found.Name; } else { typeKey = null; } } typeName = typeRef.GetDisplayName(false); } List <Block> paramDescription = new List <Block>(); if (paramComment != null && paramComment.Description != null) { paramDescription = paramComment.Description; } parameters.Add(methodParam.Name, typeName, method.Assembly, typeKey, paramDescription); } } if (parameters != null) { this.Blocks.Add(parameters); } } }
protected override void Add(StreamType type, int index, EntryKey entry, string value, string unit) { if(value == null) return; bool isValid = true; foreach(var character in value) { isValid = SafeXmlWriter.IsLegalXmlChar(character); if(!isValid) break; } if(isValid) base.Add(type, index, entry, value, unit); }