我想隐藏intellisense成员列表中的公共方法.我创建了一个属性,当应用于方法时,将导致在构造对象时调用该方法.我这样做是为了更好地支持部分课程.问题是在某些环境(例如Silverlight)中,反射无法访问私有成员,甚至是子类的私有成员.这是一个问题,因为所有工作都是在基类中完成的.我必须将这些方法设为公开,但我希望它们不受intellisense的影响,类似于Obsolete属性的工作原理.坦率地说,因为我是关于对象封装的肛门.我尝试了不同的东西,但实际上没有任何效果.该方法仍显示在成员下拉列表中.
当我不希望客户端调用公共方法时,如何防止公共方法出现在intellisense中?对于一个真正的问题,非利士人怎么样!这也适用于必须公开的MEF属性,但有时您希望将它们从客户端隐藏.
更新: 自从发布此问题以来,我已成熟为开发人员.为什么我如此关心隐藏界面是在我之外.
这是一个多线程的可扩展HttpListener的一个很好的例子吗?
这是一个真正的IIS会这样做吗?
public class Program
{
private static readonly HttpListener Listener = new HttpListener();
public static void Main()
{
Listener.Prefixes.Add("http://+:80/");
Listener.Start();
Listen();
Console.WriteLine("Listening...");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
private static async void Listen()
{
while (true)
{
var context = await Listener.GetContextAsync();
Console.WriteLine("Client connected");
Task.Factory.StartNew(() => ProcessRequest(context));
}
Listener.Close();
}
private static void ProcessRequest(HttpListenerContext context)
{
System.Threading.Thread.Sleep(10*1000);
Console.WriteLine("Response");
}
}
Run Code Online (Sandbox Code Playgroud)
我特意寻找一种不依赖于IIS的可扩展解决方案.而只是在http.sys(这是httplistener类) - 不依赖于iIS的原因是因为政府.我工作的区域需要极大减少的攻击面积.
我有这行代码:
@Html.EditorFor(model => model.Quantity, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
Run Code Online (Sandbox Code Playgroud)
我的视图数据字典中有一个名为Readonly的变量.如果ViewBag.Readonly为true,我如何将Quantity设为只读,如果为false则不读取?
简单的事情,但Razor与HTML(古老)的结合使得其他简单的事情变得不可能.
编辑:
我不想使用if语句.这是最后的手段,因为它违反了DRY,我过去曾经多次严重烧伤因为没有跟随.
我上面的这一行确实有效,因为它使文本框只读.我需要根据我的视图状态制作这个条件.
解:
我使用了以下内容.它仍然是DRY违规,但它将它减少到一行.
@Html.EditorFor(model => model.Quantity, new { htmlAttributes = ViewBag.Readonly ? (object)new { @class = "form-control", @readonly = "htmlsucks" } : (object)new { @class = "form-control" } })
Run Code Online (Sandbox Code Playgroud) 由于某种原因,以下代码生成不包含声明的XML:
XDocument xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("project",
new XAttribute("number", project.ProjectNumber),
new XElement("store",
new XAttribute("number", project.StoreNumber)
),
// User Element
new XElement("user",
new XAttribute("owner-id", project.OwnerID ?? 0),
new XElement("email", new XCData(project.OwnerEmail ?? "")),
new XElement("project-name", new XCData(project.ProjectName ?? ""))
),
// Nested Project Element
new XElement("nested-project",
new XAttribute("version", new Version(1, 0)),
new XElement("project",
new XAttribute("version", new Version(1, 0)),
xProjectItems = new XElement("project-items")
),
new XElement("price-per-part", project.PricePerPart),
new XElement("sheet-quantity", project.SheetQuantity),
new XElement("edge-length", project.EdgeLength),
new XElement("price", project.Price),
new XElement("status", …Run Code Online (Sandbox Code Playgroud) 有没有办法过滤出Fiddler中的某些过程?它目前非常嘈杂,我不希望它只显示一个过程.
每隔一段时间我就会在Blend for Visual Studio中获得编译器异常.一切都在编译和工作奇妙,然后突然BAM!我收到编译器错误,告诉我对象在特定的命名空间中不存在.我必须玩清洁和重建,关闭和重新开放Blend一个小时才能离开.我的图书馆都是最新的,一切都很好.没有其他人会发生这种情况吗?拜托,我希望它能阻止它是一个巨大的时间杀手.
我也在Visual Studio中得到编译器错误.
谢谢.
更新
例如,
错误5 XML名称空间" http://schemas.microsoft.com/expression/blend/2008 " 中不存在属性"DesignWidth ".第15行位置5. C:\ MyPath\MyControl.xaml 15 5 EasyBuilder
据我所知,DesignWidth该命名空间中确实存在很多.
XAML(不是它会帮助你)
<UserControl x:Name="UserControl" x:Class="EasyBuilder.MainControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ignore="http://www.ignore.com"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:surface="http://schemas.microsoft.com/surface/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:local="clr-namespace:EasyBuilder"
xmlns:res="clr-namespace:EasyBuilder.Infrastructure.Resources"
xmlns:system="clr-namespace:System;assembly=mscorlib"
d:DesignWidth="640" d:DesignHeight="480">
<UserControl.Resources>
<res:MainViewStrings x:Key="LocalStrings" />
</UserControl.Resources>
<UserControl.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"/>
</UserControl.DataContext>
<Grid x:Name="LayoutRoot" Background="{DynamicResource PageBackgroundBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OpenSelectionStateGroup">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.15">
<VisualTransition.GeneratedEasingFunction>
<CircleEase EasingMode="EaseOut"/>
</VisualTransition.GeneratedEasingFunction>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="SelectionClosedState"/>
<VisualState x:Name="SelectionOpenedState">
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="OpenFileSelection">
<DiscreteBooleanKeyFrame KeyTime="0" Value="False"/> …Run Code Online (Sandbox Code Playgroud) 考虑以下因素:
[Export]
public class BudgetView : ViewBase, IView
{
// Members Galore
}
Run Code Online (Sandbox Code Playgroud)
很明显,你会说BudgetView 延伸 ViewBase,它实现 IView,但它对穷人有Export什么影响?
也许BudgetView 用 Export?或BudgetView 适用 Export?
我的文档需要这个.我需要非常正式和非常详细.
编辑:

我的UML工具对我能做什么和不能做什么都非常严格.例如,我无法制作自定义构造型.
我有一种情况,我在我的代码中启动一个进程,以便建立一个IPC通道.我正在开始的过程是一个没有CLR支持的MFC应用程序.我开始这个过程的应用程序是WPF应用程序中的C#模块(我认为这不是我的问题的结果).这适用于支持CLR的应用程序版本,它适用于除部署目标之外的每台计算机,Windows 7的触摸屏计算机.但出于某种原因,当我尝试使用此确切方案时,Process对象永远不会解析主窗口句柄(Process.MainWindowHandle).这样做有另一种(甚至是pinvoke)方法吗?这是安全的事吗?我是那个盯着这个过程的人.进程的主窗口句柄确实存在.我看不出有什么不对.
如果它有帮助,这是我的代码.
_applicationProcess = new Process();
_applicationProcess.StartInfo.FileName = _strProcessPath;
_applicationProcess.StartInfo.Arguments = _strProcessArguments;
_applicationProcess.Start();
long nTicks = Environment.TickCount;
if (_applicationProcess.WaitForInputIdle(1 /*minute(s)*/ * 60000))
{
try
{
do
{
// Don't let total processing take more than 1 minute(s).
if (Environment.TickCount > nTicks + 1 /*minute(s)*/ * 60000)
throw new ApplicationException("MFCApplication.Startup failed! The main window handle is zero!");
_applicationProcess.Refresh();
}
while (_applicationProcess.MainWindowHandle.ToInt32() == 0);
_applicationHandle = new IntPtr(_applicationProcess.MainWindowHandle.ToInt32());
}
catch (Exception ex)
{
//Do some stuff...
throw;
}
} …Run Code Online (Sandbox Code Playgroud) 在visual studio 2010中,有没有办法制作特定于单个项目或解决方案的片段?我有兴趣这样做,以便我可以使用它们来支持我的架构决策(即创建一个以规定的方式实现某个接口的POCO).
c# ×5
.net ×3
process ×2
wpf ×2
asp.net-mvc ×1
async-await ×1
attributes ×1
fiddler ×1
filtering ×1
html5 ×1
intellisense ×1
ipc ×1
linq-to-xml ×1
mfc ×1
mouseevent ×1
reflection ×1
task ×1
xml ×1