问题列表 - 第30406页

在PDF中插入/更新XMP?

如何使用java 将一些XMP元数据插入/更新为PDF文件?

java pdf xmp metadata

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

Linq Entity Framework通用过滤方法

我有一些方法对我的实体的数据执行标准过滤(使用Entity Framework v4).

示例#1:

protected IQueryable<Database.Product> GetActiveProducts( ObjectSet<Database.Product> products ) {

    var allowedStates = new string[] { "Active" , "Pending" };

    return (
        from product in products
        where allowedStates.Contains( product.State )
            && product.Hidden == "No"
        select product
    );

}
Run Code Online (Sandbox Code Playgroud)

示例#2:

protected IQueryable<Database.Customer> GetActiveProducts( ObjectSet<Database.Customer> customers ) {

    var allowedStates = new string[] { "Active" , "Pending" };

    return (
        from customer in customers
        where allowedStates.Contains( customer.State )
            && customer.Hidden == "No"
        select customer
    );

}
Run Code Online (Sandbox Code Playgroud)

如您所见,这些方法与它们运行的​​实体类型完全相同.我有超过10种这样的方法,一种用于我系统中的每种类型的实体.

我试图理解我如何能够在任何实体类型中传递1个单一方法,并且如果存在2个字段/属性,则让它执行where子句.

我不在数据库中使用继承,因此就系统而言,每个实体类型都有"隐藏"和"状态"字段是巧合.

我的谷歌搜索告诉我它与使用Expression.Call()构建代码有关,但我的头现在正在旋转!

c# linq-to-entities entity-framework

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

C++:自动const?

当我编译这段代码时:

class DecoratedString
{
private:
    std::string m_String;
public:
     // ... constructs, destructors, etc
     std::string& ToString() const
     {
         return m_String;
     }
}
Run Code Online (Sandbox Code Playgroud)

我从g ++中得到以下错误:invalid initialization of reference of type 'std::string&" from expression of type 'const std::string'.

为什么m_String被视为const?编译器不应该只是在这里创建引用吗?

编辑:

此外,我应该怎么做才能使这个函数作为一个字符串的转换,在大多数情况下将起作用? 我做了函数const,因为它不修改内部字符串...也许我只需要让它返回一个副本...

编辑:好的......让它返回一份副本.

c++ const-correctness

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

如何在C中以编程方式查找闰年

我使用C制作了一个程序来查找输入的年份是否是闰年.但遗憾的是它运作不佳.它说一年是飞跃,前一年不是飞跃.

#include<stdio.h>
#include<conio.h>
int yearr(int year);
void main(void)
{
    int year;
    printf("Enter a year:");
    scanf("%d",&year);
    if(!yearr(year))
    {
        printf("It is a leap year.");
    }
    else
    {
    printf("It is not a leap year");
    }


getch();
}
int yearr(int year)
{
    if((year%4==0)&&(year/4!=0))
    return 1;
    else
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

阅读评论后,我编辑了我的编码:

#include<stdio.h>
#include<conio.h>
int yearr(int year);
void main(void)
{
    int year;
    printf("Enter a year:");
    scanf("%d",&year);
    if(!yearr(year))
    {
        printf("It is a leap year.");
    }
    else
    {
    printf("It is not a leap year");
    }


getch();
}
int …
Run Code Online (Sandbox Code Playgroud)

c leap-year

8
推荐指数
4
解决办法
3万
查看次数

iPhone NSDateComponent错误日期1.1.2011?

我用'DateFromComponents'设置了一个日期,当我把它读出来......它的错误.我必须把DAY设置为第二个或之后的任何东西,所以我得到正确的年份?!?我设置2011年,当我读它我得到2010年!


 day = 1;
 month = 1;
 year = 2011;
 NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
 NSDateComponents *components = [[NSDateComponents alloc] init];
 [components setDay:day];
 [components setMonth:month];
 [components setYear:year];
 NSDate *date = [gregorian dateFromComponents:components]; 
 [gregorian release];


 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; 
 [dateFormatter setDateFormat:@"DD MMMM YYYY"];
 NSLog (@"hmm: %@",[dateFormatter stringFromDate:actDate]);
Run Code Online (Sandbox Code Playgroud)

-------我来了1 January 2010 /// 2010 not 2011!?!?

如何解决这个问题.

克里斯

iphone nsdatecomponents

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

为什么这不会抛出任何类型的错误?

我正在尝试从其中一个博客中获取一些代码段,然后我注意到以下代码

f :: Int -> [Int]
f x = [1+x,2*x]

test :: IO ()
test = putStrLn . show $ return 5 >>= f >>= f
Run Code Online (Sandbox Code Playgroud)

执行时我正在[7,12,11,20].为什么第二个'f'函数调用不是抛出类型错误?这是List Monad的相关内容吗?

haskell type-inference

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

如何获取地址簿图像数据的裁剪框?

AddressBook框架提供ABPersonCopyImageData以获取每个地址簿条目的联系人图像.这对于图像数据非常有用,但是用户还可以对图像进行调整大小和裁剪以用于构图.当我获得图像数据时,我得到完整的图像,而不是裁剪的图像.如何获取用户用于裁剪图像的帧(或者代替该帧,如何访问裁剪的图像/数据)?

iphone addressbook

9
推荐指数
2
解决办法
1566
查看次数

确定Windows上的Perl中是否正在使用文件

我正在编写一些Perl,它可以在Windows Media Center上录制电视节目,并根据特定条件移动/重命名/删除它们.

由于Perl运行相当频繁,我想清楚地确定文件是否正在使用(换句话说,节目正在被录制过程中),所以我可以避免对它做任何事情.

我当前的方法查看文件的状态(使用"stat")并在5秒后再次比较它,如下所示:

sub file_in_use
{
  my $file = shift;

  my @before = stat($file);
  sleep 5;
  my @after = stat($file);

  return 0 if ($before ~~ $after);
  return 1;
 }
Run Code Online (Sandbox Code Playgroud)

它似乎有效,但我很有意思,可能有更好,更清洁的方法来做到这一点.

你能给些建议么?

windows testing perl winapi file

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

如何正确运行Perl"one liner"命令行脚本?

我已经浏览了一些教程,但我仍然无法弄清楚我做错了什么..我正在尝试下面的代码(在.pl Perl文件中,作为可执行文件):

#!/usr/bin/perl

perl -e 'print "Hello";' 
Run Code Online (Sandbox Code Playgroud)

我运行这个脚本并得到:

/home/user1/Desktop/file_backups.pl的执行因编译错误而中止.

(我是新手使用Perl调用Linux命令行.)

linux perl command-line

18
推荐指数
4
解决办法
7万
查看次数

如何创建SystemSoundID数组

我似乎无法弄明白.

我可以播放一个声音:

- (void) initSounds {
    // Get the main bundle for the app
    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle ();
    // Get the URL to the sound file to play
    soundFileURLRef  =  CFBundleCopyResourceURL (mainBundle,CFSTR ("1"),CFSTR ("wav"),NULL);

    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);
}

-(void) play {
    AudioServicesPlaySystemSound(self.soundFileObject);
}
Run Code Online (Sandbox Code Playgroud)

但我想创建一个SystemSoundID对象数组.当我尝试这样做时,我不断收到错误.任何人都可以告诉我创建soundFileObjects数组的代码以及我如何在AudioServicesPlaySystemSound中使用该数组?

iphone xcode objective-c

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