问题列表 - 第49848页

为什么我不能在WCF类中使用KnownType属性?

我正在使用WCF来检索对象的集合.这些对象都是ProcedureText类型,但可以是子类SuspensionText或ResumptionText,它们都继承自ProcedureText.

public class ProcedureText { }
public class SuspensionText : ProcedureText { }
public class ResumptionText : ProcedureText { }
Run Code Online (Sandbox Code Playgroud)

我的OperationContract指定一个返回ProcedureText对象数组的方法:

[OperationContract]
[WebGet(UriTemplate = "procedureTexts")]
ProcedureText[] GetProcedureTexts();
Run Code Online (Sandbox Code Playgroud)

如果我将所有对象强制转换为ProcedureText但我想保留使用子类型的区别,这是有效的.我原本希望使用KnownType属性来执行此操作,并希望能够通过将其添加到我的ProcedureText类来实现:

[System.Runtime.Serialization.KnownType(typeof(SuspensionTextDto))]
[System.Runtime.Serialization.KnownType(typeof(ResumptionTextDto))]
public class ProcedureText { }
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为编译器无法解析System.Runtime.Serialization.KnownType.我从文档中知道该属性是.NET Framework 4的一部分,但我使用的是.NET Framework 4,这是我项目的Target Frameweork.

为什么我需要设置为能够使用该属性?

wcf serialization

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

在使用Bisna时,如何在Zend Framework application.ini中定义Doctrine 2中utf-8的使用

以下ZendCasts演员表示了一种在zend框架环境中使用doctrine 2的方法.
使用此配置,如何使连接使用utf-8字符集,以便"SET NAMES 'utf8'"发生魔力?

我真正想要的是使用application.ini文件配置它的方法.
如果使用此配置无法实现,那么如何通过代码完成?_initDoctrineBootstratp文件中的方法?

谢谢.

更新
看来有一个post connect事件处理这个,但我不知道如何通过application.ini设置它(如果可能的话).
如果没有,我可以通过bootstrap方法进行设置吗?在依赖Bisna库时,引导方法是否会在任何其他学说连接代码运行之前运行?

doctrine zend-framework character-encoding doctrine-orm

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

在Oracle中进行不区分大小写的搜索

LIKE和其他比较运算符=等的默认行为区分大小写.

是否有可能使它们不区分大小写?

sql oracle case-sensitive case-insensitive sql-like

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

如何终止HandlerThreads?

按照Googles使用服务的示例,我创建了几个这样的线程.我不能使用IntentService,因为我正在做一些涉及等待回调的事情.

但是,我不知道如何终止以这种方式启动的Thread.据我了解,Threads会在run()方法返回时自动终止.但是,这种线程没有run方法.我的线程正在泄漏 - 它们在stopSelf()之后保持活跃状态​​.

@Override
public void onCreate() {

    HandlerThread thread = new HandlerThread("ServiceStartArguments",
            android.os.Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    HandlerThread thread2 = new HandlerThread("CallbackHandling",
            android.os.Process.THREAD_PRIORITY_BACKGROUND);
    thread2.start();

    mServiceLooper = thread.getLooper();
    mCallbackLooper = thread2.getLooper();
    mServiceHandler = new MyHandler(mServiceLooper);
    mCallbackHandler = new Handler(mCallbackLooper);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();

    // For each start request, send a message to start a job and deliver the
    // start ID so we know which request we're stopping when we finish …
Run Code Online (Sandbox Code Playgroud)

multithreading android

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

如何使surfaceview透明

大家好我想让我的DrawingSurface视图透明.我试了很多东西,但它不起作用.

这是我的表面视图透明的xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/icon" >
        </ImageView>

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#00000000" >

            <codewalla.android.drawings.DrawingSurface
                android:id="@+id/drawingSurface"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
            </codewalla.android.drawings.DrawingSurface>
        </LinearLayout>
    </FrameLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/colorRedBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="R" />

        <Button
            android:id="@+id/colorBlueBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="G" />

        <Button
            android:id="@+id/colorGreenBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="B" />

        <Button
            android:id="@+id/undoBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="U" />

        <Button
            android:id="@+id/redoBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:onClick="onClick"
            android:text="R" />
    </LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android surfaceview

81
推荐指数
4
解决办法
6万
查看次数

连接格式化字符串时出现问题

 currTime = DateTime.Now.ToString("u");
Run Code Online (Sandbox Code Playgroud)

上面的代码首先将时间格式化为yyyy-mm-dd hh-mm-ss(Alpha数字).

我想删除我使用的字母数字字符

 currTime = currTime.Substring(0, currTime.Length - 1);
Run Code Online (Sandbox Code Playgroud)

然后我用".000"添加到最后

 currTime = currTime + ".000";
Run Code Online (Sandbox Code Playgroud)

但是,这会删除格式,并在显示时显示标准dd-mm-yyyy格式.所以我的问题分为两部分:

所以...

如何DateTime.Nowyyyy-mm-dd hh:mm:ss没有字母数字字符的情况下格式化?

如何在不丢失格式的情况下添加".000"?

c# datetime string-formatting

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

使用网页作为C#桌面应用程序中的UI?

我正在构建一个带有简单UI的C#桌面应用程序.由于我对HTML/CSS的熟悉,以及之前基于Web的非常相似的应用程序的迭代,如果我可以重用一些现有的HTML/CSS页面作为这个新桌面应用程序的UI,这将是理想的选择.

可以用C#做​​到吗?任何人都可以展示一个使用HTML/CSS页面作为C#桌面应用程序的UI的简单示例吗?

html c#

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

选择满足条件的矩阵行

在R中有一个矩阵:

     one two three four
 [1,]   1   6    11   16
 [2,]   2   7    12   17
 [3,]   3   8    11   18
 [4,]   4   9    11   19
 [5,]   5  10    15   20
Run Code Online (Sandbox Code Playgroud)

我想提取其行有第三列= 11的子矩阵.这是:

      one two three four
 [1,]   1   6    11   16
 [3,]   3   8    11   18
 [4,]   4   9    11   19
Run Code Online (Sandbox Code Playgroud)

我想在没有循环的情况下这样做.我是R的新手,所以这可能非常明显,但文档往往有些简洁.

select r matrix submatrix

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

如何通过代码触发"今天"按钮的单击?

如何通过FullCalendar中的代码触发单击"今天"按钮?如果我通过外部按钮在哪里?

fullcalendar

4
推荐指数
2
解决办法
7336
查看次数

如果任务失败,如何将任务放回队列?

我有一个看起来像这样的脚本:

#!/usr/bin/env python
# encoding: utf-8

import time, random, os, multiprocessing

def main():
    NPROCESSES = 5
    pool = multiprocessing.Pool(processes=NPROCESSES)

    a = [1,2,3,4,5,6,7,8,9,0]
    for _ in pool.imap_unordered(do_task, a):
        pass

def do_task(n):
    try:
        might_crash(n)
    except Hell, e:
        print e, " crashed."

def might_crash(n):
    time.sleep(3*random.random())
    if random.randrange( 3 ) == 0:
        raise Hell(n)
    print n

class Hell(Exception):
    pass  

if __name__=="__main__":    
    main()
Run Code Online (Sandbox Code Playgroud)

此脚本通常会打印'a'中的值,但might_crash()会随机引发异常.

我想捕获这些异常并将当前的do_task()放回队列中以便稍后重试.

如果当前任务失败,如何将当前任务放回队列?

python multiprocessing

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