问题列表 - 第49323页

由于构造函数中的"保护级别"错误,C#"无法访问"

子类"caesar"的构造函数给出错误.它说由于其保护级别,名称,类型无法访问.怎么会?因为这是从"Cipher"类派生的子类,所以不应该给出这样的错误.我怎样才能克服这种情况.但我希望这些变量是私有的.我不想将它们改为公开.

***第二个代码示例有效.任何人都能看到差异吗?

namespace Encrypter
{
    class Cipher
    {
        public Cipher(string name, string type)
        {
            setName(name);
            setType(type);

        }
        private string name;
        private string type;

        public void setName(string newName)
        {
            name = newName;
        }
        public string getName()
        {
            return name;
        }
        public void setType(string newType)
        {
            type = newType;
        }
        public string getType()
        {
            return type;
        }
        public string encrypt(string text)
        {
            return text;
        }
        public string decrypt(string text)
        {
            return text;
        }
    }
}




namespace Encrypter
{
    class Caesar : Cipher …
Run Code Online (Sandbox Code Playgroud)

c# inheritance encapsulation access-modifiers

6
推荐指数
3
解决办法
5万
查看次数

如何使用minidom解析unicode字符串?

我正在尝试用库xml.dom.minidom解析一堆xml文件,以提取一些数据并将其放入文本文件中.大多数XML都运行良好,但对于其中一些XML,在调用minidom.parsestring()时会出现以下错误:

UnicodeEncodeError:'ascii'编解码器无法编码位置5189中的字符u'\ u2019':序数不在范围内(128)

它也适用于其他一些非ascii字符.我的问题是:我有什么选择?在解析XML文件之前,我是否应该以某种方式剥离/替换所有非英文字符?

python unicode minidom

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

是否可以使用现有的包而不是再次下载?

我正在开发一个需要新的virtualenv的新项目.当我执行pip install -r requirements.txt时,它会重新下载这些包,即使这些包已经存在于上一个项目的virtualenv中.

有没有办法告诉pip从其他virtualenv获取包?

python pip virtualenv

12
推荐指数
2
解决办法
2239
查看次数

如何从数据库加载java类?

喜欢以下源代码:

package util.abc;
public class Test{
    public String out(){
        return "Hello World!";
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以用:

Class c = Class.forName("util.abc.Test");
Run Code Online (Sandbox Code Playgroud)

获取此类,但我必须将此源文件(Test.java)放在ClassPath中/util/abc/

我想从数据库动态加载这个类(将源代码存储为string,或binary)

这个有可能 ?

感谢帮助 :)

java

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

在Sitemesh中可以多次装饰吗?

我正在尝试做这样的事情: 布局

对于/ admin/*的所有请求,我需要使用B装饰器来装饰页面,但是B装饰器必须包含在作为主应用程序布局的装饰器的内容中.

我怎么能用Sitemesh做到这一点?

它甚至可能吗?或者我必须在B装饰器中重复相同的布局?

提前致谢

layout sitemesh

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

如何从Windows服务将文件复制到网络位置?

我希望在Windows Server 2008服务器上运行Windows服务,该服务器将监视本地服务器上的目录(即C:\ Watch),并在该目录中创建新的pdf时,将该文件复制到网络共享(即.//192.168.1.2/Share).

这两个服务器都不是域的成员.

Windows服务将其登录设置为本地用户帐户,该帐户可以访问// server/share并创建和删除文件.

如果sourceDir和destDir是C:\ Source和C:\ Dest之类的本地文件夹但是如果我将destDir更改为网络位置,如// server/share /或//// server /,我有以下工作正常/ share //我收到错误"T文件名,目录名或卷标语法不正确".

更新: 我不再收到上面的错误,现在当我将sourceDir设置为C:\ Watch并将destDir设置为\ server\share \时(服务器可以是Windows或Ubuntu服务器,我得到一个System.UnauthorizedAccess我假设的错误来自目标服务器.如何设置连接到目标服务器时使用的凭据.请记住,服务器不在域中,可以是Windows或Ubuntu.

public partial class Service1 : ServiceBase
{
    private FileSystemWatcher watcher;
    private string sourceFolder;
    private string destFolder;

    public Service1()
    {
        InitializeComponent();
    }

    protected override void OnStart(string[] args)
    {
        this.sourceFolder = Properties.Settings.Default.sourceDir;
        this.destFolder = Properties.Settings.Default.destDir;

        watcher = new FileSystemWatcher();
        watcher.Path = this.sourceFolder;
        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
        watcher.Filter = "*.pdf";

        watcher.Created += new FileSystemEventHandler(watcher_Created);

        watcher.EnableRaisingEvents = true; …
Run Code Online (Sandbox Code Playgroud)

c# windows-services

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

自定义按钮的前景色(ControlPresenter)

我试图在App.xaml中定义一个全局按钮样式,它主要按照我的预期工作.但是,我只是想不通如何让Foreground正常工作.无论我做什么,我都会得到默认TextBlock的样式(将颜色设置为白色).

    <Style TargetType="{x:Type Button}">
        <Setter Property="Margin" Value="3, 5" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="FocusVisualStyle" 
                Value="{StaticResource ButtonFocusVisual}" />
        <Setter Property="Foreground" Value="Red" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid x:Name="gridMainButton"
                          RenderTransformOrigin="0.5, 0.5">
                        <Grid.RenderTransform>
                            <ScaleTransform x:Name="scaleTransform" 
                                            CenterX="0.5"
                                            CenterY="0.5" />
                        </Grid.RenderTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates" >
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation
                                              Storyboard.TargetName="scaleTransform"
                                              Storyboard.TargetProperty="ScaleX"
                                              Duration="0"
                                              To="0.85" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Ellipse x:Name="ellipse"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Stretch"
                                 StrokeThickness="2"
                                 Stroke="{StaticResource standardBackground}"
                                 Fill="{StaticResource standardBackground}" />
                        <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Margin="4, 8"/> …
Run Code Online (Sandbox Code Playgroud)

wpf controls controltemplate

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

javascript foreach如何与多维数组一起使用?

我正在玩一些javascript,并发现(至少对我来说)通过foreach循环处理多维数组时的奇怪行为.所以我有这段代码:

<script type="text/javascript">
  var arr = [['a', 'b'], ['c','d']];

  var first='';

  for (var singleArray in arr) {
    first += ' ' + singleArray[0] + ' ' + singleArray[1];
  }

  var second = '';
  for (var i=0;i<arr.length; i++) {
    second += ' ' + arr[i][0] + ' ' + arr[i][1];
  }

  console.log('First: ', first);
  console.log('Second: ', second);
</script>
Run Code Online (Sandbox Code Playgroud)

输出是:

First: 0 undefined 1 undefined
Second: a b c d
Run Code Online (Sandbox Code Playgroud)

我希望第一和第二将是相同的.你能解释一下我错过了什么吗?

注意:请不要建议通过jQuery或其他方式迭代数组.我没有编码麻烦,我只是对这种特殊情况感到好奇.谢谢!

javascript arrays

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

".NET应用程序和WCF服务的配置服务"样本是否已准备好生产?

我最近偶然发现了.NET应用程序和WCF服务配置服务.它是微软推出的"StockTrader 4.0"样本的一部分.我想知道是否有人为生产企业应用程序使用或调整了此服务.它是企业准备好的吗?如何与SO-Aware等商业解决方案进行比较.

.net configuration wcf enterprise production

9
推荐指数
0
解决办法
432
查看次数

子类化AS3数组:如何获取数组元素(这[0]不起作用)?

如果我是Array的子​​类,我该如何访问元素?

class ArrayOfFoo extends Array
{
   public function getFooAt(anIndex : int) : Foo
   {
        return this[anIndex] as Foo;   //  <---- looks for an object attribute (named "0", for example)
   }
}
Run Code Online (Sandbox Code Playgroud)

我可以包装一个数组而不是子类化它,但缺少一个通用的IArray接口,这对于期望一个数组的标准和自定义函数来说不太有用.

向量根本不允许子类化,因此它们无济于事.

谢谢

apache-flex arrays actionscript-3

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