小编Nic*_*ert的帖子

在Visual Studio 2015中清除"最近的项目"列表

有谁知道如何清除VS2015起始页上的最近项目列表?显然VS2015在注册表中没有MRU文件,我找不到有关如何清除2015版本列表的任何教程.谢谢!

visual-studio visual-studio-2015

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

Visual Studio,Python不自动缩进

这可能是一个简单的问题,但我的Visual Studio Python工具出了问题.当我第一次开始使用VS2015 for Python时,只要我使用冒号就会自动缩进.现在VS2015就像一个带有语法高亮的文本编辑器.我尝试卸载并重新安装Python工具,但这不起作用.当我再次编写Python时,如何将Visual Studio修复为自动样式?

python visual-studio visual-studio-2015

17
推荐指数
2
解决办法
9208
查看次数

为什么Python类不能识别静态变量

我试图用Python创建一个静态变量和方法(属性和行为)的类

import numpy

class SimpleString():    
    popSize = 1000 
    displaySize = 5
    alphatbet = "abcdefghijklmnopqrstuvwxyz "

    def __init__(self):
        pop = numpy.empty(popSize, object)
        target = getTarget()
        targetSize = len(target)
Run Code Online (Sandbox Code Playgroud)

代码运行虽然它说它不能使数组弹出,因为没有定义popSize

python oop variables static class

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

在 MIPS 中迭代和修改字符串

我正在尝试编写一种方法来对 MIPS 汇编语言中的文本字符串进行凯撒移位。我的加密方法如下:

encryptMessage:
    la $s0, message     #s0 will hold message that will be iterated through
    lw $t1, key     #s1 will hold the key to shift by
    li $t0, 0       #t0 will be iterator, starting at 0

encryptionLoop:
    add $s1, $s0, $t0   #$s1 = message[i]
    lb $s2, 0($s1)      #Loading char to shift into $s2
    beq $s2, $zero, exit    #Breaking the loop if we've reached the end: http://stackoverflow.com/questions/12739463/how-to-iterate-a-string-in-mips-assembly
    add $s2, $s2, $t1   #Shifting the character by the key amount
    la $s1, …
Run Code Online (Sandbox Code Playgroud)

string assembly loops mips

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

无法重塑numpy数组

我有一个函数应该采用一维整数数组并将其形成一个1x3数组的2D数组.然后它应该采用每个1x3阵列并将其转换为3x1阵列.结果应该是3x1阵列的2D数组.这是我的功能

def RGBtoLMS(rgbValues, rgbLength): #Method to convert from RGB to LMS
    print rgbValues
    lmsValues = rgbValues.reshape(-1, 3)
    print lmsValues
    for i in xrange(len(lmsValues)):
        lmsValues[i] = lmsValues[i].reshape(3, 1)

    return lmsValues
Run Code Online (Sandbox Code Playgroud)

当我尝试将1x3阵列更改为3x1阵列时,问题就出现了.假设rgbValues = [14,25,19,24,25,28,58,87,43],我得到以下输出

[14 25 19 ..., 58 87 43]
[[14 25 19]
 [24, 25, 28]
 [58 87 43]]

ValueError [on line lmsValues[i] = lmsValues[i].reshape(3, 1)]: could not broadcast input array from shape (3,1) into shape (3)
Run Code Online (Sandbox Code Playgroud)

我怎样才能避免这个错误?

python numpy multidimensional-array reshape

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

TypeConverters的依赖注入

我有一个我正在设计的应用程序,它引用了我正在设计的库.具体来说,应用程序需要创建我的较低级库中定义的Sheathing类的实例.

[TypeConverter(typeof(SheathingOptionsConverter))]
public class Sheathing : Lumber
{
    public string Description { get; set; }

    public Sheathing(string passedDescription)
    {
        Description = passedDescription;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序在属性网格中列出了不同的护套选项.因为它在下拉菜单中列出它们所以我必须将ExpandableObjectConverter扩展两次.第一级向下是我的SheathingObjectConverter,它正确显示单个Sheathing对象

public class SheathingObjectConverter : ExpandableObjectConverter
{
    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
    {
        if (destinationType == typeof(Sheathing))
        {
            return true;
        }
        return base.CanConvertTo(context, destinationType);
    }

    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
    {
        if (sourceType == typeof(string))
        {
            return true;
        }
        return base.CanConvertFrom(context, sourceType);
    }

    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, …
Run Code Online (Sandbox Code Playgroud)

.net c# dependency-injection typeconverter

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

ASP.NET:发布网站不发布Resources文件夹

我有一个用ASP.NET开发的网站.我正在使用Visual Studio 2015.当我右键单击并点击发布网站时,该网站会正确发布,但我的资源文件夹会被遗忘.下面是Visual Studio中解决方案资源管理器的样子

在此输入图像描述

但是我在这里发布之后是放在Azure上的文件(通过FileZilla访问)

在此输入图像描述

如何告诉Visual Studio将Resources文件夹与网站的其余部分一起发布?

c# asp.net azure visual-studio-2015

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

实体框架6以编程方式连接到Postgres

我正在使用Entity Framework 6以编程方式建立与PostgresSQL的连接.我有这个类:

public class ClearspanDatabaseContext : DbContext
Run Code Online (Sandbox Code Playgroud)

使用此构造函数:

public ClearspanDatabaseContext()
    : base(buildConnectionString())
{
}
Run Code Online (Sandbox Code Playgroud)

这是以编程方式创建连接字符串的静态方法:

private static string buildConnectionString()
{
    RegisterDbProvider("Npgsql", ".Net Framework Data Provider for Postgresql", "Npgsql Data Provider", "Npgsql.NpgsqlFactory, Npgsql");
    EntityConnectionStringBuilder entityConnectionStringBuilder = new EntityConnectionStringBuilder();
    entityConnectionStringBuilder.Provider = "Npgsql";
    entityConnectionStringBuilder.ProviderConnectionString = "host=192.168.168.140;Port=5432;username=ClearspanDevLogin;password=*******;database=ClearspanWebServerDev";
    return entityConnectionStringBuilder.ToString();
}
Run Code Online (Sandbox Code Playgroud)

这里是将Npgsql注册为数据库提供程序的方法,取自此:

public static bool RegisterDbProvider(string invariant, string description, string name, string type)
{
    try
    {
        DataSet ds = ConfigurationManager.GetSection("system.data") as DataSet;
        foreach (DataRow row in ds.Tables[0].Rows)
        {
            if (row["InvariantName"].ToString() == invariant) …
Run Code Online (Sandbox Code Playgroud)

entity-framework connection-string database-connection npgsql entity-framework-6

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

将预先存在的AutoCAD图形插入当前图形中

我正在尝试以编程方式将预先存在的绘图中的块插入到运行插件的当前绘图中.为此,我在C#.NET表单上有一个按钮,调用以下方法

public void MakeAndInsertObject() //Method to add all windows and doors templates to drawing database for use later
{
    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; //Stores the active document
    Editor ed = doc.Editor; //Stores the document's editor
    Database dtb = ed.Document.Database; //Stores the database from the editor

    Transaction tr = dtb.TransactionManager.StartTransaction(); //Start a transaction with the document's database
    DocumentLock docLock = doc.LockDocument();

    using (tr)    
    using (docLock)
    {
        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(dtb.CurrentSpaceId, OpenMode.ForWrite); //Opens the block table record so you can write to …
Run Code Online (Sandbox Code Playgroud)

.net c# autocad-plugin

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

设置字符串提示的默认值

编辑器类有一个名为GetString的方法,它通过AutoCAD的命令提示符提示用户输入字符串值.我在这个包装器方法中调用它:

public static string PromptUserForString(string message = "Enter a string: ", string defaultAnswer = "")
{
    return _editor.GetString("\n" + message).StringResult;
}
Run Code Online (Sandbox Code Playgroud)

参数消息成为用户在提示输入字符串时看到的消息.如何设置它以使默认答案的值自动设置为答案,以便如果用户立即进入,则会变为如下面的屏幕截图中的值

在此输入图像描述

因此,1会自动输入为答案,这意味着用户可以按Enter键输入值1或将1更改为他们想要的任何非默认答案

.net c# autocad autocad-plugin

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