问题列表 - 第14829页

php SimpleXML检查孩子是否存在

A->b->c可能存在但c可能不存在.我该如何检查?

php simplexml

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

Python - 覆盖实例的__getattribute__?

这个对我来说似乎有点棘手.前段时间我已经设法用以下内容覆盖实例的方法:

def my_method(self, attr):
    pass

instancemethod = type(self.method_to_overwrite)
self.method_to_overwrite = instancemethod(my_method, self, self.__class__)
Run Code Online (Sandbox Code Playgroud)

这对我很有用; 但现在我正在尝试覆盖一个实例的__getattribute__()函数,由于该方法似乎不适合我

<type 'method-wrapper'>
Run Code Online (Sandbox Code Playgroud)

有可能做任何事情吗?我找不到任何体面的Python文档method-wrapper.

python django

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

WPF DataGrid:将DataGridColumn绑定到ContextMenu MenuItems IsChecked(MVVM)

我想通过右键单击列标题来控制用户可用的DataGrid列可见性ContextMenu.将ContextMenu显示所有可用的列的名称.我正在使用MVVM设计模式.

我的问题是:如何将绑定DataGridColumnVisibility属性设置IsChecked的属性MenuItem地处ContextMenu.

一些模型代码:

<UserControl.Resources>         
    <ContextMenu x:Key="ColumnHeaderContextMenu">  
        <MenuItem Header="Menu Item..1" IsCheckable="True" />  
    </ContextMenu>  
    <Style x:Key="ColumnHeaderStyle" 
           TargetType="{x:Type toolkit:DataGridColumnHeader}">  
        <Setter Property="ContextMenu" 
                Value="{StaticResource ColumnHeaderContextMenu}" />  
    </Style>  
    <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />  
</UserControl.Resources>  
Run Code Online (Sandbox Code Playgroud)

... flaf flaf flaf

<toolkit:DataGrid x:Name="MyGrid" AutoGenerateColumns="False" 
    ItemsSource="{Binding MyCollection, Mode=Default}" 
    EnableColumnVirtualization="True" IsReadOnly="True" 
    ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">  
    <toolkit:DataGrid.Columns>  
        <toolkit:DataGridTextColumn Binding="{Binding Path=MyEntry}" 
            Header="MyEntry" Visibility="{Binding IsChecked, Converter=
                {StaticResource booleanToVisibilityConverter}.... />
    </toolkit:DataGrid.Columns>     
</toolkit:DataGrid>  
Run Code Online (Sandbox Code Playgroud)

如果我不清楚请告诉我,我会尝试详细说明.

干杯,

wpf xaml binding datagrid mvvm

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

每隔X分钟自动触发一次asp.net mvc ajax刷新

我的页面上有一个刷新按钮,它将执行一个asp.net mvc ajax帖子来更新页面上的一些内容.刷新/更新过程可以长时间运行(大约10-20秒).现在,用户必须手动单击"刷新"按钮才能触发刷新.我想每隔X分钟自动触发一次刷新.几乎我想触发下面这个相同的Ajax帖子(显示LoadingElementId也很好).

<% using (Ajax.BeginForm("Refresh", null, 
                   new {userId=Model.UserId},
                   new AjaxOptions { UpdateTargetId = "UserForm", LoadingElementId = "RefreshingDiv" },
                   null))
               {
            %>

                    <button type="submit">
                        <img src="/zsys/img/icons/refresh.png" alt="Refresh" />
                        Refresh
                    </button>

            <% } %>
Run Code Online (Sandbox Code Playgroud)

我如何强制asp.net mvc ajax回发?

asp.net-mvc asp.net-mvc-ajax

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

MySQL查询 - 获取不同的值

有一个表"T",其中包含如下所示的数据:

A   B
---------
3    5   
4    6      
7    10 
8    5 
9    12 
3    6
3    7
8    7
Run Code Online (Sandbox Code Playgroud)

假设给定的输入集{3,8}作为A的值,如何检索输入集中所有值都有条目的B的所有不同值?

B
---
5
7
Run Code Online (Sandbox Code Playgroud)

编辑:我认为问题不够明确.我希望B中的值具有给定集合中所有值的记录作为列A的值.因此,由于没有A = 8且B = 6的记录,因此不会包括B = 6.希望这说清楚!

mysql

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

Windows服务中的WCF安全性

我有一个WCF服务,可以作为控制台应用程序和Windows服务运行.我最近将控制台应用程序复制到具有以下安全设置的W2K3服务器:

<wsHttpBinding>
 <binding name="ServiceBinding_Security" transactionFlow="true" >
  <security mode="TransportWithMessageCredential" >
    <message clientCredentialType="UserName" />
  </security>           
 </binding>             
</wsHttpBinding> 

<serviceCredentials>
 <userNameAuthentication  userNamePasswordValidationMode="Custom" 
  customUserNamePasswordValidatorType="Common.CustomUserNameValidator, Common" />
</serviceCredentials>
Run Code Online (Sandbox Code Playgroud)

安全性正常,没有问题.我有完全相同的代码,但在Windows服务中运行,当我尝试从客户端调用任何方法时,我收到以下错误:

System.ServiceModel.Security.MessageSecurityException was unhandled
Message="An unsecured or incorrectly secured fault was received from 
         the other party. See the inner FaultException for the fault code and detail."
  Source="mscorlib"
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
       ......   
    (lots of stacktrace info - not very useful)

  InnerException: System.ServiceModel.FaultException
       Message="An error occurred when verifying security for the message." …
Run Code Online (Sandbox Code Playgroud)

wcf windows-services wcf-security

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

试图运行这个"我在日期无效的月份"?

我正在尝试对Informix运行以下db命令:

delete from table1
    where u_id in (select u_id
                     from table2
                    where c_id in (select c_id
                                     from ptable
                                    where name = 'Smith'
                                      and dob = '29-08-1946'));
Run Code Online (Sandbox Code Playgroud)

我将此作为字符串传递给MS数据应用程序块中的db.ExecuteNonQuery方法,我得到上述错误?

informix

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

php如何:将会话变量保存为静态类变量

下面的代码工作正常:

<?php session_start();

   $_SESSION['color'] = 'blue'; 

   class utilities
   {
            public static $color;

        function display()
            {
                echo utilities::$color = $_SESSION['color'];
            }

   }
   utilities::display(); ?>
Run Code Online (Sandbox Code Playgroud)

这是我想要但不起作用:

<?php session_start();

$_SESSION['color'] = 'blue'; 

class utilities  {  
     public static $color = $_SESSION['color']; //see here

     function display()     
     {      
         echo utilities::$color;    
     }   } utilities::display(); ?>
Run Code Online (Sandbox Code Playgroud)

我收到此错误: Parse error: syntax error, unexpected T_VARIABLE in C:\Inetpub\vhosts\morsemfgco.com\httpdocs\secure2\scrap\class.php on line 7

Php不喜欢会话变量存储在函数之外.为什么?这是语法问题还是什么?我不想实例化对象,因为只是调用实用程序函数,我需要一些会话变量全局存储.init()每次运行函数时,我都不想调用函数来存储全局会话变量.解决方案?

php session static session-variables

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

当兄弟元素重叠时有效检测

例:

<div id="big">&nbsp;</div>
<div class="small">&nbsp;</div>
<div class="small">&nbsp;</div>
<div class="small">&nbsp;</div>
<div class="small">&nbsp;</div>
<div class="small">&nbsp;</div>
<!-- ...and so on -->
Run Code Online (Sandbox Code Playgroud)

"#big"绝对位于".small"的一部分后面,但不是父元素.

我一直这样做:

           var smallArray = [];

           var $big = $('#big');
           var $bigPos = $big.offset();

           $('div.small').each(function() {
                    var $this = $(this);
                    var $thisPos = $this.offset();

                    if(
                            $thisPos.left >= $bigPos.left &&
                            $thisPos.left <= $bigPos.left+$big.outerWidth() &&
                            $thisPos.top >= $bigPos.top &&
                            $thisPos.top <= $bigPos.top+$big.outerHeight()
                    ) smallArray.push($this);
            });
Run Code Online (Sandbox Code Playgroud)

......但这似乎很糟糕.我是否错过了一些jQuery或vanilla JavaScript的方法,这些方法可以让我以更优雅高效的方式做到这一点?

非常感谢您提供的任何帮助.

jquery siblings

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

不使用鼠标运行NUnit测试?

当我想运行1个测试时,我总是必须右键单击方法声明并单击"运行测试".有没有办法在不使用鼠标的情况下完成此操作?

nunit unit-testing keyboard-shortcuts testdriven.net visual-studio

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