我有这段代码是从VB.NET转换而来的.
private static void PrivateExecuteNonQuery(ref Providers enumProvider, ref string statement, ref CommandType commandType, ref ArrayList paramCollection, ref IDbConnection conn, ref Int16 CommandTimeout)
{
ExecuteSqlServerNonQuery(ref statement, ref commandType, ref paramCollection, ref (SqlConnection)conn, ref CommandTimeout);
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误,因为它说ref(SqlConnection)conn不是变量的形式,所以我猜你不能传递ref的方法参数?
所以这对我来说似乎是一个hacky解决方案:
private static void PrivateExecuteNonQuery(ref Providers enumProvider, ref string statement, ref CommandType commandType, ref ArrayList paramCollection, ref IDbConnection conn, ref Int16 CommandTimeout)
{
SqlConnection sqlConnection = (SqlConnection)conn;
ExecuteSqlServerNonQuery(ref statement, ref commandType, ref paramCollection, ref sqlConnection, ref CommandTimeout);
}
Run Code Online (Sandbox Code Playgroud)
有谁知道更好的方法来满足这个参考或使这个更清洁?
在TFS中重命名文件夹的正确方法(步骤顺序)是什么?我尝试在本地做然后提交,但它不起作用.我认为你不得不从TFS(服务器端)做到这一点,而不是吗?但是,如果你这样做并获得最新的,那么我想它只是在本地更新你的文件夹,希望你没有任何其他冲突?
好的,首先通过查看此网址听我说:
http://api.flickr.com/services/feeds/photos_public.gne?format=json
注意Description字符串如何在其中包含非编码的html,例如<,>等.
以下是我使用ASP.NET 3.5和C#返回JSON的方法:
context.Response.ContentType = "text/plain";
context.Response.Charset = Encoding.UTF8.ToString();
int i = 1;
List<Product> products = GetTestProducts();
List<CrImageList> imageList = new List<CrImageList>();
foreach(Product p in products)
{
string imageTag = HttpUtility.HtmlEncode(string.Format(@"<img src=""{0}"" alt="""">", ImageUrl(p.Image, false)));
imageList.Add(new CrImageList{ImageTag = imageTag});
i++;
}
string jsonString = imageList.ToJSON();
context.Response.Write(jsonString);
Run Code Online (Sandbox Code Playgroud)
以下是此代码返回的JSON,当我点击我的.ashx时调用它,并在包含它的方法中调用此代码:
[{"ImageTag":"<img src="http://www.ourdomain.com/image/540.jpg" alt="">"},{"ImageTag":"<img src="http://www.ourdomain.com/image/642.jpg" alt="">"}]
Run Code Online (Sandbox Code Playgroud)
现在,我如何才能将编码后的字符实际显示为我的JSON返回的文本字符串中的html字符?
我希望<to show <等等,就像Flickr能够用他们的JSON一样.
如果我拿出HtmlEncode:
string.Format(@"",ImageUrl(p.Image,false));
然后我开始在我的字符串中获取/ u00:
[{"ImageTag":"\u003cimg src=\"http://www.example.com/cat_image/540.jpg\" alt=\"\"\u003e"},
...
Run Code Online (Sandbox Code Playgroud)
那么为什么Flickr的JSON在其描述中没有返回任何干净的HTML?
自定义控件可以使用它来渲染span标记:
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.Write(Text);
writer.RenderEndTag();
Run Code Online (Sandbox Code Playgroud)
好的,为什么我不能这样做:
writer.Write("<span>");
writer.Write(Text);
writer.Write(</span>");
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我实际上可以看到它而不是在整个地方读取HtlmlTextWriter标记,并且还可以轻松地调整任何标记,例如向标记添加cs类,id或whaetver.如果你说由于Intellisense打字速度更快,这是使用RenderBegin和RenderEnd的唯一原因吗?这不是一个案例.
var allProductIDs = [5410, 8362, 6638, 6758, 7795, 5775, 1004, 1008, 1013, 1014, 1015, 1072, 1076, 1086, 1111, 1112, 1140];
lastProductID = 6758;
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我得到-1或我猜这相当于没有找到这个:
alert(allProductIDs[allProductIDs.indexOf(lastProductID));
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我的生命因为它应该找到6758而那将是索引3.如果它是索引3那么我应该回到6758我会想.
是否有可能以某种方式做到这一点而不取出@?它不喜欢@
cJavaScript.AppendFormat(@"
function GetNextProductIDs(state)
{
var productIDs = new Array();
var {0}lastProductFoundIndex = $.inArray({0}lastProductID, {0}allProductIDs);
return productIDs.join();
}; ", ClientID);
Run Code Online (Sandbox Code Playgroud) 这与.NET有关.我决定使用Web服务参考而不是Web服务...我认为虽然下面的问题确实适用于这两种情况,但我想尝试全面了解这一点.
所以这是我的问题. 我先来解释一下我来自哪里.在过去的一个项目中,我之前通过创建手动类(例如GetPicturesRequest.cs和GetPicturesResponse.cs)与一些API进行了交谈,例如,它将为我保留状态.我有一个名为Request.cs的基类,它实际发送了api调用:
Stream requestStream;
Stream responseStream;
XmlDocument doc = new XmlDocument();
doc = CreateRequestXML();
// Determins if API call needs to use a session based URI
string requestURI = UseAuthURI == true ? _requestURIAuthBased + JSessionID : _requestURI;
byte[] data = XmlUtil.DocumentToBytes(doc);
// Create the atual Request instance
HttpWebRequest request = CreateWebRequest(requestURI, data.Length);
request.ContentLength = data.Length;
request.KeepAlive = false;
request.Timeout = 30000;
// Send the Request
requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
Run Code Online (Sandbox Code Playgroud)
现在我想使用Web服务参考.所以我指出并在VS 2008中创建了对https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl的新引用.我现在有一个Web引用.
我现在有这些问题作为第一次使用Web服务而不是手动操作,因为我使用的是第三方API:
1) …
我听说有一个问题或某种方式你必须设置IIS才能同时运行.NET 2.0和.NET 3.5站点?
配置站点框架时,我们在下拉列表中看不到.NET 3.5选项.
我没有使用hotcopy来备份我的Subversion存储库.我们使用Visual SVN Server(最新)与乌龟.我复制了C:\ Repositories并在几天前备份了,现在我想恢复它.
我现在可以使用存储库并复制备份的Repository文件夹.
然后我想现在我已经手动浏览了团队中每个人的本地项目,看看谁有修改?如果是这样,我将花费数小时.
谁知道这是正确的方式还是唯一的方式?真的是这本手册吗?我想这将是因为每个人都在本地有不同的变化.
当我清楚地调用这个单例并且它应该调用Logger()来设置filename变量时,我无法弄清楚为什么我一直在文件名上获得null ref:
public class Logger
{
private static Logger defaultLogger = null;
readonly string filename;
public static Logger DefaultLogger
{
get
{
// Check for valid instance
if (defaultLogger == null)
defaultLogger = new Logger();
// Return instance
return defaultLogger;
}
}
private Logger()
{
filename = ConfigurationManager.AppSettings["MyLogPath"];
}
public string Filename
{
get { return this.filename; }
}
public void Write(EntryType type, string data)
{
lock (this)
{
using (StreamWriter writer = new StreamWriter(filename, true))
{
//do something
} …Run Code Online (Sandbox Code Playgroud) asp.net ×4
c# ×3
.net-2.0 ×1
.net-3.5 ×1
iis-7 ×1
javascript ×1
svn ×1
tfs ×1
tfs2010 ×1
tortoisesvn ×1
web-services ×1