走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-08-21 04:58:27

如果您尝试介入通过 COM+ 调用的托管 .NET 代码,请确保将调试器附加到 dllhost.exe 而不是 w3p.exe(或运行 Web 应用程序的任何进程...具体取决于您的IIS 版本)。

COM+ 代码不在 Web 服务器进程中执行...

If you're trying to step in to Managed .NET code being called via COM+, make sure you're attaching the Debugger to dllhost.exe rather than w3p.exe (or whatever process is running your web app...depending on your version of IIS).

COM+ code is not executed in process with the web server...

Classic.ASP通过COM调用.NET组件

走过海棠暮 2024-08-21 04:31:47

您的问题是 postorder 接受必须以这种方式调用的函数对象:

f(arg);

您正在传递一个指向成员函数的指针。您应该首先调用 mem_fun 从指向成员的指针创建一个函数对象:

std::mem_fun(&city_db::print)

返回的函数对象有两个参数:指向 city_db 的指针(隐式 this 指针)和要打印的对象。您可以使用 bind1st 将第一个绑定到此,如下所示:

std::bind1st(std::mem_fun(&city_db::print), this)

现在您应该能够对其调用 postorder:

postorder(std::bind1st(std::mem_fun(&city_db::print), this), head);

Your problem is that postorder accepts a function object that must be called this way:

f(arg);

You are passing in a pointer to member function. You should first call mem_fun to make a function object from the pointer to member:

std::mem_fun(&city_db::print)

The returned function object takes two arguments: the pointer to a city_db (the implicit this pointer), and the object to be printed. You can bind the first to this with bind1st, like this:

std::bind1st(std::mem_fun(&city_db::print), this)

And now you should be able to call postorder on it:

postorder(std::bind1st(std::mem_fun(&city_db::print), this), head);

在调用传递给模板函数的函数时调用指向成员函数的指针

走过海棠暮 2024-08-20 20:55:44

我也使用 Visual Studio;为了快速测试和原型设计,我的桌面上有一个文件 scratch.c,我只需加载该文件并在其中进行测试。

我没有看到打开 Visual Studio,单击新文档图标,编写代码,按 F5,然后接受所有内容的默认值,因为太费力了:)

我拥有的另一个替代方案(我不用于 C,但用于 Haskell)是将 PuTTY 放入我有权访问的 Linux 盒子中,并在那里做所有事情。

I also use Visual Studio; for quick testing and prototyping, I have a file scratch.c on my desktop, which I just load up and test things out in.

I don't see opening Visual Studio, clicking the new document icon, writing code, pressing F5 then just accepting the defaults for everything as being too much effort :)

The other alternative I have (which I don't use for C, but do for Haskell) is to PuTTY into a Linux box I have access to, and do everything on there.

你如何尝试小型/简单的 C 或 C++源代码?

走过海棠暮 2024-08-20 10:36:16

不,没有办法强制打开新选项卡,因为非选项卡式浏览不支持此操作

您只能将其设置为打开新窗口,而不能设置新选项卡。

Nope, there's no way to force the opening of a new tab, simply because this would be unsupported by un-tabbed browsing

You can only set it to open a new window, not a new tab.

在 Firefox 中创建新选项卡/在选项卡之间切换?

走过海棠暮 2024-08-20 03:38:47

您可以使用 () 运算符调用它,也可以将其传递给 feval。您需要首先从元胞数组中提取它。

x; % holds your ans from original question
fcn = x{1}; % Extract from cell array
fcn(); % call with () syntax
feval(fcn); % call with feval() syntax

如果这不起作用,请发布确切的代码和错误消息,以便我们了解出了什么问题。

You can call it with the () operator, or you can pass it to feval. You'll need to extract it from the cell array first.

x; % holds your ans from original question
fcn = x{1}; % Extract from cell array
fcn(); % call with () syntax
feval(fcn); % call with feval() syntax

If that doesn't work, please post exact code and error message so we can see what's going wrong.

如何从 MATLAB 中的另一个函数文件执行回调函数?

走过海棠暮 2024-08-19 23:37:26

我不确定动态在这里意味着什么,但是您是否在寻找 ImageView.setImageURI

I'm not sure what dynamic means here, but are you looking for ImageView.setImageURI?

imageview 网络图像资源

走过海棠暮 2024-08-19 22:04:10

我们决定使用以下解决方案。
使用 Date 从数据库中检索日期。这是因为 Date 是无时区类型。

@Column(name = "DATE_COLUMN")
@Temporal(TemporalType.TIMESTAMP)
private Date dateValue;

public Date getDate()
{
   return dateValue;
}

为了通过 UTC (jax-ws) 中的 WebService 发送它,我们创建了 UtcTimestampAdapter 来在编组阶段将区域从应用程序的默认值更改为 UTC。

public class UtcTimestampAdapter extends XmlAdapter<XMLGregorianCalendar, Date>
{
   @Override
   public XMLGregorianCalendar marshal(Date date) throws Exception
   {
      GregorianCalendar calendar = new GregorianCalendar();
      calendar.setTime(date);

      DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance();
      XMLGregorianCalendar xmlCalendar = 
         dataTypeFactory.newXMLGregorianCalendar(calendar);

      //Reset time zone to UTC
      xmlCalendar.setTimezone(0);

      return xmlCalendar;
   }

   @Override
   public Date unmarshal(XMLGregorianCalendar calendar) throws Exception
   {
      return calendar.toGregorianCalendar().getTime();
   }
}

然后,为了对该模块中的所有数据字段启用此规则,我们添加了包特定设置,如下所示。

@XmlJavaTypeAdapter(value = UtcTimestampAdapter.class, type = Date.class)
@XmlSchemaType(name = "dateTime", type = XMLGregorianCalendar.class)
package com.companyname.modulename;

就是这样。现在我们有了将所有逻辑封装在一处的通用解决方案。如果我们想通过其他模块中的 Web 服务以 UTC 形式发送无时区日期,我们只需注释某个包即可。

We decided to use following solution.
Use Date for retrieving date from database. It is because Date is timezoneless type.

@Column(name = "DATE_COLUMN")
@Temporal(TemporalType.TIMESTAMP)
private Date dateValue;

public Date getDate()
{
   return dateValue;
}

And to send it via WebService in UTC (jax-ws) we created UtcTimestampAdapter to change zone from application's default to UTC in the marshaling phase.

public class UtcTimestampAdapter extends XmlAdapter<XMLGregorianCalendar, Date>
{
   @Override
   public XMLGregorianCalendar marshal(Date date) throws Exception
   {
      GregorianCalendar calendar = new GregorianCalendar();
      calendar.setTime(date);

      DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance();
      XMLGregorianCalendar xmlCalendar = 
         dataTypeFactory.newXMLGregorianCalendar(calendar);

      //Reset time zone to UTC
      xmlCalendar.setTimezone(0);

      return xmlCalendar;
   }

   @Override
   public Date unmarshal(XMLGregorianCalendar calendar) throws Exception
   {
      return calendar.toGregorianCalendar().getTime();
   }
}

Then to enable this rule to all Datas fields in the module we added package specific setting like so.

@XmlJavaTypeAdapter(value = UtcTimestampAdapter.class, type = Date.class)
@XmlSchemaType(name = "dateTime", type = XMLGregorianCalendar.class)
package com.companyname.modulename;

That's it. Now we have generic solution which encapsulate all logic in one place. And if we want to send timezoneless dates as UTC via web service in some other module we will just annotate certain package.

将数据库时间戳列映射到 UTC 日历 (JPA) 并通过 WebService (jax-ws) 将其作为 UTC 日期传递

走过海棠暮 2024-08-19 19:49:39

你可以做的一件事是将你的peace-main设置为浮动“左”并且只有700px的宽度(因此侧边栏有足够的空间)

然后侧边栏也应该将其浮动设置为“右”

但我实际上会建议您尝试以下方法之一:
http://www.thenoodleincident.com/tutorials/box_lesson/boxes.html

one thing you could do is set your peace-main to float 'left' and only have a width of 700px (so there is enough room for the sidebar)

then the sidebar should also have it's float set to 'right'

but i would actually suggest you try one of these methods :
http://www.thenoodleincident.com/tutorials/box_lesson/boxes.html

无法在 IE7 中正确定位 div

走过海棠暮 2024-08-19 16:20:39

我无法找到在 WIX 中执行此操作的方法,因此我采取了自定义操作。我一直在用 Javascript 编写所有自定义操作。我发现 Javascript 易于使用且功能强大,不管其他人怎么说

但我找不到从 Javascript 添加脚本映射的方法,因为 IIS 元数据库更新需要使用 VBArray 数据类型,VBScript 支持该数据类型,但 Javascript 不支持。哎呀。

这是 VBScript 中的代码。

Function AddExtension_CA()

    VBSLogMessage("AddExtension_CA() ENTRY")
    Dim iis
    Set iis = GetObject("winmgmts://localhost/root/MicrosoftIISv2")

    dim siteName
    siteName = Session.Property("WEBSITE_NAME")

    VBSLogMessage "website name(" & siteName & ")"

    If (siteName <> "") Then
        Dim idir, dll
        idir = Session.Property("INSTALLDIR")
        dll = idir & "\MyIsapiExtension.dll"

        Dim query
        If (siteName <> "W3SVC") Then
            query = "SELECT * FROM IIsWebServerSetting WHERE Name = '" & siteName & "'"
        Else
            query = "SELECT * FROM IIsWebServiceSetting"
        End If

        Set results = iis.ExecQuery(query)
        Dim newMaps()   '' dynamically-sized Array

        '' two passes
        For t = 0 to 1
            Dim c
            c=0
            For Each item in results
                '' in pass 1, count them. 
                '' in pass 2, copy them.
                For i = 0 to Ubound(item.ScriptMaps)
                    If UCase(item.ScriptMaps(i).Extensions) <> ".IIRF" Then
                        If t = 1 Then
                            Set newMaps(c) = item.ScriptMaps(i)
                        End if
                        c = c+1
                    End If
                Next

                If t = 0 Then
                    ReDim Preserve newMaps(c)
                Else
                    VBSLogMessage("setting new filter")

                    Set newMaps(c) = iis.get("ScriptMap").SpawnInstance_()
                    newMaps(c).Extensions = ".iirf"
                    newMaps(c).ScriptProcessor= dll
                    newMaps(c).Flags = "1"
                    newMaps(c).IncludedVerbs = "GET,POST"
                    item.ScriptMaps = newMaps
                    item.Put_()
                End If
            Next
        Next

        VBSLogMessage("Allowing the DLL as an Extension")

        dim IIsWebServiceObj
        Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")
        IIsWebServiceObj.AddExtensionFile dll, True, "GroupId", True, "Description of the Extension"
        Set IIsWebServiceObj = Nothing

    End If

    Set iis = Nothing

    VBSLogMessage("AddExtension_CA() EXIT")

    AddExtension_CA = 1   ' MsiActionStatus.Ok

End Function

这是 WIX 代码:

<Fragment>
    <CustomAction Id="CA.AddExtension"
              BinaryKey="B.VBScript"
              VBScriptCall="AddExtension_CA"
              Execute="immediate"
              Return="check" />

    ....

另请参阅:
添加扩展文件

I couldn't figure out a way to do this in WIX, so I resorted to a custom action. I had been writing all my custom actions in Javascript. I find Javascript to be easy to use and robust for that purpose, despite what others have said.

But I could not find a way to add a scriptmap from Javascript, because the IIS metabase update requires the use of a VBArray datatype, which is supported in VBScript, but not in Javascript. Whoops.

So, here is the code, in VBScript.

Function AddExtension_CA()

    VBSLogMessage("AddExtension_CA() ENTRY")
    Dim iis
    Set iis = GetObject("winmgmts://localhost/root/MicrosoftIISv2")

    dim siteName
    siteName = Session.Property("WEBSITE_NAME")

    VBSLogMessage "website name(" & siteName & ")"

    If (siteName <> "") Then
        Dim idir, dll
        idir = Session.Property("INSTALLDIR")
        dll = idir & "\MyIsapiExtension.dll"

        Dim query
        If (siteName <> "W3SVC") Then
            query = "SELECT * FROM IIsWebServerSetting WHERE Name = '" & siteName & "'"
        Else
            query = "SELECT * FROM IIsWebServiceSetting"
        End If

        Set results = iis.ExecQuery(query)
        Dim newMaps()   '' dynamically-sized Array

        '' two passes
        For t = 0 to 1
            Dim c
            c=0
            For Each item in results
                '' in pass 1, count them. 
                '' in pass 2, copy them.
                For i = 0 to Ubound(item.ScriptMaps)
                    If UCase(item.ScriptMaps(i).Extensions) <> ".IIRF" Then
                        If t = 1 Then
                            Set newMaps(c) = item.ScriptMaps(i)
                        End if
                        c = c+1
                    End If
                Next

                If t = 0 Then
                    ReDim Preserve newMaps(c)
                Else
                    VBSLogMessage("setting new filter")

                    Set newMaps(c) = iis.get("ScriptMap").SpawnInstance_()
                    newMaps(c).Extensions = ".iirf"
                    newMaps(c).ScriptProcessor= dll
                    newMaps(c).Flags = "1"
                    newMaps(c).IncludedVerbs = "GET,POST"
                    item.ScriptMaps = newMaps
                    item.Put_()
                End If
            Next
        Next

        VBSLogMessage("Allowing the DLL as an Extension")

        dim IIsWebServiceObj
        Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")
        IIsWebServiceObj.AddExtensionFile dll, True, "GroupId", True, "Description of the Extension"
        Set IIsWebServiceObj = Nothing

    End If

    Set iis = Nothing

    VBSLogMessage("AddExtension_CA() EXIT")

    AddExtension_CA = 1   ' MsiActionStatus.Ok

End Function

Here's the WIX code:

<Fragment>
    <CustomAction Id="CA.AddExtension"
              BinaryKey="B.VBScript"
              VBScriptCall="AddExtension_CA"
              Execute="immediate"
              Return="check" />

    ....

See also:
AddExtensionFile.

WIX:如何在现有 Web 应用程序或站点上注册新的 ISAPI 扩展或脚本映射?

走过海棠暮 2024-08-19 12:16:22

可以这样做: http://msdn.microsoft.com/en-us /library/b8ytshk6.aspx(请参阅“构造泛型类型的实例”部分)

以下示例创建一个 Dictionary

Type d1 = typeof(Dictionary<,>);
Type[] typeArgs = {typeof(string), typeof(object)};
Type constructed = d1.MakeGenericType(typeArgs);
object o = Activator.CreateInstance(constructed);

It can be done: http://msdn.microsoft.com/en-us/library/b8ytshk6.aspx (See section "Constructing an Instance of a Generic Type")

The following example creates a Dictionary<string,object>:

Type d1 = typeof(Dictionary<,>);
Type[] typeArgs = {typeof(string), typeof(object)};
Type constructed = d1.MakeGenericType(typeArgs);
object o = Activator.CreateInstance(constructed);

ClassName

走过海棠暮 2024-08-19 07:35:00

标准中告诉您编译器何时可以删除副本的部分是 12.8/15。是否实际执行省略始终取决于编译器。有两种合法情况,以及它们的任意组合:

  • “在具有类返回类型的函数中的 return 语句中,当表达式是非易失性自动对象的名称,其类型与以下内容相同:函数返回类型"

  • < p>“当尚未绑定到引用的临时类对象将被复制到具有相同 cv-unqualified 类型的类对象时”。

前者通常称为“命名返回值优化”,它允许您在示例中看到的输出。后者实际上将复制初始化转换为直接初始化,例如,如果您的代码执行了 Example x = Example();,则可能会发生这种情况。

不允许其他复制省略,当然,通常的“假设”规则适用除外。因此,如果复制构造函数具有跟踪功能,那么以下代码必须调用它:

Example x;
Example y = x;

但是如果 x 未被使用,并且 cctor 没有副作用,那么我认为它可以被优化掉,只需就像任何其他不执行任何操作的代码一样。

The part of the standard which tells you when compilers may elide copies is 12.8/15. It's always up to the compiler whether to do actually perform the elision. There are two legal situations, plus any combination of them:

  • "in a return statement in a function with a class return type, when the expression is the name of a non-volatile automatic object with the same cv-unqualified type as the function return type"

  • "when a temporary class object that has not been bound to a reference would be copied to a class object with the same cv-unqualified type".

The former is usually referred to as the "named return value optimization", and it's what permits the output you're seeing in your example. The latter in effect turns copy-initialization into direct initialization, and could occur for instance if your code did Example x = Example();.

Other copy elisions are not permitted, except of course that the usual "as-if" rules apply. So if the copy constructor has tracing in, then the following code must call it:

Example x;
Example y = x;

But if x were otherwise unused, and the cctor had no side-effects, then I think it could be optimized away, just like any other code that does nothing.

C++复制构造函数调用

走过海棠暮 2024-08-19 02:48:22

我认为我找到了原因,但这只是我的猜测:

当在字符串中应该表示正确的 xml 文档只是一些字符串(例如示例中的“无”)时,验证不会发生,因为加载会抛出异常,这不是一个根本没有xml。

Think I found the reason, but this is only my guess:

When in string that should represent a proper xml document is just some string (like "nothing" in example) the validation would not happen becouse load throws exception that this isn't an xml at all.

XmlDocument 未执行验证?

走过海棠暮 2024-08-19 00:24:39

我认为发生这种情况的原因是因为通过项目向上滑动,页面高度变得越来越短。 Firefox 无法同时重绘页面、更改高度、向上滚动视口以及为元素设置动画。

这是我用来尝试解决问题的方法。潜在的副作用是,如果他们打开所有盒子并一一关闭它们,您将留下大量空白。但是,您不会关闭闪光灯。如果您滚动到页面的最底部,打开时也会遇到同样的问题。 $('html,body') 滚动行解决了以下问题:

$(".question").click(function(){
    var $animator = $(this).next(".answer"),
        $post     = $animator.closest('.post');
    if($animator.is(':visible')){
        $post.css('min-height', $post.height());
        $animator.slideUp("slow");
    } else {
        $('html, body').scrollTop($('html, body').scrollTop() - 1);
        $animator.slideDown("slow", function(){
            $post.css('min-height', 0);
        });
    }
});

I think the reason this is happening, is because by the item sliding up, the page height is getting shorter. Firefox can't redraw the page, change the height, scroll the viewport up, and animate your element all at the same time.

Here is what I would use to attempt to fix the problem. The potential side effect would be, if they opened all of the boxes and closed them one by one, you would be left with a lot of white space. However, you won't have the flashes on close. You also have the same problem on open if you are scrolled to the very bottom of the page. The $('html,body') scroll line addresses that:

$(".question").click(function(){
    var $animator = $(this).next(".answer"),
        $post     = $animator.closest('.post');
    if($animator.is(':visible')){
        $post.css('min-height', $post.height());
        $animator.slideUp("slow");
    } else {
        $('html, body').scrollTop($('html, body').scrollTop() - 1);
        $animator.slideDown("slow", function(){
            $post.css('min-height', 0);
        });
    }
});

jQuery SlideToggle 在 Firefox 中闪烁

走过海棠暮 2024-08-19 00:17:43

通常我不会测试子类中的行为,除非子类改变了父类中预期的行为。如果它使用相同的行为,则无需测试它。如果您计划对父类进行重大更改,但子类仍然需要旧的行为,那么我将首先在子类中创建测试来定义其所需的行为,然后我将在父类测试和后续测试中进行更改代码更改。这遵循 YAGNI 原则——你不会需要它——并延迟子测试的实施,直到它们真正有目的为止。

Normally I wouldn't test behavior in the child class unless the child class changes the behavior from that expected in the parent class. If it is using the same behavior, there is no need to test it. If you are planning to make breaking changes to the parent class but the child class still needs the old behavior, then I would first create tests in the child class to define its required behavior, then I would make the changes in the parent tests and subsequent code changes. This follows the YAGNI principle -- you aren't going to need it -- and delays the implementation of the child tests until they actually have a purpose.

子类的单元测试

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