小编Ron*_*Dex的帖子

如何在Windows应用商店应用中使用WCF时禁用Expect:100-Continue

Expect: 100-Continue在Windows Store App中使用WCF与WebService进行通信时,我需要删除HTTP消息中的标头.我找到了很多解决方案,但在Windows 8中没有一个是可能的:

  1. ServicePoint.Expect100Continue = false;商店应用程序中不再存在(No SericePointServicePointManagerclass),
  2. 我无法更改web.config文件中的配置,因为它在Store App中不存在,
  3. HttpClient使用WCF时,可以更改标志,但我无法访问它,
  4. 我尝试使用消息头进行操作IClientMessageInspector,但是稍后会在更高层中添加默认的HTTP标头,因此我的更改将是ovverriden.

有没有人有任何其他想法?

c# wcf

6
推荐指数
1
解决办法
2813
查看次数

如何定义 XmlSerializer 使用的区域性

我使用以下代码反序列化 xml 配置文件:

// Create object by deserializing the given xml document
var serializer = new XmlSerializer(typeof(ConfigurationFile));
var stream = File.Open(path, FileMode.Open, FileAccess.Read);
var configFile = serializer.Deserialize(stream);
Run Code Online (Sandbox Code Playgroud)

在配置中,我定义了一些浮点数,如下所示:

每日阈值=“41.9”

作为小数点分隔符“.” 是否依赖于文化我想知道如何定义序列化器用来解析这些数字的文化?

c# localization xml-serialization

5
推荐指数
1
解决办法
6851
查看次数

如何在ASP.NET页面中抽象属性

我正在使用aspx表单.我们所做的是我们为每种形式声明属性.代码就在最后

所以我想如果我们可以拥有一个包含所有类似内容的基类,但由于表单已经继承了Page类,我们在C#中没有多重继承,所以我们可以使用interface实现这一点我是新手哎呀请告诉我有可能.

public partial class Default2 : System.Web.UI.Page
{
    public string ImagePath { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net

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

将 CSS 精灵用于图像类型的输入

我正在创建一个引用图像的 ImageButton,其中包含多个图标。我试图通过定位背景图像来显示正确的图标,但这不起作用。这是我创建的方式ImageButton

ImageButton closeButton = new ImageButton();
closeButton.CommandName = "CloseItem";
closeButton.ID = "BtnClose";
closeButton.Width = 16;
closeButton.Height = 16;
closeButton.ImageUrl = "/_layouts/15/1031/images/formatmap16x16.png?rev=23.gif";
closeButton.Style.Add(HtmlTextWriterStyle.Top, "-115");
closeButton.Style.Add(HtmlTextWriterStyle.Left, "-275");
closeButton.OnClientClick = btn.OnClientClick;
this.Controls.Add(closeButton);
Run Code Online (Sandbox Code Playgroud)

这导致以下 HTML:

<input type="image" 
       name="ctl00$ctl40$g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80$ctl00$toolBarTbl$RightRptControls$ctl02$BtnClose" 
       id="ctl00_ctl40_g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80_ctl00_toolBarTbl_RightRptControls_ctl02_BtnClose" 
       src="/_layouts/15/1031/images/formatmap16x16.png?rev=23.gif" 
       onclick="STSNavigate('http:\u002f\u002fespseis13\u002fsharechange\u002fdefault.aspx');return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl40$g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80$ctl00$toolBarTbl$RightRptControls$ctl02$BtnClose&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" 
       style="height:16px;width:16px;top: -115px;left: -275px">
Run Code Online (Sandbox Code Playgroud)

我显示的图像是这样的:

在此处输入图片说明

我不能轻易切换输入类型,因为它需要属性CommandName = "CloseItem" 有谁知道,我如何移动(而不是缩放!)由input类型引用的图像image

html css asp.net html-input sharepoint-2013

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

为什么这个 switch case 返回一个 double 即使它是一个 int?

给出以下代码:

object value = header.DataContentType switch
{
    DataContentType.DOUBLE => (double)BitConverter.ToDouble(currentValueBytes.ToArray()),
    DataContentType.FLOAT => (float)BitConverter.ToSingle(currentValueBytes.ToArray()),
    DataContentType.BYTE => (byte)contentData[i],
    DataContentType.SHORT => (short)BitConverter.ToInt16(currentValueBytes.ToArray()),
    DataContentType.INTEGER => (int)BitConverter.ToInt32(currentValueBytes.ToArray()),
    DataContentType.LONG => (long)BitConverter.ToInt64(currentValueBytes.ToArray()),
    _ => throw new InvalidDataException("Invalid data type"),
};
Run Code Online (Sandbox Code Playgroud)

现在,在header.DataContentTypeis 的情况下DataContentType.INTEGER,该值被分配为 double tovalue而不是 anint(int)value导致 InvalidCastException

如果我调试,我可以清楚地看到它进入INTEGER案例,如果我BitConverter.ToInt32(currentValueBytes.ToArray())在调试控制台中评估,我会返回一个整数。然而,只要 switch case 退出,变量value的类型就是 double。

此外,如果我手动执行value = BitConverter.ToInt32(currentValueBytes.ToArray())变量是正确的类型int。由于某种奇怪的原因,暗示 switch 语句必须将类型更改为 double 。

我希望 switch case 返回返回的任何类型BitConverter。如何使BitConverter返回正确 BitConverter …

c# switch-statement .net-core

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

Regex.Replace无法按预期使用Regexoptions.IgnoreCase

如果我有几个字符串:

str = "This is a cool string (orch. details here): 2. Denied."
str2 = " (Orch. details here)" <--notice the capital letter
Run Code Online (Sandbox Code Playgroud)

然后我做这行代码试图清除那部分:

str3 = Regex.Replace(str, str2, "", RegexOptions.IgnoreCase);
Run Code Online (Sandbox Code Playgroud)

str3最终完全像str执行前一样.我怀疑它是不是"看到"其他人物,如周期,因为当我做这与只是简单的字母strstr2那么它将取代它就好了.

是什么赋予了?!:)

感谢您的任何见解!

.net c# regex

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

忽略foreach循环中特定类型的项目

我试图取消选中菜单中所有可检查的ToolStripMenuItem项目

foreach (ToolStripMenuItem item in filtersMenu.DropDownItems)
{
   item.Checked = false;
}
Run Code Online (Sandbox Code Playgroud)

ToolStripMenuItem都可以检查,但问题是编译器给出了InvalidCastException,循环也试图对ToolStripSeparator项目进行操作,如何解决这个问题,任何帮助都将不胜感激,谢谢.

c# winforms drop-down-menu

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