问题列表 - 第38466页

过滤Maven中的源代码

我写了一个小的BeanShell脚本,它取代"__LINE__"了源代码中的实际行号.它在Ant中运行良好.

我正在寻找一种方法来过滤Maven中的源代码,以便我的BeanShell脚本可以生成一个新的源代码目录,然后进行编译.

我知道资源文件过滤.是否有类似的源代码设施?

maven-2 filtering

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

我在哪里可以学习如何编写C代码来加速慢速R函数?

学习如何编写用于R的C代码的最佳资源是什么?我知道R扩展的系统和外语接口部分,但我发现它很难.编写用于R的C代码有哪些好的资源(在线和离线)?

为了澄清,我不想学习如何编写C代码,我想学习如何更好地集成R和C.例如,我如何从C整数向量转换为R整数向量(反之亦然)或者从C标量到R向量?

r rcpp

111
推荐指数
4
解决办法
9050
查看次数

使用NSFetchedResultController进行自定义排序(子类化NSSortDescriptor)

我想使用NSFetchedResultsController和NSSortDescriptor提供自定义排序.

作为通过NSSortDescriptor消息进行自定义排序 - (id)initWithKey:ascending:selector:是不可能的(参见此处),我尝试使用NSSortDescriptor派生类来覆盖compareObject:toObject:消息.

我的问题是compareObject:toObject:并不总是被调用.似乎只有当数据已经在内存中时才会调用它.当第一次从商店检索数据时,存在使用基于数据库的排序而不是compareObject:toObject的某种优化.(见这里).

我的问题是:如何强制NSFetchedResultscontroller使用compareObject:toObject:消息对数据进行排序?(并且它适用于大型数据集)

一种解决方案是使用二进制存储而不是sqlite存储,但我不想这样做.

另一种解决方案是:
-call performFetch通过SQL(compareObject未调用)对数据进行排序 - 对数据进行
修改并将其反转.
-call performFetch再次调用(compareObject被调用)
它在我的情况下工作,但它是一个黑客,我不确定它将始终有效(特别是对于大数据集(大于批量大小)).

更新:您可以使用CoreDataBooks示例进行重现.
在RootViewController.m中,添加这个丑陋的黑客:

- (void)viewWillAppear:(BOOL)animated {
    Book* book = (Book *)[NSEntityDescription insertNewObjectForEntityForName:@"Book" 
                 inManagedObjectContext:[self fetchedResultsController].managedObjectContext];
    [[self fetchedResultsController] performFetch:nil];
    [[self fetchedResultsController].managedObjectContext deleteObject:book];
    [self.tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)

在RootViewController.m中,将排序描述符代码替换为:

MySortDescriptor *myDescriptor = [[MySortDescriptor alloc] init];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:myDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];  
Run Code Online (Sandbox Code Playgroud)

添加MySortDescriptor类:

@implementation MySortDescriptor

-(id)init
{
    if (self = [super initWithKey:@"title" ascending:YES selector:@selector(compare:)])
    {

    }
    return self;
}

- (NSComparisonResult)compareObject:(id)object1 toObject:(id)object2
{
    //set …
Run Code Online (Sandbox Code Playgroud)

iphone core-data nssortdescriptor nsfetchedresultscontroller

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

WCF消息正文在修改后显示<s:Body> ... stream ... </ s:Body>

尝试使用MessageInspector在wcf服务之前通过代理修改消息.但是,在调试消息正文时,不会复制并显示正文

 <s:Body>... stream ...</s:Body>
Run Code Online (Sandbox Code Playgroud)

代码有什么问题?

public class CustomWCFMessageInspector : IClientMessageInspector
{
    public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
        request = ModifyMessage(request);
        return null;
    }

    private Message ModifyMessage(Message oldMessage)
    {
        Message newMessage = null;
        MessageBuffer msgbuf = oldMessage.CreateBufferedCopy(int.MaxValue);

        Message tmpMessage = msgbuf.CreateMessage();
        XmlDictionaryReader xdr = tmpMessage.GetReaderAtBodyContents();

        XDocument xd = ConvertToXDocument(xdr);

        EmitTags(xd);

        var ms = new MemoryStream();
        var xw = XmlWriter.Create(ms);
        xd.Save(xw);

        xw.Flush();
        xw.Close();

        ms.Position = 0;
        XmlReader xr = XmlReader.Create(ms);

        newMessage = Message.CreateMessage(tmpMessage.Version, null, xr);
        newMessage.Headers.CopyHeadersFrom(tmpMessage);
        newMessage.Properties.CopyProperties(tmpMessage.Properties);

        return newMessage;
    } …
Run Code Online (Sandbox Code Playgroud)

wcf

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

Android:点击时如何从Button获取文本?

for(i = 0; i <26; i ++){

        btnAlpha[i] = new Button(this);
        btnAlpha[i].setBackgroundColor(Color.TRANSPARENT);
        btnAlpha[i].setTextColor(Color.GREEN);
        btnAlpha[i].setText(Character.toString ((char)(j+i)));
        btnAlpha[i].setOnClickListener(new View.OnClickListener(){              
            public void onClick(View v){
            //Want to get the text from the current button.
                             btnAlpha[i].getText();
                            //But it gives error that "i" cannot be accessed.

        }});
Run Code Online (Sandbox Code Playgroud)

我得到的错误是"不能引用在不同方法中定义的内部类中的非最终变量".但我需要在正确的时间得到文本.怎么做?还有其他办法吗?请帮忙!

android button android-widget

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

使用ImageMagick(或类似文件)覆盖图像的文件名

我知道ImageMagick的annotate命令可以在图像上叠加一些文本,但它可以使用图像的文件名作为此文本吗?我会这样认为,但似乎无法找到确认这一点的直接文件.

毫无疑问,某些参数组合可以管理这个,或者在脚本中有更好的方法吗?

filenames imagemagick image-processing

15
推荐指数
2
解决办法
8733
查看次数

在BAT脚本中使用FOR/F解析PATH

我需要在.BAT脚本中解析%PATH%列表,但是我对包含空格的路径没有太多好运.

for %%a in (%PATH%) do @echo %%a
Run Code Online (Sandbox Code Playgroud)

上面解析了空格(默认),但我需要解析分号.我正在尝试使用它,但它给我一个错误:

for /f "tokens=* delims=;" %%a in (%PATH%) do @echo %%a
Run Code Online (Sandbox Code Playgroud)

结果是一行:"系统找不到文件C:\ Windows\system32."

我敢肯定我错过了一些非常基本的东西,但任何帮助都会非常感激.TY!

string for-loop path batch-file tokenize

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

检查集合是否为空

data.results在尝试对其执行操作之前,如何检查以下内容是否为空?

$.getJSON(myurl, function(data) {
  // if data.results is not empty 
  // {
  //    console.log(data.results.size);
  // }

});
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

黑莓模拟器屏幕刷新

当我使用黑莓模拟器时,当我与虚拟设备交互时,屏幕似乎没有重新绘制.我必须最小化/恢复屏幕的模拟器应用程序以重新绘制,但它应该自己重新绘制.

这只发生在我的Windows 7机器上,有什么想法吗?

windows-7 blackberry-simulator

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

在XAML中设置XamDataGrid的列宽

我想在XAML中设置XamDataGrid的列宽.没有可用的宽度属性

<ip:Field Label="Name" ........... Width="60"/>
Run Code Online (Sandbox Code Playgroud)

这是我的示例代码.

    <ip:XamDataGrid Name="PatientsList" DataSource="{Binding PatientsList}" SelectedItemsChanged="PatientsListSelectedItemsChanged"
                    XamDataGridBehaviours:XamDataGridBehavior.IsSynchronizedWithCurrentItem="True" GroupByAreaLocation="None">
        <ip:XamDataGrid.FieldLayoutSettings>
            <ip:FieldLayoutSettings AutoGenerateFields="False" SelectionTypeRecord="Extended" MaxSelectedRecords="1"/>
        </ip:XamDataGrid.FieldLayoutSettings>
        <ip:XamDataGrid.FieldSettings>
            <ip:FieldSettings AllowEdit="False" CellClickAction="SelectRecord"/>
        </ip:XamDataGrid.FieldSettings>
        <ip:XamDataGrid.FieldLayouts>
            <ip:FieldLayout>
                <ip:FieldLayout.Fields>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colSex}}" Name="Sex"/>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colPatientId}}" Name="PatientId"/>
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colLastName}}" Name="LastName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colFirstName}}" Name="FirstName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colPatientId}}" Name="FullName" />
                    <ip:Field Label="{Binding Source={x:Static properties:Resources.StudyManager_colDOB}}" Name="DateOfBirth" />
                </ip:FieldLayout.Fields>
            </ip:FieldLayout>
        </ip:XamDataGrid.FieldLayouts>
    </ip:XamDataGrid>
Run Code Online (Sandbox Code Playgroud)

wpf infragistics xamdatagrid

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