小编Yar*_*evi的帖子

CloudBlobContainer.ListBlobs() - 使用 ToList() 降低交易成本

我有两个代码示例:

var container = new CloudBlobContainer("address");
var blobs = container.ListBlobs();
foreach (var blob in blobs)
{
    //Do somthing
}
Run Code Online (Sandbox Code Playgroud)

和这个 :

var container = new CloudBlobContainer("address");
var blobs = container.ListBlobs().ToList();
foreach (var blob in blobs)
{
     //Do somthing
}
Run Code Online (Sandbox Code Playgroud)

第二个例子会在“交易方面”提供任何优势吗?
在每个示例中,对 blob 存储进行了多少事务?

c# azure azure-storage azure-storage-blobs

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

Silverlight 5 + AutoCompleteBox = Bug

刚刚安装了几天前发布的SL5和工具包.
将AutoCompleteBox的Text属性设置为string.Empty时会发生错误.它导致AutoCompleteBox处于错误状态.重现错误:

将AutoCompleteBox和Button添加到主页面.注册TextChanged和Click事件.这是代码隐藏:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        auto.Text = string.Empty;
    }

    private void auto_TextChanged(object sender, RoutedEventArgs e)
    {
        // Put a break point here.
    }
} 
Run Code Online (Sandbox Code Playgroud)

在运行时:

1)在自动装箱中输入"aa".

2)单击按钮.

3)键入"q".(仍调用TextChanged).

4)擦除"q" - 不调用TextChanged .

5)再次输入"q" - 不调用TextChanged .

6)依此类推,直到你选了一封新信.然后它重新开始.

autocomplete silverlight-toolkit autocompletebox silverlight-5.0

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

将动态DataTable转换为List <Dictionary <string,string >>

我想要一个优雅的方式来获取像这样的DataTable:

在此输入图像描述

把它变成:

List<Dictionary<string,string>> values = dataTable.ToDictionary();
Run Code Online (Sandbox Code Playgroud)

列表中的每个字典对应一行.字典包含行的值,其中键是列名称,值是列值.

该方法应支持动态列数和名称.

c# datatable dictionary todictionary

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

React Native - 如何使用DEV = FALSE从xcode在iOS设备上运行

在连接的iPhone上运行我的react本机应用程序时,我看到该应用程序正在使用DEV = TRUE运行: 在此输入图像描述

我正在运行应用程序,打开xcode项目文件,然后按播放按钮.

我怎么能这样做,但让它运行DEV = false?

xcode reactjs react-native

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

用反射产生迭代器

我有一个数据类学生,我有一个聚合类学生.Student有两个类型为string的属性:Name和City.

我想要做的是选择使用foreach机制选择要迭代的属性.

我写的代码有效,它也可读,外观漂亮.主要问题是性能:我使用yield关键字的行可能不是很有效,但问题是多少?这是戏剧性的表现吗?

有没有更好的方法来实现此功能?(补充:我不想让某人修改返回的Student对象,所以所提出的所有Linq解决方案都不好.为了更清楚,我想要:
属性迭代+ foreach机制集成+ Student类和列表学生是只读的.我怎样才能实现这一目标?)

static void Main(string[] args)
    {           
        Students students = new Students();

        students.AddStudent(new Student { Age = 20, Name = "Stud1" , City="City1" });
        students.AddStudent(new Student { Age = 46, Name = "Stud2" , City="City2"});
        students.AddStudent(new Student { Age = 32, Name = "Stud3" , City="City3" });
        students.AddStudent(new Student { Age = 34, Name = "Stud4" , City="city4" });

        students.PropertyToIterate = eStudentProperty.City;
        foreach (string studentCity in students)
        {
            Console.WriteLine(studentcity);
        }

        students.PropertyToIterate = eStudentProperty.Name;
        foreach (string …
Run Code Online (Sandbox Code Playgroud)

c# reflection iterator yield

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

Array和ArrayList的位置访问性能

我刚看了这个代码示例:http: //robaustin.wikidot.com/how-does-the-performance-of-arraylist-compare-to-array

导致j = INT_ARRAY [i]的原因; 比j = ARRAY_LIST.get(i)快三倍

我知道ArrayList内部使用一个数组.所以我想详细了解这次添加的额外操作(调用方法,转换,其他JVM注意事项等).

提前致谢.

java arrays performance arraylist

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

Swift - 检查日期是否在下周/下个月。( isDateInNextWeek() isDateInNextMonth() )

我们在日历中有这些方便的功能:

let calendar = NSCalendar.currentCalendar()
calendar.isDateInToday(date)
calendar.isDateInTomorrow(date)
Run Code Online (Sandbox Code Playgroud)

但我错过了这两个:

  • calendar.isDateInNextWeek(日期)

  • calendar.isDateInNextMonth(date)

正如@Rob 所提到的,意思是:“在即将到来的星期日开始的日历周中,经过下一个星期六”

我很难弄清楚如何以涵盖所有极端情况的稳健方式实现这些功能。

有人可以提供助手吗?

xcode nsdate nscalendar swift

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

带有异步/等待的节点 - 如何获取发生错误的特定行?

我在节点中有一个函数,如下所示:

async someFlow() {
        try {
            func1();
            func2();
            await getSomeData();
            func3();
        }
        catch (e) {
            sentryIo.captureException(e);
        }
    }
Run Code Online (Sandbox Code Playgroud)

和 getSomeData() 看起来像这样:

async getSomeData() {
        //... some code
        await pgPromise.one('select * from some bad syntax') // line 351!!
        //... some code
    }
Run Code Online (Sandbox Code Playgroud)

当 pgPromise(用于与 PostgreSQL 对话的库)抛出错误时,错误的堆栈跟踪仅包含内部行号发生错误的 pgPromise 库。

因此,当错误被捕获并记录到 Sentry.io 服务时,我无法知道错误的确切行。

我如何才能使错误包含在告诉我错误发生在第 351 行的堆栈跟踪中

node.js async-await pg-promise

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

Dapper - Bulk insert of new items and get back new IDs

I am using dapper to add multiple new students in one db hit using this method:

db.ExecuteAsync(@"INSERT Student(Name,Age) values (@Name,@Age)", 
  students.Select(s => new { Name = s.Name, Age = s.Age })
);
Run Code Online (Sandbox Code Playgroud)

But the problem I don't have the new ids.

Can I make one db hit and still some how get the new ids ?
And if not, what is the most efficient way of performing such bulk insert ?

sql bulkinsert c#-4.0 dapper dapper-extensions

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

Swift - 如何初始化NSDate属性的默认值?

我有一个简单的类定义:

class Course{

    var date:NSDate

    init(){

    }
}
Run Code Online (Sandbox Code Playgroud)

例如,在c#中,创建此类时,date属性的默认值为DateTime.MinValue.

  • 我不想让这个NSDate?因为根据我的业务逻辑,这个属性是必须的,每个课程都有一个日期.(设置为NSDate?意味着课程可以在没有日期的情况下存在)

  • 我不想将它设置为Now,因为它具有误导性.现在可能是一个有效的值,来自我的业务逻辑的其他部分.

我怎样才能在swift中做同样的事情?

datetime nsdate default-value swift

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