我想在Visual Studio 2010的解决方案资源管理器的特定文件类型的上下文菜单中添加一个新选项.因此,例如,右键单击*.cs文件将显示现有的上下文菜单以及"我的新选项".
我想知道代码会是什么样的; 并且喜欢指向开发visual studio插件的良好参考指针.我看到的教程/参考文章非常可怕.
谢谢!
我有一个System.Diagnostics.Process
对象.我的C#程序正在监视某些情况.当条件被命中时,我想要获取进程的完整内存转储.
实现这一目标的最佳方法是什么?
有没有CLR提供的方法?
我正在反序列化一个名为Method
.NET Serialization 的类.Method
包含实现的对象列表IAction
.我最初使用该[XmlInclude]
属性来指定实现的所有类IAction
.
但是现在,我想改变我的程序来加载目录中的所有dll并删除实现的类IAction
.然后,用户可以反序列化包含其实施的操作的文件IAction
.
我不再控制实现的类IAction
,因此我无法使用[XmlInclude]
.
有没有办法在运行时设置此属性?或者为实现类设置了类似的属性?
public class Method
{
public List<Actions.IAction> Actions = new List<Actions.IAction>();
}
public interface IAction
{
void DoExecute();
}
public static Type[] LoadActionPlugins(string pluginDirectoryPath)
{
List<Type> pluginTypes = new List<Type>();
string[] filesInDirectory = Directory.GetFiles(pluginDirectoryPath, "*.dll", SearchOption.TopDirectoryOnly);
foreach (string pluginPath in filesInDirectory)
{
System.Reflection.Assembly actionPlugin = System.Reflection.Assembly.LoadFrom(pluginPath);
Type[] assemblyTypes = actionPlugin.GetTypes();
foreach (Type type in assemblyTypes)
{
Type …
Run Code Online (Sandbox Code Playgroud) 我需要花几个小时来了解Azure Service Bus架构.我特别想知道这种排队技术是否可用于支持消息路由 - 类似于RabbitMQ的路由功能. http://www.rabbitmq.com/tutorials/tutorial-four-python.html
我们将使用直接交换.直接交换背后的路由算法很简单 - 消息进入队列,其绑定密钥与消息的路由密钥完全匹配.
在此设置中,我们可以看到直接交换X与两个绑定到它的队列.第一个队列绑定橙色绑定,第二个绑定有两个绑定,一个绑定密钥为黑色,另一个绑定为绿色.
在这样的设置中,使用路由密钥orange发布到交换机的消息将被路由到队列Q1.路由键为黑色或绿色的消息将转到Q2.所有其他消息将被丢弃.
寻找对服务总线体系结构有深刻理解的人,以推荐实现此类队列的最佳向量.
我正在运行一个控制台应用程序(myApp.exe),它将一个伪本地化(unicode)字符串输出到标准输出.如果我在常规命令提示符(cmd.exe)中运行此命令,则unicode数据将丢失.如果我在unicode命令提示符(cmd.exe/u)中运行它或将控制台的属性设置为"Lucida Console",则会保留unicode字符串.
我想在C#中运行此应用程序并将unicode字符串重定向到本地变量.我正在使用RedirectStandardOutput = true的Process对象,但unicode字符串总是丢失.
如何指定保留此unicode信息?
private static int RunDISM(string Args, out string ConsoleOutput)
{
Process process = new Process();
process.StartInfo.FileName = "myApp.exe";
process.StartInfo.Arguments = Args;
try
{
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
process.Start();
process.WaitForExit(Int32.MaxValue);
}
catch (Exception e)
{
WEX.Logging.Interop.Log.Assert("Failure while starting or running process.\nERROR: " + e.Message);
ConsoleOutput = null;
return EXITCODE_ERROR;
}
ConsoleOutput = process.StandardOutput.ReadToEnd();
return process.ExitCode;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用C#VS2008中的Xml数据源编写数据驱动的单元测试.
属性看起来像这样,一切都很棒.
[DeploymentItem("HtmlSchemaUrls.xml")]
[DataSource("DataSource", "Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\HtmlSchemaUrls.xml", Microsoft.VisualStudio.TestTools.WebTesting.DataBindingAccessMethod.Sequential, "URL")]
[DataBinding("DataSource", "URL", "URL_Text", "DataSource.URL.URL_Text")]
[TestMethod]
Run Code Online (Sandbox Code Playgroud)
我想扩展Microsoft.VisualStudio.TestTools.DataSource.XML数据源的功能,最好通过App.config进行配置.例如,一个bool,当我运行Xml文件中的所有行时为true,而当为false时,我只运行一个.
我不想在测试用例本身中执行此检查 - 我有1000个具有此要求的测试用例.
任何有关如何实现这一目标的指导都将非常受欢迎.
String.GetHashCode的行为取决于程序架构.因此它将在x86中返回一个值,在x64上返回一个值.我有一个必须在x86中运行的测试应用程序,它必须预测必须在x64上运行的应用程序的哈希码输出.
下面是mscorwks中String.GetHashCode实现的反汇编.
public override unsafe int GetHashCode()
{
fixed (char* text1 = ((char*) this))
{
char* chPtr1 = text1;
int num1 = 0x15051505;
int num2 = num1;
int* numPtr1 = (int*) chPtr1;
for (int num3 = this.Length; num3 > 0; num3 -= 4)
{
num1 = (((num1 << 5) + num1) + (num1 >? 0x1b)) ^ numPtr1[0];
if (num3 <= 2)
{
break;
}
num2 = (((num2 << 5) + num2) + (num2 >> 0x1b)) ^ numPtr1[1];
numPtr1 += 2; …
Run Code Online (Sandbox Code Playgroud) 我想知道从Windows注册表通过标准C#库读取注册表值需要多长时间(以毫秒为单位).在这种情况下,我正在阅读一些代理设置.
我应该期望什么数量级的值?有没有好的基准数据?
我正在运行WS2k8 R2 amd64.加分:OS sku /版本对此措施有多大影响?
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software/Copium"))
{
return (string)registryKey.GetValue("BinDir");
}
Run Code Online (Sandbox Code Playgroud) 我有一个从外部来源获取的 ISO 3166 两个字母国家/地区代码列表。对于每个,我创建
new System.Globalization.RegionInfo(countryCode)
Run Code Online (Sandbox Code Playgroud)
有时,其中一个无效,导致出现 ArgumentException“不支持区域性名称 'xx'”。
我想要一个函数来确定国家/地区代码在将其传递给构造函数之前是否有效。这是我的尝试:
private bool IsCultureValid(string cultureName)
{
return CultureInfo.GetCultures(CultureTypes.AllCultures)
.Any(c => c.Name.Equals(cultureName, StringComparison.InvariantCultureIgnoreCase));
}
Run Code Online (Sandbox Code Playgroud)
该函数对许多输入返回假阴性(函数返回 false,但如果我尝试,我可以使用该输入创建一个 RegionInfo 对象)。一些输入:
我缺少什么?这里有更好的方法吗?提前致谢!
c# ×7
xml ×2
api ×1
asp.net ×1
azure ×1
command-line ×1
console ×1
cultureinfo ×1
datasource ×1
gethashcode ×1
graph-theory ×1
iso ×1
memory-dump ×1
performance ×1
plugins ×1
process ×1
reflection ×1
region ×1
registry ×1
unicode ×1
wysiwyg ×1
xul ×1