예제 #1
0
        public override void EnterScalarParameterValue(TnsNamesParser.ScalarParameterValueContext context)
        {
            var    parameterContext = (TnsNamesParser.ParameterContext)context.Parent;
            string keyword          = parameterContext.keyword().GetText();
            var    text             = context.scalar.content.Text;

            bool isRootLevel        = parameterContext.Parent is TnsNamesParser.Configuration_fileContext;
            bool isConnectDataLevel = _levelStack.Any() && string.Equals("CONNECT_DATA", _levelStack.First());
            bool isAddressLevel     = _levelStack.Any() && string.Equals("ADDRESS", _levelStack.First());

            if (isAddressLevel && string.Equals(keyword, "HOST", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.Host = text.ToUpperInvariant();
            }
            else if (isAddressLevel && string.Equals(keyword, "KEY", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.Key = text.ToUpperInvariant();
            }
            else if (isAddressLevel && string.Equals(keyword, "PIPE", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.Pipe = text.ToUpperInvariant();
            }
            else if (isAddressLevel && string.Equals(keyword, "PORT", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.PortStr = text;
            }
            else if (isAddressLevel && string.Equals(keyword, "PROTOCOL", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.Protocol = text.ToUpperInvariant();
            }
            else if (isAddressLevel && string.Equals(keyword, "SERVER", StringComparison.OrdinalIgnoreCase))
            {
                _currentDatabaseAddress.Server = text.ToUpperInvariant();
            }
            else if (isConnectDataLevel && string.Equals(keyword, "SERVICE_NAME", StringComparison.OrdinalIgnoreCase))
            {
                _currentTnsNameServiceName = text.ToUpperInvariant();
            }
            else if (isConnectDataLevel && string.Equals(keyword, "SID", StringComparison.OrdinalIgnoreCase))
            {
                _currentTnsNameSid = text.ToUpperInvariant();
            }
            else if (isRootLevel && string.Equals(keyword, "IFILE", StringComparison.OrdinalIgnoreCase))
            {
                string filepath = context.scalar.content.Text;

                // Fix UNC path (Oracle thingie: the two starting slashes are forwards in TNS names files - UNC uses backslash)
                if (filepath.StartsWith("//"))
                {
                    filepath = @"\\" + (filepath.Length > 2 ? filepath.Substring(2) : string.Empty);
                }
                IfileEntries.Add(filepath);
            }

            base.EnterScalarParameterValue(context);
        }
예제 #2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>scalarParameterValue</c>
 /// labeled alternative in <see cref="TnsNamesParser.parameterValue"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitScalarParameterValue([NotNull] TnsNamesParser.ScalarParameterValueContext context)
 {
 }