有人可以解释一下下面这个功能的含义吗?对不起,我是VB开发人员,我无法理解下面的语法.转换器工具将其无意义地转换为VB代码.
我不理解Where T的继承
public static string ValidateSeName<T>(this T entity, string seName, string name, bool ensureNotEmpty)
where T : BaseEntity, ISlugSupported
{
}
Run Code Online (Sandbox Code Playgroud)调用此函数的位置,调用函数如下所示.这个T实体的第一个参数发生了什么,它不用作参数?它的目的是什么?
model.SeName = category.ValidateSeName(model.SeName, category.Name, true);
Run Code Online (Sandbox Code Playgroud)
如果你能在VB中给我相同的代码,将会很有帮助.谢谢
我尝试使用嵌套来理解ElasticSearch的索引选项,并且我执行了每个选项,这里是我的结果:
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node, defaultIndex: "mydatabase");
settings.SetTimeout(1800000);
var client = new ElasticClient(settings);
var createIndexResult = client.CreateIndex("mydatabase");
var mapResult = client.Map<Product>(c => c.MapFromAttributes().SourceField(s=>s.Enabled(true));
Run Code Online (Sandbox Code Playgroud)
1)索引:当我通过迭代每个对象使用索引选项时,虽然它很慢但它工作顺利.
foreach (var item in Items)
{
elasticClient.Index(item);
}
Run Code Online (Sandbox Code Playgroud)
2)IndexAsync:这没有任何例外,但它并不比snyc迭代更快,索引的文档也更少.
foreach (var item in Items)
{
elasticClient.IndexAsync(item);
}
Run Code Online (Sandbox Code Playgroud)
3)IndexMany:我试过,elasticClient.IndexMany(items);
当然没有foreach,它比foreach -index选项运行得更快,但不知何故,当我有大量数据(在我的情况下是500.000objects)时,它抛出异常,说
"System.Net.WebException:基础连接已关闭:服务器已关闭其连续预期的连接..在System.Net.HttpWebRequest.GetResponse()"
当我检查日志文件时,我只能看到
"2016年1月14日
10:21:49,567] [WARN] [http.netty] [Microchip]处理客户端http流量时发生异常,关闭连接[id:0x68398975,/ 0:0:0:0:0:0:0:1:57860 =>/0:0:0:0:0:0:0:1:9200]"
4)IndexManyAsync: elasticClient.IndexManyAsync(Items);
尝试indexasnyc抛出与snyc类似的异常,但我可以在日志文件中看到更多信息.
[2016-01-14 11:00:16,086] [WARN] [http.netty] [Microchip]处理客户端http流量时发生异常,关闭连接[id:0x43bca172,/ 0:0:0:0:0:0 …
我应该使用 akavache 作为我的 xamarin 表单应用程序中的主要本地数据库还是另一个 sqlite 数据库之上的缓存数据库?因为我找不到任何关于如何在 akavache 对象中更新、插入、删除数据的示例。例如,
CacheItems= await BlobCache.LocalMachine.GetOrFetchObject<List<Item>>("CacheItems",
async () => await getdatafromAzure(recursive));
Run Code Online (Sandbox Code Playgroud)
我从 azure 获取项目并存储在本地机器中,这些项目是可编辑/可删除的,或者用户可以添加新项目。我该怎么做?
我已经实现了启动屏幕,如下所示我有一个启动活动作为主启动器,它启动 MainActivity
[Activity(Theme = "@style/MyTheme.Splash",
MainLauncher = true,
Immersive = true,
ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait,
NoHistory = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var intent = new Intent(this, typeof(MainActivity));
StartActivity(intent);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的主要活动开始时,我注册了所有应用程序链接并具有意图过滤器,如下所示。
[Activity(Label = "myapp",
Icon = "@drawable/icon",
Theme = "@style/MyTheme",
MainLauncher = false,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "http",
DataHost = "myapp.azurewebsites.net", …
Run Code Online (Sandbox Code Playgroud) 我试图从一个文件夹复制到另一个文件夹,并按照msdn 文章,我试图在我的WPF应用程序上实现asnyc调用.但我不确定我做错了它阻止UI线程,我不认为这第一个样本是asnyc.
这是我的代码
Dim tasks = myImages.Select(Async Function(x)
Dim result As Image
Try
result = Await CopyImage(x, If(cts IsNot Nothing, cts.Token, Nothing))
Catch ex2 As Exception
End Try
ProgressValue += 1
CompletedText = ProgressValue.ToString() & " of " + MaxValue.ToString() & " images completed."
Return result
End Function)
Dim results = Await Task.WhenAll(tasks)
Public Async Function CopyImage(Image As Image, ct As CancellationToken) As Task(Of Image)
If ct.IsCancellationRequested Then
Return Nothing
End If
Await _mutex.WaitAsync()
Dim SourceMainDirectory As String = …
Run Code Online (Sandbox Code Playgroud) c# ×2
vb.net ×2
akavache ×1
android ×1
async-await ×1
c#-to-vb.net ×1
nest ×1
wpf ×1
xamarin ×1