private static void FetchSyntax(UriParser syntax, string lwrCaseSchemeName, int defaultPort) { if (syntax.SchemeName.Length != 0) { throw new InvalidOperationException(SR.Format(SR.net_uri_NeedFreshParser, syntax.SchemeName)); } lock (s_table) { syntax._flags &= ~UriSyntaxFlags.V1_UnknownUri; UriParser oldSyntax = null; s_table.TryGetValue(lwrCaseSchemeName, out oldSyntax); if (oldSyntax != null) { throw new InvalidOperationException(SR.Format(SR.net_uri_AlreadyRegistered, oldSyntax.SchemeName)); } s_tempTable.TryGetValue(syntax.SchemeName, out oldSyntax); if (oldSyntax != null) { // optimization on schemeName, will try to keep the first reference lwrCaseSchemeName = oldSyntax._scheme; s_tempTable.Remove(lwrCaseSchemeName); } syntax.OnRegister(lwrCaseSchemeName, defaultPort); syntax._scheme = lwrCaseSchemeName; syntax.CheckSetIsSimpleFlag(); syntax._port = defaultPort; s_table[syntax.SchemeName] = syntax; } }
private static void FetchSyntax(UriParser syntax, string lwrCaseSchemeName, int defaultPort) { if (syntax.SchemeName.Length != 0) { throw new InvalidOperationException(SR.GetString("net_uri_NeedFreshParser", new object[] { syntax.SchemeName })); } lock (m_Table) { syntax.m_Flags &= ~UriSyntaxFlags.V1_UnknownUri; UriParser parser = (UriParser)m_Table[lwrCaseSchemeName]; if (parser != null) { throw new InvalidOperationException(SR.GetString("net_uri_AlreadyRegistered", new object[] { parser.SchemeName })); } parser = (UriParser)m_TempTable[syntax.SchemeName]; if (parser != null) { lwrCaseSchemeName = parser.m_Scheme; m_TempTable.Remove(lwrCaseSchemeName); } syntax.OnRegister(lwrCaseSchemeName, defaultPort); syntax.m_Scheme = lwrCaseSchemeName; syntax.CheckSetIsSimpleFlag(); syntax.m_Port = defaultPort; m_Table[syntax.SchemeName] = syntax; } }
// private static void FetchSyntax(UriParser syntax, string lwrCaseSchemeName, int defaultPort) { if (syntax.SchemeName.Length != 0) throw new InvalidOperationException(SR.GetString(SR.net_uri_NeedFreshParser, syntax.SchemeName)); lock (m_Table) { syntax.m_Flags &= ~UriSyntaxFlags.V1_UnknownUri; UriParser oldSyntax = null; m_Table.TryGetValue(lwrCaseSchemeName, out oldSyntax); if (oldSyntax != null) throw new InvalidOperationException(SR.GetString(SR.net_uri_AlreadyRegistered, oldSyntax.SchemeName)); m_TempTable.TryGetValue(syntax.SchemeName, out oldSyntax); if (oldSyntax != null) { // optimization on schemeName, will try to keep the first reference lwrCaseSchemeName = oldSyntax.m_Scheme; m_TempTable.Remove(lwrCaseSchemeName); } syntax.OnRegister(lwrCaseSchemeName, defaultPort); syntax.m_Scheme = lwrCaseSchemeName; syntax.CheckSetIsSimpleFlag(); syntax.m_Port = defaultPort; m_Table[syntax.SchemeName] = syntax; } }
private static void FetchSyntax(UriParser syntax, string lwrCaseSchemeName, int defaultPort) { if (syntax.SchemeName.Length != 0) { throw new InvalidOperationException(SR.GetString("net_uri_NeedFreshParser", new object[] { syntax.SchemeName })); } lock (m_Table) { syntax.m_Flags &= ~UriSyntaxFlags.V1_UnknownUri; UriParser parser = (UriParser) m_Table[lwrCaseSchemeName]; if (parser != null) { throw new InvalidOperationException(SR.GetString("net_uri_AlreadyRegistered", new object[] { parser.SchemeName })); } parser = (UriParser) m_TempTable[syntax.SchemeName]; if (parser != null) { lwrCaseSchemeName = parser.m_Scheme; m_TempTable.Remove(lwrCaseSchemeName); } syntax.OnRegister(lwrCaseSchemeName, defaultPort); syntax.m_Scheme = lwrCaseSchemeName; syntax.CheckSetIsSimpleFlag(); syntax.m_Port = defaultPort; m_Table[syntax.SchemeName] = syntax; } }