我正在尝试将json注入我的backbone.js应用程序.我的json有"每个报价.
有没有办法让我删除它?
我在下面提供了一个示例:
[{"Id":1,"Name":"Name}]
Run Code Online (Sandbox Code Playgroud) 我试图了解backbone.js的一部分是如何工作的.应用程序开始后,我必须获取一组模型.我需要等到fetch完成才能呈现每个视图.我不是百分百肯定在这个例子中采取的最佳方法.
var AppRouter = Backbone.Router.extend({
routes: {
"": "home",
"customer/:id": "customer"
},
home: function () {
console.log("Home");
},
customer: function (id) {
if (this.custromers == null)
this.init();
var customer = this.customers.at(2); //This is undefined until fetch is complete. Log always says undefined.
console.log(customer);
},
init: function () {
console.log("init");
this.customers = new CustomerCollection();
this.customers.fetch({
success: function () {
console.log("success");
// I need to be able to render view on success.
}
});
console.log(this.customers);
}
});
Run Code Online (Sandbox Code Playgroud) 我想了解以下内容:
如果我声明64字节作为数组长度(缓冲区).当我转换为基数为64的字符串时,它表示长度为88.长度不应该只有64,因为我传递的是64字节?我完全可能误解了这个实际的工作方式.如果是的话,请你解释一下.
//Generate a cryptographic random number
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
// Create byte array
byte[] buffer = new byte[64];
// Get random bytes
rng.GetBytes(buffer);
// This line gives me 88 as a result.
// Shouldn't it give me 64 as declared above?
throw new Exception(Convert.ToBase64String(buffer).Length.ToString());
// Return a Base64 string representation of the random number
return Convert.ToBase64String(buffer);
Run Code Online (Sandbox Code Playgroud) 我在课堂上学习加入,但我并没有完全掌握一些概念.有人可以解释具有多个连接的语句是如何工作的吗?
SELECT B.TITLE, O.ORDER#, C.STATE FROM BOOKS B
LEFT OUTER JOIN ORDERITEMS OI ON B.ISBN = OI.ISBN
LEFT OUTER JOIN ORDERS O ON O.ORDER# = OI.ORDER#
LEFT OUTER JOIN CUSTOMERS C ON C.CUSTOMER# = O.CUSTOMER#;
Run Code Online (Sandbox Code Playgroud)
我相信我理解BOOKS表是连接BOOKS和ORDERITEMS的第一个外连接中的左表.即使书中没有ORDERITEM,也会显示所有BOOKS.第一次加入后,我不确定到底发生了什么.
当ORDERS加入时,左表是哪个表,哪个是右表?对于客户来说也一样.这是我迷路的地方.
一个同事有一个对象,上面有一堆通用的列表集合.列表中的每种类型都实现给定的接口.他希望能够创建一个包含所有其他列表的列表,这样他就可以遍历并调用对象实现的方法.下面是一个简单的例子.
List<Dx> dxs = new List<Dx>();
dxs.Add(new Dx());
dxs.Add(new Dx());
List<Proc> procs = new List<Proc>();
procs.Add(new Proc());
List<List<IClean>> lists = new List<List<IClean>>();
lists.Add(procs); // Error here
lists.Add(dxs); // Error here
foreach (List<IClean> list in lists)
{
foreach (IClean i in list)
{
i.Clean();
}
}
Run Code Online (Sandbox Code Playgroud)
Dx和Proc都实现了IClean.这是目标.这样的事情可能吗?或者,这是不好的编程?
.NET版本4.0
我的IVehicle接口上有一个名为Color的属性.如果我希望每个实现该界面的车辆都具有默认颜色"红色",我怎么能实现这一目标?我需要另一个级别吗?
public interface IVehicle
{
string Color { get; set; }
void Go();
void Stop();
}
public class Bmw : IVehicle
{
#region IVehicle Members
public string Color
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void Go()
{
}
public void Stop()
{
}
#endregion
}
Run Code Online (Sandbox Code Playgroud) 我对此很陌生,所以如果问题没有意义,我会提前道歉.
如果我是正确的,c#中的int是4个字节.如果我有声明:
int x;
Run Code Online (Sandbox Code Playgroud)
我认为这占用了4个字节的内存.如果每个存储器地址空间是1个字节,那么这将占用四个地址槽?如果是这样,x如何映射到四个地址位置?
我正在尝试使用AE.Net.Mail获取邮箱列表,但我找不到任何文档.ListMailboxes方法接受引用字符串和模式字符串.我不确定这两个参数应该是什么.
using (var imap = new AE.Net.Mail.ImapClient(host, username, password, AE.Net.Mail.ImapClient.AuthMethods.Login, port, isSSL))
{
List<Mailbox> boxes = imap.ListMailboxes("", ""); // string reference, string parameter
}
Run Code Online (Sandbox Code Playgroud) 我在backbone.js中看过一些例子,它说初始模型集应该被引导到页面中而不是去取它.这一点是有道理的.出于某种原因,我无法弄清楚如何使用asp.net mvc应用程序.我在下面开了一个简单的例子.
控制器动作:
public ActionResult Index()
{
CustomerRespository repository = new CustomerRespository();
ViewModel model = new ViewModel();
model.Customers = repository.GetAll();
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
View Model:这里我创建了将我的客户列表注入应用程序所需的json.
public List<Customer> Customers { get; set; }
public string CustomerJson
{
get
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(this.Customers);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的视图中解码json:
@{ string s = HttpUtility.HtmlDecode(Model.CustomerJson); }
Run Code Online (Sandbox Code Playgroud)
在backbone.js app中调用collection.reset():
this.customers = new CustomerCollection();
this.customers.reset("@s");
Run Code Online (Sandbox Code Playgroud)
出于某种原因,这似乎无法正常工作.
我无法弄清楚我的查询在这里做错了什么.
SELECT ORDER#, SUM(PAIDEACH * QUANTITY) AS TOTAL
FROM ORDERITEMS
WHERE TOTAL > 39.9
GROUP BY ORDER#
ORDER BY TOTAL DESC;
Run Code Online (Sandbox Code Playgroud)
这是我不断得到的错误:
"TOTAL": invalid identifier
Run Code Online (Sandbox Code Playgroud) c# ×6
asp.net ×3
javascript ×3
sql ×2
asp.net-mvc ×1
asynchronous ×1
backbone.js ×1
bits ×1
byte ×1
database ×1
email ×1
interface ×1
oop ×1
oracle ×1