灯角

文章 0 评论 0 浏览 23

灯角 2024-11-22 17:12:42

假设您使用的是 WCF,它默认使用 SOAP,因此如果您正确设置了所有内容,它将自动为您进行序列化和反序列化。

[OperationContract]
MyResponse ParseId(MyRequest req);

MyResponse可以保存响应信息
MyRequest 可以保存请求信息

实现可以是这样的:

public MyResponse ParseId(MyRequest req)
{
    if(req.Id == null)
    {
       //Error
    }
    else
    {

    }
 }

如果真的很简单,您可以这样做:

[OperationContract]
void ParseId(int id);

实现:

public void ParseId(int id)
{
  if(id == null)
  {
      //throw exception;
  }
  else
  {

  }
}

不要忘记用 DataContract 属性来装饰您的 MyResponse 类和 MyRequest 类。

Assuming you are using a WCF, it uses SOAP by default, so if you have everything setup correctly, it will automatically serialize and deserialize for you.

[OperationContract]
MyResponse ParseId(MyRequest req);

MyResponse can hold response information
MyRequest can hold request information

Implementation could be like this:

public MyResponse ParseId(MyRequest req)
{
    if(req.Id == null)
    {
       //Error
    }
    else
    {

    }
 }

If it is really simple, you can do something like this:

[OperationContract]
void ParseId(int id);

Implementation:

public void ParseId(int id)
{
  if(id == null)
  {
      //throw exception;
  }
  else
  {

  }
}

Don't forget to decorate your MyResponse class and MyRequest class with DataContract attributes.

具有 SOAP 响应的 C# Web 应用程序

灯角 2024-11-22 15:40:16

去掉这个: async: false (默认情况下为 true)

你不应该同步进行 ajax 调用,除非在极少数情况下你必须等待。

这肯定会锁定页面功能(甚至无法单击鼠标)

Take this out: async: false (by default it is true)

You should not make ajax call in synchronusly unless extreme rare case where you must wait.

This will definitely lock the page from functioning (not even a mouse click possible)

使用 jquery ajax 刷新页面

灯角 2024-11-22 09:43:26

在需要之前,不要担心 I/O 速度或内存消耗。您不会注意到其中的差异。

另外,请尽可能保持代码模块化,以便可以在其他上下文中重用。

Don't worry about i/o speed or memory consumption until you need to. You won't notice the difference.

Also, keep your code as modular as possible so that it can be re-used in other contexts.

加载应用程序、函数、类的大文件

灯角 2024-11-22 06:30:14

您需要在表达式混合中编辑文本框的模板。它的状态将具有只读状态,您需要对其进行调整以满足您的需求。更多信息请参见此处

You'd need to edit the template of the textbox in expression blend. Its states would have a read-only state which you need to tweak to your satisfaction. More info here.

如何使只读文本框中的文字不褪色?

灯角 2024-11-22 03:51:56

在 GDI+ 中,您可以将 FillPath()DrawPath()FillModeAlternate 结合使用。

有一个非常接近您要求的示例 这里

In GDI+, you can use FillPath() or DrawPath() with FillModeAlternate.

There's an example pretty close to what you're asking for here.

C# 绘图:绘制中间有孔的多边形的最佳方法是什么

灯角 2024-11-21 23:39:28

AddThis 人员称,显然没有解决办法。

发生这种情况是因为我们不
重新计算DIV的位置
调用菜单后。我什么
要做的就是禁用紧凑菜单
并将按钮设置为仅使用
扩展(完整)菜单,这是自动的
居中。

因此,将 更改为

http://www.addthis.com/forum/viewtopic.php?f=5&t=24157

Apparently there is no fix, according to the AddThis people.

This happens because we don't
recalculate the position of the DIV
after the menu is invoked. What I
would do is disable the compact menu
and set the button to only use the
expanded (full) menu, which is auto
centered.

So change <a class="addthis_button_compact"></a> to <a class="addthis_button_expanded"></a>

http://www.addthis.com/forum/viewtopic.php?f=5&t=24157

在固定元素中添加此小部件 - 位置错误?

灯角 2024-11-21 19:16:09

如果您按值传递指针(这就是您正在做的事情),它将采用该指针值并将新的披萨分配给它。该值与上面第 7 行中找到的值不同。例如:

int bar = new int(3);
void  doSomething(int *foo){ foo = new int(5); } //memory leak here
doSomething(bar);

bar 仍然是 3。这实际上就是您正在做的事情。

您想通过引用传递指针:

void doSomething(int **foo){ delete *foo; *foo = new int(5); }

更新

看到您想要一个嵌套类结构,其中 Child 类以多态方式保留类 Base 的记录......

void doSomething(MyClass **foo){ *foo = new MyChildClass(*foo); }

我希望作为子类中定义的一部分,您已确保正确处理资源(即指针)的释放。我建议考虑合并一个智能指针,但这可能超出了您完成此任务所需的范围。

If you pass in a pointer by value (which is what you're doing) it will take that pointer value and assign the new pizza to it. That value is not the same as that which is found in line 7 above. For instance:

int bar = new int(3);
void  doSomething(int *foo){ foo = new int(5); } //memory leak here
doSomething(bar);

bar is still 3. That's effectively what you're doing.

You want to pass in the pointer by reference:

void doSomething(int **foo){ delete *foo; *foo = new int(5); }

Update:

Seeing as you'd like a nested class structure, wherein class Child retains a record of a class Base in a polymorphic manner...

void doSomething(MyClass **foo){ *foo = new MyChildClass(*foo); }

I hope that as part of your definition within the child classes you've made sure you're handling the release of resources (i.e. the pointers) correctly. I'd suggest looking at incorporating a smart pointer but that might be more than you need for this assignment.

装饰器设计模式、功能bug

灯角 2024-11-21 19:13:25

这是一个非常广泛的问题,所以我将其分为 3 个主要任务,并为您提供高级概述:

1) 创建拼图游戏图像

2) 拖放拼图块

3) 检查拼图块是否放入正确的位置放置


第1步主要是图像编辑问题而不是编程问题,因此这里不多说。但请注意,可以使用玩家提交的图像或从互联网下载的图像自动生成不同的谜题,方法是应用矢量蒙版并将 BitmapData 克隆到预先创建的影片剪辑中。

第 2 步主要是向片段添加鼠标事件侦听器,并在侦听器函数中使用 startDrag() 和 stopDrag()。类似于:

piece.addEventListener(MouseEvent.MOUSE_DOWN, OnDrag);
piece.addEventListener(MouseEvent.MOUSE_UP, OffDrag);
function OnDrag(e:Event) {
  e.target.startDrag();
}
function OffDrag(e:Event) {
  e.target.stopDrag();
  //check placement
}

正如评论中所指出的,当一个棋子掉落时,就会发生第 3 步。有多种方法可以解决这个问题,但我的建议是在创建拼图时将已解决的位置存储在数组中,然后根据解决方案数组检查所有部分以查看拼图是否已解决。

顺便说一句,在检查放置时,通常最好检查零件是否掉落在正确位置的一定距离内,如果是,则将其卡入到位。

This is a really broad question so I'll break it down into 3 main tasks and give you a high-level overview:

1) Create the jigsaw puzzle images

2) Drag and drop pieces

3) Check if the pieces are dropped into the correct placement


Step 1 is mostly an image editing question and not programming, so there's not much to say here. Do note however that it is possible to automatically generate different puzzles using images submitted by the player or downloaded off the internet by doing things like applying vector masks and cloning the BitmapData into pre-created Movieclips.

Step 2 is mostly about adding mouse event listeners to the pieces and using startDrag() and stopDrag() in the listener functions. Something like:

piece.addEventListener(MouseEvent.MOUSE_DOWN, OnDrag);
piece.addEventListener(MouseEvent.MOUSE_UP, OffDrag);
function OnDrag(e:Event) {
  e.target.startDrag();
}
function OffDrag(e:Event) {
  e.target.stopDrag();
  //check placement
}

As noted in the comment, step 3 would happen when a piece is dropped. There are multiple ways to go about this, but my recommendation would be to store the solved positions in an Array when the puzzle is created, and then check all the pieces against the solution Array to see if the puzzle has been solved.

Incidentally, when checking placement it is generally best to check if the piece was dropped within a certain distance of the correct position, and if so snap it into place.

如何制作基于 Flash 的拼图游戏

灯角 2024-11-21 17:10:15

方案应为“http”,主机应为“www.abc.com”。

The scheme should be "http" and the host should be "www.abc.com".

Android 3.1 Intent 过滤器主机方案与 http 方案的问题

灯角 2024-11-21 10:49:11

如果您将宽度设置为%,它将采用其父元素的宽度。在您的情况下。div采用父元素的宽度,即td

If you set width to %,it will take the width of their parent element.In your case.the div takes the width of the parent element i.e td

为什么 div 100% 宽度不能按预期工作

灯角 2024-11-21 08:00:27

我怀疑您正在传递 ArrayList,因为 ArrayList 迭代器上的删除方法不会引发该异常。

我猜你正在传递一个 ArrayList 的用户派生类,该类的迭代器在删除时会抛出该异常。

public void remove() {
    if (lastRet == -1)
    throw new IllegalStateException();
        checkForComodification();

    try {
    AbstractList.this.remove(lastRet);
    if (lastRet < cursor)
        cursor--;
    lastRet = -1;
    expectedModCount = modCount;
    } catch (IndexOutOfBoundsException e) {
    throw new ConcurrentModificationException();
    }
}

I doubt you are being passed an ArrayList, as the remove method on the ArrayList iterator does not throw that exception.

I'm guessing your are being passed a user derived class of ArrayList who's iterator does throw that exception on remove.

public void remove() {
    if (lastRet == -1)
    throw new IllegalStateException();
        checkForComodification();

    try {
    AbstractList.this.remove(lastRet);
    if (lastRet < cursor)
        cursor--;
    lastRet = -1;
    expectedModCount = modCount;
    } catch (IndexOutOfBoundsException e) {
    throw new ConcurrentModificationException();
    }
}

操作 ArrayList 时出现 AbstractList.remove() 中的 UnsupportedOperationException

灯角 2024-11-21 06:13:35

更新看来您的应用程序服务器错误地处理了异常,因此您必须手动查看所有字段并检查它们的类型是否实现Serialized


您很可能正在处理你的例外错误。我假设你正在做:

try { ..
} catch(Exception ex) {
   System.out.println("Caught Exception while trying to serialize"); // wrong
   ex.printStackTrace(); // better
   logger.error("Serialization problem", ex); //best
}

如果是这样的话 - 你无法获得更多信息,因为你已经吞下了异常。您应该调用 ex.printStackTrace() (或使用日志框架)

,然后异常会告诉您哪个类未能序列化,因此您将能够将其标记为 Serializable< /代码>

Update it appears that your application server is handling the exception wrongly, so you'd have to manually look through all fields and check if their types implement Serializable


You are most likely handling your exception wrong. I assume you are doing:

try { ..
} catch(Exception ex) {
   System.out.println("Caught Exception while trying to serialize"); // wrong
   ex.printStackTrace(); // better
   logger.error("Serialization problem", ex); //best
}

If that's the case - you can't get any more info, because you've swallowed the exception. You should call ex.printStackTrace() instead (or use a logging framework)

Then the exception will tell you which class fails the serialization, and so you will be able to mark it as Serializable

尝试序列化时捕获异常

灯角 2024-11-21 03:23:55

您在名称列中缺少“UserName”,即列名称和值不匹配。

string insertCommand = 
    "INSERT INTO Users (UserID,UserName) VALUES" + "" + 
    "(CONVERT(uniqueidentifier, '" + UsersIdentityToinsert + "'),'"+ userName+"')";

You are missing "UserName" in column Names, that is, Column Name and values mismathch.

string insertCommand = 
    "INSERT INTO Users (UserID,UserName) VALUES" + "" + 
    "(CONVERT(uniqueidentifier, '" + UsersIdentityToinsert + "'),'"+ userName+"')";

sql语句有问题

灯角 2024-11-21 01:33:28
<script type="text/javascript">
    function your_function() {
        alert('clicked!');
    }
</script>

<a onclick="your_function();" href="/foo/bar">Foo Bar</a>

如果 Javascript 关闭,链接将正常运行。

在这种情况下,除非 your_function() 不返回 false,否则单击链接时也会跟随该链接。

为了防止这种情况,可以让 your_function() 返回 false,或者在 onclick 属性中的函数调用之后添加 return false;

<script type="text/javascript">
    function your_function() {
        alert('clicked!');
        return false;
    }
</script>

<a onclick="your_function();" href="/foo/bar">Foo Bar</a>

或者:

<script type="text/javascript">
    function your_function() {
        alert('clicked!');
    }
</script>

<a onclick="your_function(); return false;" href="/foo/bar">Foo Bar</a>

使用 element.addEventListener()

点击后默认锚点行为:

<script type="text/javascript">
    document.addEventListener("load", function() { 
        document.getElementById("your_link").addEventListener("click", function() {
            alert('clicked');
        }, true); 
    }, true);
</script> 

<a id="your_link" href="/foo/bar">Foo Bar</a>

没有:

<script type="text/javascript">
    document.addEventListener("load", function() { 
        document.getElementById("your_link").addEventListener("click", function(event) {
            event.preventDefault();
            alert('clicked');
        }, true); 
    }, false);
</script> 

<a id="your_link" href="/foo/bar">Foo Bar</a>
<script type="text/javascript">
    function your_function() {
        alert('clicked!');
    }
</script>

<a onclick="your_function();" href="/foo/bar">Foo Bar</a>

If Javascript is off, the link behaves normally.

In this case, unless your_function() does not return false, the link will be followed when clicked as well.

To prevent this, either make your_function() return false, or add return false; just after the function call in your onclick attribute:

<script type="text/javascript">
    function your_function() {
        alert('clicked!');
        return false;
    }
</script>

<a onclick="your_function();" href="/foo/bar">Foo Bar</a>

Or:

<script type="text/javascript">
    function your_function() {
        alert('clicked!');
    }
</script>

<a onclick="your_function(); return false;" href="/foo/bar">Foo Bar</a>

Using element.addEventListener()

With default anchor behaviour following click:

<script type="text/javascript">
    document.addEventListener("load", function() { 
        document.getElementById("your_link").addEventListener("click", function() {
            alert('clicked');
        }, true); 
    }, true);
</script> 

<a id="your_link" href="/foo/bar">Foo Bar</a>

Without:

<script type="text/javascript">
    document.addEventListener("load", function() { 
        document.getElementById("your_link").addEventListener("click", function(event) {
            event.preventDefault();
            alert('clicked');
        }, true); 
    }, false);
</script> 

<a id="your_link" href="/foo/bar">Foo Bar</a>

创建双功能 html Url 链接?

灯角 2024-11-21 01:14:21

您可以使用生成的行 ID 进行循环,并将颜色基于行 ID 的倍数。让我尝试快速输入一些内容。

You could do a loop with a generated row id, and base the colors on the multiple of the row Id.. let me try typing up something quickly.

jsTree 中不同级别的行使用不同的颜色

更多

推荐作者

浪漫人生路

文章 0 评论 0

620vip

文章 0 评论 0

羞稚

文章 0 评论 0

走过海棠暮

文章 0 评论 0

你好刘可爱

文章 0 评论 0

陌若浮生

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文