private void StartLookup()
        {
            DisplayStatusMessage = false;
            StatusMessage        = string.Empty;

            IsLookupRunning = true;

            // Measure the time
            StartTime = DateTime.Now;
            stopwatch.Start();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
            EndTime = null;

            // Reset the latest results
            LookupResult.Clear();

            AddHostToHistory(Host);

            DNSLookupOptions dnsLookupOptions = new DNSLookupOptions();

            if (SettingsManager.Current.DNSLookup_UseCustomDNSServer)
            {
                dnsLookupOptions.UseCustomDNSServer = SettingsManager.Current.DNSLookup_UseCustomDNSServer;
                dnsLookupOptions.CustomDNSServers   = SettingsManager.Current.DNSLookup_CustomDNSServer.Select(x => x.Trim()).ToList();
                dnsLookupOptions.Port = SettingsManager.Current.DNSLookup_Port;
            }

            dnsLookupOptions.AddDNSSuffix = SettingsManager.Current.DNSLookup_AddDNSSuffix;

            if (SettingsManager.Current.DNSLookup_UseCustomDNSSuffix)
            {
                dnsLookupOptions.UseCustomDNSSuffix = true;
                dnsLookupOptions.CustomDNSSuffix    = SettingsManager.Current.DNSLookup_CustomDNSSuffix.TrimStart('.');
            }

            dnsLookupOptions.Class            = SettingsManager.Current.DNSLookup_Class;
            dnsLookupOptions.Type             = Type;
            dnsLookupOptions.Recursion        = SettingsManager.Current.DNSLookup_Recursion;
            dnsLookupOptions.UseResolverCache = SettingsManager.Current.DNSLookup_UseResolverCache;
            dnsLookupOptions.TransportType    = SettingsManager.Current.DNSLookup_TransportType;
            dnsLookupOptions.Attempts         = SettingsManager.Current.DNSLookup_Attempts;
            dnsLookupOptions.Timeout          = SettingsManager.Current.DNSLookup_Timeout;
            dnsLookupOptions.ResolveCNAME     = SettingsManager.Current.DNSLookup_ResolveCNAME;

            DNSLookup DNSLookup = new DNSLookup();

            DNSLookup.RecordReceived += DNSLookup_RecordReceived;
            DNSLookup.LookupError    += DNSLookup_LookupError;
            DNSLookup.LookupComplete += DNSLookup_LookupComplete;;

            DNSLookup.LookupAsync(Host.Split(';').Select(x => x.Trim()).ToList(), dnsLookupOptions);
        }
示例#2
0
        private void StartLookup()
        {
            DisplayStatusMessage = false;
            StatusMessage        = string.Empty;

            IsLookupRunning = true;

            // Measure the time
            StartTime = DateTime.Now;
            stopwatch.Start();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
            EndTime = null;

            // Reset the latest results
            LookupResult.Clear();

            // Change the tab title (not nice, but it works)
            Window window = Application.Current.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive);

            if (window != null)
            {
                foreach (TabablzControl tabablzControl in VisualTreeHelper.FindVisualChildren <TabablzControl>(window))
                {
                    tabablzControl.Items.OfType <DragablzTabItem>().First(x => x.ID == _tabId).Header = Host;
                }
            }

            AddHostToHistory(Host);

            DNSLookupOptions dnsLookupOptions = new DNSLookupOptions();

            if (SettingsManager.Current.DNSLookup_UseCustomDNSServer)
            {
                dnsLookupOptions.UseCustomDNSServer = SettingsManager.Current.DNSLookup_UseCustomDNSServer;
                dnsLookupOptions.CustomDNSServers   = SettingsManager.Current.DNSLookup_CustomDNSServer.Select(x => x.Trim()).ToList();
                dnsLookupOptions.Port = SettingsManager.Current.DNSLookup_Port;
            }

            dnsLookupOptions.AddDNSSuffix = SettingsManager.Current.DNSLookup_AddDNSSuffix;

            if (SettingsManager.Current.DNSLookup_UseCustomDNSSuffix)
            {
                dnsLookupOptions.UseCustomDNSSuffix = true;
                dnsLookupOptions.CustomDNSSuffix    = SettingsManager.Current.DNSLookup_CustomDNSSuffix.TrimStart('.');
            }

            dnsLookupOptions.Class            = SettingsManager.Current.DNSLookup_Class;
            dnsLookupOptions.Type             = Type;
            dnsLookupOptions.Recursion        = SettingsManager.Current.DNSLookup_Recursion;
            dnsLookupOptions.UseResolverCache = SettingsManager.Current.DNSLookup_UseResolverCache;
            dnsLookupOptions.TransportType    = SettingsManager.Current.DNSLookup_TransportType;
            dnsLookupOptions.Attempts         = SettingsManager.Current.DNSLookup_Attempts;
            dnsLookupOptions.Timeout          = SettingsManager.Current.DNSLookup_Timeout;
            dnsLookupOptions.ResolveCNAME     = SettingsManager.Current.DNSLookup_ResolveCNAME;

            DNSLookup DNSLookup = new DNSLookup();

            DNSLookup.RecordReceived += DNSLookup_RecordReceived;
            DNSLookup.LookupError    += DNSLookup_LookupError;
            DNSLookup.LookupComplete += DNSLookup_LookupComplete;;

            DNSLookup.LookupAsync(Host.Split(';').Select(x => x.Trim()).ToList(), dnsLookupOptions);
        }
        private void StartLookup()
        {
            DisplayStatusMessage = false;
            IsLookupRunning      = true;

            // Reset statistic
            DNSServerAndPort = string.Empty;
            Questions        = 0;
            Answers          = 0;
            Authorities      = 0;
            Additionals      = 0;
            MessageSize      = 0;

            // Measure the time
            StartTime = DateTime.Now;
            stopwatch.Start();
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            dispatcherTimer.Start();
            EndTime = null;

            // Reset the latest results
            LookupResult.Clear();

            HostHistory = new List <string>(HistoryListHelper.Modify(HostHistory, Host, SettingsManager.Current.Application_HistoryListEntries));

            DNSLookupOptions DNSLookupOptions = new DNSLookupOptions();

            if (SettingsManager.Current.DNSLookup_UseCustomDNSServer)
            {
                if (!string.IsNullOrEmpty(SettingsManager.Current.DNSLookup_CustomDNSServer))
                {
                    DNSLookupOptions.UseCustomDNSServer = SettingsManager.Current.DNSLookup_UseCustomDNSServer;
                    DNSLookupOptions.CustomDNSServer    = SettingsManager.Current.DNSLookup_CustomDNSServer;
                }
                else
                {
                    StatusMessage        = Application.Current.Resources["String_CustomDNSServerIsEmptyCheckYourSettingsUseWindowsOwnDNSServer"] as string;
                    DisplayStatusMessage = true;
                }
            }

            DNSLookupOptions.Class            = SettingsManager.Current.DNSLookup_Class;
            DNSLookupOptions.Type             = Type;
            DNSLookupOptions.Recursion        = SettingsManager.Current.DNSLookup_Recursion;
            DNSLookupOptions.UseResolverCache = SettingsManager.Current.DNSLookup_UseResolverCache;
            DNSLookupOptions.TransportType    = SettingsManager.Current.DNSLookup_TransportType;
            DNSLookupOptions.Attempts         = SettingsManager.Current.DNSLookup_Attempts;
            DNSLookupOptions.Timeout          = SettingsManager.Current.DNSLookup_Timeout;
            DNSLookupOptions.ResolveCNAME     = SettingsManager.Current.DNSLookup_ResolveCNAME;

            DNSLookup DNSLookup = new DNSLookup();

            DNSLookup.RecordReceived += DNSLookup_RecordReceived;
            DNSLookup.LookupError    += DNSLookup_LookupError;
            DNSLookup.LookupComplete += DNSLookup_LookupComplete;

            string hostnameOrIPAddress = Host;
            string dnsSuffix           = string.Empty;

            // Detect hostname (usually they don't contain ".")
            if (Host.IndexOf(".", StringComparison.OrdinalIgnoreCase) == -1)
            {
                if (SettingsManager.Current.DNSLookup_AddDNSSuffix)
                {
                    if (SettingsManager.Current.DNSLookup_UseCustomDNSSuffix)
                    {
                        dnsSuffix = SettingsManager.Current.DNSLookup_CustomDNSSuffix;
                    }
                    else
                    {
                        dnsSuffix = IPGlobalProperties.GetIPGlobalProperties().DomainName;
                    }
                }
            }

            // Append dns suffix to hostname
            if (!string.IsNullOrEmpty(dnsSuffix))
            {
                hostnameOrIPAddress += string.Format("{0}{1}", dnsSuffix.StartsWith(".") ? "" : ".", dnsSuffix);
            }

            DNSLookup.LookupAsync(hostnameOrIPAddress, DNSLookupOptions);
        }
        protected override void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList <Symbol> basesBeingResolved, LookupOptions options, bool diagnose)
        {
            LookupResult tmp       = LookupResult.GetInstance();
            LookupResult nonViable = LookupResult.GetInstance();

            // Member definitions of different kinds hide each other (field defs hide method defs, etc.).
            // So even if the caller asks only for invocable members find any member first and then reject the result if a non-invokable is found.
            LookupOptions anyMemberLookupOptions = options & ~LookupOptions.MustBeInvocableMember;

            // TODO: optimize lookup (there might be many interactions in the chain)
            for (ICompilation commonSubmission = Compilation.PreviousSubmission; commonSubmission != null; commonSubmission = commonSubmission.PreviousSubmission)
            {
                // TODO (tomat): cross-language binding - for now, skip non-C# submissions
                Compilation submission = commonSubmission as Compilation;
                if (submission == null)
                {
                    continue;
                }

                tmp.Clear();

                Imports imports = GetImports(submission);
                imports.LookupSymbolInAliases(this, tmp, name, arity, basesBeingResolved, anyMemberLookupOptions, diagnose);

                // If a viable using alias and a matching member are both defined in the submission an error is reported elsewhere.
                // Ignore the member in such case.
                if (!tmp.IsMultiViable && (options & LookupOptions.NamespaceAliasesOnly) == 0)
                {
                    this.LookupMembers(tmp, submission.ScriptClass, name, arity, basesBeingResolved, anyMemberLookupOptions, diagnose);
                }

                // found a non-method in the current submission:
                if (tmp.Symbols.Count > 0 && tmp.Symbols.First().Kind != SymbolKind.Method)
                {
                    if (!tmp.IsMultiViable)
                    {
                        // skip non-viable members, but remember them in case no viable members are found in previous submissions:
                        nonViable.MergePrioritized(tmp);
                        continue;
                    }

                    if (result.Symbols.Count == 0)
                    {
                        result.MergeEqual(tmp);
                    }

                    break;
                }

                // merge overloads:
                Debug.Assert(result.Symbols.Count == 0 || result.Symbols.All(s => s.Kind == SymbolKind.Method));
                result.MergeEqual(tmp);
            }

            // Set a proper error if we found a symbol that is not invocable but were asked for invocable only.
            // Only a single non-method can be present in the result; methods are always invocable.
            if ((options & LookupOptions.MustBeInvocableMember) != 0 && result.Symbols.Count == 1)
            {
                Symbol      symbol = result.Symbols.First();
                AliasSymbol alias  = symbol as AliasSymbol;
                if (alias != null)
                {
                    symbol = alias.GetAliasTarget(basesBeingResolved);
                }

                if (IsNonInvocableMember(symbol))
                {
                    result.SetFrom(LookupResult.NotInvocable(symbol, result.Symbols.First(), diagnose));
                }
            }
            else if (result.Symbols.Count == 0)
            {
                result.SetFrom(nonViable);
            }

            tmp.Free();
            nonViable.Free();
        }