问题列表 - 第15255页

如何获取Mac OSX上的窗口标题列表?

我想获取当前正在运行的应用程序的窗口标题列表.

在Windows上我有EnumWndProc和GetWindowText.

在Linux上我有XGetWindowProperty和XFetchName.

什么是Native Mac等价物?

api macos objective-c

17
推荐指数
2
解决办法
8226
查看次数

C#4.0以后的哪些功能必须鼓励从Java切换?

Java是一种流行的语言和平台,拥有庞大的生态系统.是否有C#4.0及其平台应具备的功能,以使您完全切换到C#编程?

c# java language-features programming-languages

6
推荐指数
3
解决办法
916
查看次数

使用javascript substring()创建一个读取更多链接

我正在开发一个经典ASP页面,它从数据库中提取一些内容,并在前100个字符后创建一个Read more链接,如下所示;

<div class="contentdetail"><%=StripHTML(rspropertyresults.Fields.Item("ContentDetails").Value)%></div>

<script type="text/javascript">
    $(function() {

        var cutoff = 200;
        var text = $('div.contentdetail').text();
        var rest = $('div.contentdetail').text().substring(cutoff);
        if (text.length > 200) {
          var period = rest.indexOf('.');
          var space = rest.indexOf(' ');
          cutoff += Math.max(Math.min(period, space), 0);
        }

        var visibleText = $('div.contentdetail').text().substring(0, cutoff);

        $('div.contentdetail')
            .html(visibleText + ('<span>' + rest + '</span>'))
            .append('<a title="Read More" style="font-weight:bold;display: block; cursor: pointer;">Read More&hellip;</a>')
            .click(function() {
                $(this).find('span').toggle();
                $(this).find('a:last').hide();
            });

        $('div.contentdetail span').hide();
    });
</script>
Run Code Online (Sandbox Code Playgroud)

但是,脚本显然只是在100个字符后关闭文本.例如,我希望它继续写文本直到第一个句号或空格.这可能吗?

谢谢.

javascript jquery asp-classic

5
推荐指数
1
解决办法
1万
查看次数

如何使用Perl的Term :: Readline阻止空格被附加到制表符完成的单词?

我正在使用Term :: ReadLine :: Gnu模块的制表符完成支持.每次我做一个标签时,我会在完成的单词后面找到一个空格.

例如:

如果我有一个单词"完整"作为可能的完成.提示后我按Tab键,我得到它:

"完整"

这些是完成单词末尾的空格.我想要的是:

"完成"

有没有办法删除那个空间?

perl readline

2
推荐指数
1
解决办法
264
查看次数

在C#中解析XML

我正在寻找一种方法来阅读以下XML

<Data>
  <MaxCount>10</MaxCount>
  <Points>
    <Point X="10" Y="10"/>
    <Point X="20" Y="10"/>
    <Point X="30" Y="10"/>
    <Point X="40" Y="10"/>
    <Point X="50" Y="10"/>
    <Point X="60" Y="10"/>
  </Points>
</Data>
Run Code Online (Sandbox Code Playgroud)

基本上我想将所有点值读入Point对象数组(我的点对象有2个属性X和Y),MaxCount读成整数.使用C#从XML文件中提取Point值的最佳方法是什么?

谢谢

.net c# xml

1
推荐指数
1
解决办法
486
查看次数

我可以阻止StreamReader在使用时锁定文本文件吗?

StreamReader在读取文本文件时会锁定它.
我可以强制StreamReader以"只读"或"非锁定"模式工作吗?

我的解决方法是将文件复制到临时位置并从那里读取,但我更愿意直接使用StreamReader.任何替代建议?

背景:
我写了一个小应用程序来从日志文件中获取一些统计信息.该文件不断被外部程序更新(每秒几次),可以调用AAXXYY.

查看输出表明我的应用程序可能正在锁定文件并阻止AAXXYY写入.

这就是我正在做的事情

    private void btnGetStats_Click(object sender, EventArgs e)
    {
        int countStarts = 0;
        int countEnds = 0;

        IList<string> sessions = new List<string>();

        using(StreamReader stRead = new StreamReader(openFileDialog1.FileName,Encoding.Unicode))
        {
            while(!stRead.EndOfStream)
            {
                string line = stRead.ReadLine();
                if(line.Contains("Session start"))
                {
                    countStarts++;
                    sessions.Add(line.Substring(line.IndexOf("["), line.LastIndexOf("]") - line.IndexOf("[")));
                }
                if (line.Contains("Session end"))
                {
                    countEnds++;
                    sessions.Remove(line.Substring(line.IndexOf("["), line.LastIndexOf("]") - line.IndexOf("[")));
                }
            }
        }

        txtStarts.Text = countStarts.ToString();
        txtEnds.Text = countEnds.ToString();
        txtDifference.Text = (countStarts - countEnds).ToString();

        listBox1.DataSource = sessions;
    }
Run Code Online (Sandbox Code Playgroud)

.net c# concurrency logging filelock

20
推荐指数
2
解决办法
2万
查看次数

NServiceBus MSMQ发送问题

我无法通过NServiceBus发送消息.我有一个ASP.Net MVC Web应用程序,在Win7 x64上开发,我已经将我的web.config配置为

       <MsmqTransportConfig    InputQueue="worker"    ErrorQueue="error"    NumberOfWorkerThreads="1"    MaxRetries="5"   />

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="PricingInformation.Messages" Endpoint="worker2" />
    </MessageEndpointMappings>   </UnicastBusConfig>
Run Code Online (Sandbox Code Playgroud)

在application_start中,我连接了以下内容:

var bus = NServiceBus.Configure.WithWeb()
            .StructureMapBuilder()
            .XmlSerializer()
            .MsmqTransport()
                .IsTransactional(false)
                .PurgeOnStartup(false)
            .UnicastBus()
                .ImpersonateSender(false)
            .CreateBus()
            .Start();
Run Code Online (Sandbox Code Playgroud)

当我感兴趣的动作发生在应用程序中时我会开火

    public override void HandleEvent(SupplierPricingUpdatedEvent updatedEvent)
    {
        bus.Send(new ModelSupplierDetailsUpdatedMessage() {Id = updatedEvent.Id})
        return;
     }
Run Code Online (Sandbox Code Playgroud)

ModelSupplierDetailsUpdatedMessage是PricingInformation.Messages中的简单类,它使用接口标记IMessage并使用Serializable属性进行修饰.

MSMQ队列是设置的,而不是事务性的,包括NETWORK SERVICE和IIS_IUSRS在内的每个人都有完全控制权(在严重的故障排除措施中)

log4net显示以下内容:

DEBUG NServiceBus.Utils.MsmqUtilities  14 - Checking if queue exists: worker.
Run Code Online (Sandbox Code Playgroud)

DEBUG NServiceBus.Utils.MsmqUtilities 14 - 检查队列是否存在:错误.DEBUG NServiceBus.Unicast.UnicastBus Worker.15 - 在NServiceBus.SagaPersisters.NHibernate.NHibernateMessageModule上调用'HandleBeginMessage'INFO NServiceBus.Unicast.UnicastBus Worker.15 - worker初始化.DEBUG NServiceBus.Unicast.UnicastBus Worker.15 - 在NServiceBus.SagaPersisters.NHibernate.NHibernateMessageModule上调用'HandleEndMessage'调用消息 PriceInformation.Messages.ModelSupplierDetailsUpdatedMessage,PricingInformation.Messages,Version = 1.0.0.0,Culture …

msmq nservicebus

1
推荐指数
1
解决办法
2638
查看次数

WIX ServiceInstall - 将服务设置为在NetworkService帐户下运行

我正在尝试创建一个WIX安装程序来安装我的Windows服务以在NetworkService帐户下运行并在安装过程中获得Insufficient Priviledges错误.

我发现这篇文章有人似乎遇到了同样的问题,但没有提供真正的解决方案:

http://n2.nabble.com/Re-WiX-users-Digest-Vol-40-Issue-129-td3782055.html

我敢肯定以前有人必须实现这一点,并想知道他们是否愿意分享一段代码片段?

windows-services wix wix3 serviceinstall

4
推荐指数
1
解决办法
7711
查看次数

php中的部分字符串比较

我已经在两个字符串中存储了两个ip地址值

a = '116.95.123.111'
b = '116.95.122.112'
Run Code Online (Sandbox Code Playgroud)

我只是想比较ip地址的前两部分,即116.95两个字符串中的一部分,因为它在两个字符串中是相同的,我的比较应该返回true.如何在PHP中进行部分字符串比较?

php string-comparison

0
推荐指数
1
解决办法
809
查看次数

为什么我的脚本在使用mod_perl运行时会占用更多内存?

我正在尝试学习如何配置perl内存.

我有一个非常简单的Perl hello-world脚本,我想知道它在内存中的大小.

我使用GTop实用程序来测量内存(Stas Beckman 在mod_perl中推荐).GTop提供的结果令我感到困惑.

当我从命令行运行脚本时,GTop说:7M.

当我运行它时mod_perl,GTop说:54M.

为什么这么多?!

为什么脚本内存增长如此之多mod_perl?或者我可能以错误的方式测量内存?你如何描述perl脚本内存?

这是脚本及其输出(我手动添加了逗号以轻松读取数字)

  1. 从命令行运行

    > perl simple.pl 
    
    size: 7,282688
    share: 2,027520
    diff: 5,255168
    
  2. 在mod_perl下运行

    size: 54,878208
    share: 4,661248
    diff: 50,216960
    

脚本simple.pl

#!/usr/bin/perl

use strict;
use warnings;
use CGI ();

my $cgi = CGI->new;

print $cgi->header('text/plain');

use GTop;

print "Hello, world!\n";
my $m = GTop->new->proc_mem($$);
print "size: ".$m->size."\n";
print "share: ".$m->share."\n";
my $diff = $m->size - $m->share;
print "diff: $diff\n";
Run Code Online (Sandbox Code Playgroud)

perl memory-management mod-perl

4
推荐指数
1
解决办法
476
查看次数