我需要将这个且只有一个AJAX控件的功能移植到MVC,但鉴于MVC控件的选择很差,我认为我需要将这个传统控件带入MVC世界......
我宁愿不用ASP.NET控件来修改我的MVC项目,也欢迎你知道的json/MVC替代品.(如果你知道的话,发布它们)
我在ASP.NET MVC中需要的示例UI

回到移植
虽然是不幸的,我留下来移植这种控制,MVC,这似乎是一个被广泛接受的做法,因为Telerik的有详细的说明就如何做到这一点.
这让我问:
MVC网站使用ASP.NET控件有多常见?
我再次提到我不想这样做,所以我欢迎MVC特定的替代方案.话虽这么说,我将继续尝试将该控件与我现有的网站合并.</End Disclaimer>
如果你单击这个超链接,并查看底部的源代码,你能告诉我应该在MVC中放置以下内容吗?
代码背后(我的第一直觉是使用Controller,但另一个SO问题表明我应该创建一个创建一个ViewName.aspx.cs文件)
如何将SQLDataSource移植到新的"模型"思维方式.我知道它们本质上是不同的,但我不知道如何以消耗信息的方式向ASP.NET控件提供数据.
我如何处理AJAX组件?此控件具有使用回调的AJAX组件.是的,这很难看,但似乎我必须这样做.
显然,此模型将数据保存在会话或视图状态中.我不知道这是否适用于MVC.非常感谢指导,备用控制或救生圈.
我已经完成了研究,并在这里 和Telerik的指示中描述了如何开始放置一个简单的菜单,但是我需要一些辅助来处理像这样的更复杂的控件.
注意:对于遇到此问题的所有评论,请记住我只想要这一个 ASP.NET控件功能; 我在MVC中找不到类似的控件.
asp.net-mvc telerik sqldatasource asp.net-mvc-3 asp.net-mvc-2
我在.NET 3.5下使用TrimEnd()获得了不一致的结果.TrimEnd看起来好像很简单,有什么我在这里做错了或者这是一个bug
成功案例
var foundvalue = "hosted.local.chatter.com";
Console.WriteLine(foundvalue.TrimEnd(".chatter.com".ToCharArray()));
// Result is "hosted.local" which is expected.
Run Code Online (Sandbox Code Playgroud)
失败案例
var foundvalue = "hosted.local.chattermailcom";
Console.WriteLine(foundvalue.TrimEnd(".chattermailcom".ToCharArray()));
// Result is "hosted" which is incorrect
Run Code Online (Sandbox Code Playgroud) 对该计划的观察:
通过该程序缓慢按F11不会显示每次执行 ProcessURL()
通过此程序快速按F11可显示更多的执行 ProcessURL()
Thread.Sleep(3000);在ProcessURL中使用会导致MainUI线程挂起大约30秒.没有UI重绘,取消按钮不可用.
需求:

码
namespace ProcessTasksAsTheyFinish
{
public partial class MainWindow : Window
{
// Declare a System.Threading.CancellationTokenSource.
CancellationTokenSource cts;
public MainWindow()
{
InitializeComponent();
}
private async void startButton_Click(object sender, RoutedEventArgs e)
{
resultsTextBox.Clear();
// Instantiate the CancellationTokenSource.
cts = new CancellationTokenSource();
try
{
await AccessTheWebAsync(cts.Token);
resultsTextBox.Text += "\r\nDownloads complete.";
}
catch (OperationCanceledException)
{
resultsTextBox.Text += "\r\nDownloads canceled.\r\n";
}
catch (Exception)
{
resultsTextBox.Text += "\r\nDownloads failed.\r\n";
}
cts = null;
} …Run Code Online (Sandbox Code Playgroud) 此MSDN页面具有以下示例:目的是包装无法在各种Func<T1, T2, T3>重载中表示的APM样式任务.
static Task<String> ReturnTaskFromAsyncResult()
{
IAsyncResult ar = DoSomethingAsynchronously(); // <-- If this is an APM method, it's a bad example since most APM methods have a parameter for callback and state.
Task<String> t = Task<string>.Factory.FromAsync(ar, _ =>
{
return (string)ar.AsyncState;
});
return t;
}
Run Code Online (Sandbox Code Playgroud)
我的问题与这个功能有关DoSomethingAsynchronously();.我见过的大多数APM函数都需要参数回调和状态,这在本示例中缺失.
问题: "DoSomethingAsynchronously"中的回调和状态参数会发生什么
要正确调用与此类似的函数,我需要做什么?在我的情况下,我试图像这样包装Azure表调用
Task CreateAsync(CloudTable tbl, CancellationToken token, object state)
{
ICancellableAsyncResult result = tbl.BeginCreate(null, state); // Incorrect
token.Register((o) => result.Cancel(), state);
Task<bool> t = Task.Factory.FromAsync(result, _ …Run Code Online (Sandbox Code Playgroud) 我记得读过有关某些数学运算和类型的问题double,但我忘了它们何时会发生,或者我需要如何处理它们.
"比特币"是一个有8个小数位的浮点数.我假设我使用它们键入double它,而不是任何其他类型(十进制等).它是否正确?
在编写,调试和测试使用8个小数点的应用程序时,我应该考虑哪些其他问题?
我正在尝试调试一些位移操作,我需要在Bit-Shifting操作之前和之后可视化位.
我从这个答案中读到,我可能需要处理来自变换的回填,但我不确定这意味着什么.
我想通过提出这个问题(我如何打印int中的位)我可以弄清楚回填是什么,也许我还有其他一些问题.
这是我到目前为止的示例代码.
static string GetBits(int num)
{
StringBuilder sb = new StringBuilder();
uint bits = (uint)num;
while (bits!=0)
{
bits >>= 1;
isBitSet = // somehow do an | operation on the first bit.
// I'm unsure if it's possible to handle different data types here
// or if unsafe code and a PTR is needed
if (isBitSet)
sb.Append("1");
else
sb.Append("0");
}
}
Run Code Online (Sandbox Code Playgroud) 我从Web服务收到以下JSON.如何在Netwtonsoft中解析以下JSON?
{ "file/folder": "/Shared/Salesforce/asdf.txt" }
^^^^^^^^^^
^^^^^^^^^^
^^^^^^^^^^---that is my problem
Run Code Online (Sandbox Code Playgroud)
请注意,字段名称具有正斜杠,当用作字段名称时,该斜杠对于C#无效.(Newtownsoft在JSON名称和C#字段之间进行自动映射)
我的代码是
JsonSerializerSettings set = new JsonSerializerSettings();
List<UserAudit> usrs = JsonConvert.DeserializeObject<List<UserAudit>>(statusResult );
foreach (var item in usrs)
{
Console.WriteLine(item.username + " " + item.ip_address);
}
Run Code Online (Sandbox Code Playgroud)
注意所有NewtownSoft需要的是C#中Javascript对象的名称.它处理所有转换.
public class UserAudit
{
public string username;
public string filefolder; // <----- HOW DO I SET THIS VARIABLE? "file/folder" is invalid
public string transaction;
public string access;
public string time;
}
Run Code Online (Sandbox Code Playgroud)
其他研究
我查看了重载,JsonConvert.DeserializeObject<List<UserAudit>>(statusResult);并没有看到重命名或重新格式化数据的直接方法.我查看了JsonSerializerSettings和JsonConverters.
假设我有以下WCF代码:
try
{
ServiceClient proxy = new ServiceClient();
proxy.ClientCredentials.UserName.UserName = "user";
proxy.ClientCredentials.UserName.Password = "password";
proxy.GetData(2);
if (proxy.State = CommunicationState.Opened)
{
proxy.GetData("data");
}
proxy.Close();
}
catch (FaultException ex)
{
// handle the exception
}
Run Code Online (Sandbox Code Playgroud)
而且因为我注意到try ... catch和其他逻辑是重复的,更不用说设置WCF调用是昂贵的,我想向这个函数发送许多"方法和参数".
本质上是传递GetData(2)和GetData("data")作为方法数组,并使结果异步或同步返回.
我怎么做到这一点?
我想我可以有两个'ref'对象来处理结果[]和对结果[]的共享锁.但是我不确定如何将"带参数的方法"作为参数传递给另一个函数.
也许另一种看待它的方法可能是一个函数指针数组,使用不同的参数来表示相同的函数.
任何人都可以推动我做正确的方法吗?
更多信息:
我问这个问题所以我可以优化这种方法来处理WCF异常和重试,但所以我不必总是在每次调用后打开/关闭客户端.
我需要在UNUserNotificationCenterDelegate中使用iOS 10功能。如何在c#/ Xamarin中实现此委托?
我有一个像这样定义的单例:
public partial class MoonDataManager
{
static MoonDataManager _singletonInstance;
public static MoonDataManager SingletonInstance
{
get
{
return _singletonInstance;
}
private set
{
_singletonInstance = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个安全地创建实例的函数:
public static async Task<MoonDataManager> CreateSingletonAsync()
{
_singletonInstance = new MoonDataManager();
Run Code Online (Sandbox Code Playgroud)
我是不是该:
return _singletonInstance; (field)
Run Code Online (Sandbox Code Playgroud)
要么
return SingletonInstance; (property)
Run Code Online (Sandbox Code Playgroud)
我关心垃圾收集,特别是在Xamarin的iOS或Android中.
如果在C#中有这样的命名模式,请告诉我是否偏离了标准.
更新:
现在我觉得我真的陷入了线程和异步方法的困境.以下是对象及其目标:
MoonDataManager:RegisterTable<Models.IssuerKey>每个表运行一次.这是一种基本上运行的通用方法(new MobileServiceSQLiteStore).DefineTable<T>()
OfflineStore:这是一个MobileServiceSQLiteStore.
MobileClient:这是一个MobileServiceClient.
MoonDataManager依赖关系:MoonDataManager要求OfflineStore和MobileClient完成初始化.具体来说,它执行MobileServiceClient.SyncContext.InitializeAsync(OfflineStore)
我不确定如何理解这种依赖关系的意义...或者如何使代码看起来很好,并且是线程安全的.
这是代码的新迭代:
private readonly Lazy<MobileServiceClient> lazyMobileClient =
new Lazy<MobileServiceClient>(() => …Run Code Online (Sandbox Code Playgroud) c# garbage-collection xamarin.ios xamarin.android automatic-ref-counting
c# ×8
xamarin.ios ×2
.net ×1
.net-3.5 ×1
.net-4.5 ×1
asp.net-mvc ×1
async-await ×1
asynchronous ×1
azure ×1
bit-shift ×1
bitcoin ×1
bits ×1
closures ×1
debugging ×1
delegates ×1
double ×1
json ×1
json.net ×1
performance ×1
pointers ×1
string ×1
telerik ×1
trim ×1
wcf ×1
xamarin ×1