我做了一些谷歌搜索,似乎jRuby的IDE很少.我已经阅读了有关TextMate和Sublime的内容,但它们没有提供调试或代码完成.
有人可以提出建议(或者这项技术还处于起步阶段)?
MSDN在Func Generic Delegate上的文章中给出了这个代码示例:
Func<String, int, bool> predicate = ( str, index) => str.Length == index;
String[] words = { "orange", "apple", "Article", "elephant", "star", "and" };
IEnumerable<String> aWords = words.Where(predicate).Select(str => str);
foreach (String word in aWords)
Console.WriteLine(word);
Run Code Online (Sandbox Code Playgroud)
我明白这一切是做什么的.我不明白的是
Select(str => str)
Run Code Online (Sandbox Code Playgroud)
位.当然不需要吗?如果你把它留下来就可以了
IEnumerable<String> aWords = words.Where(predicate);
Run Code Online (Sandbox Code Playgroud)
然后你仍然得到一个包含相同结果的IEnumerable,并且代码打印相同的东西.
我错过了什么,或者是误导性的例子?
我遇到了这个问题中描述的问题: 无法转换类型异常的COM对象 ,表现为错误:
无法将"System .__ ComObject"类型的COM对象强制转换为接口类型"IMyInterface".此操作失败,因为对于具有IID"{GUID}"的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口
我的WPF应用程序正在调用最终调用COM对象的.NET库.这工作正常,但它在主线程上运行并阻止UI.当我生成一个新线程并从中调用库时,我收到了这个错误.在另一个问题上,这些解决方案都没有对我有用.我试图了解运行时如何加载类型信息,但不能在线程之间共享它.
我知道WPF应用程序是STA,我知道这意味着在线程之间移动的任何对象都将被COM编组.我不明白类型信息如何说"这是一个COM对象,它的GUID就是这个"可以在AppDomain中,但是第二个线程无法访问.
加载类型信息在哪里?它在AppDomain中,还是每个线程?无论如何,我如何让线程共享类型信息?我怎样才能解决这个问题?
我读过这个:
http://www.codeproject.com/Articles/9190/Understanding-The-COM-Single-Threaded-Apartment-Pa
and this:
http://msdn.microsoft.com/en-us/ library/ms973913.aspx#rfacomwalk_topic10
和一些其他讨论COM互操作的东西,但没有帮我修复它.
根据Hans Passant的回答,我在第二个STA线程中创建了我的库对象:
var thread = new Thread(delegate()
{
var aeroServer = new AeroServerWrapper(Config.ConnectionString);
var ct = new CancellationToken();
aeroServer._server.MessageReceived += ServerMessageReceived;
aeroServer.Go(@"M:\IT\Public\TestData\file.dat", ct);
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
Run Code Online (Sandbox Code Playgroud)
我知道我可能需要调用Application.Run()来启动消息队列,如果事件无法触发但是我没有那么远:它一旦尝试创建COM对象就会崩溃.AeroServerWrapper位于一个单独的DLL中,该DLL调用第二个DLL,最终尝试实例化COM对象.
任何提示或文章将不胜感激.我想解决这个问题:我的计划B是将库包装在控制台应用程序中,从UI生成控制台应用程序,并通过命名管道从中获取状态消息.那会起作用,但看起来很难看.
我想制作一个水平排列项目的ListBox.每个项目都应该是一个TextBox,它应该垂直填充列表框,无论文本有多少.如果您使用过Tweetdeck,我的目标是产生类似的效果.这是我得到的:
<ListBox
Background ="DarkGray"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ItemsSource="{Binding Path=Items}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="5" Margin="2,0,2,0">
<Grid Width="250">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Stretch"
Text="{Binding Path=Messages, Mode=OneWay}" />
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
会发生什么是TextBox固执地适合文本,而不是垂直拉伸.我试过为DockPanel切换网格,这没有帮助.我可以绑定TextBox的Height属性,但这看起来很不愉快.
我错过了这个诀窍吗?
我想根据是否定义了值来更改Wix变量的值。在我的wixproj中,我有:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'TFS Live|x86' ">
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
<WixVariables>LIVE</WixVariables>
<DefineConstants>LIVE</DefineConstants>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
...在我的wx中,我有:
<?ifdef LIVE ?>
<?define binaryPath = "C:\Builds\5\IT Aerodynamics\RBT.TestSpec.LiveRelease\Binaries" ?>
<?else?>
<?define binaryPath = "C:\Builds\5\IT Aerodynamics\RBT.TestSpec.CI\Binaries" ?>
<?endif?>
Run Code Online (Sandbox Code Playgroud)
...但是当我构建适当的配置时,ifdef永远不会触发。我总是得到的第二个值binaryPath。关于我在做什么错的任何建议吗?
我正在玩XNA.当我单击鼠标左键时,我会记录X,Y坐标.按住鼠标按钮,移动鼠标会从此原点绘制一条线到当前鼠标位置.我将它偏移到了窗口的中间.
现在,我想做的是将鼠标光标限制在一个圆圈内(半径为N,以屏幕中间为中心).将鼠标限制在矩形区域很容易(通过鼠标位置和区域大小的差异来调整原点),但我还没有找到如何开始为圆形区域进行操作的线索.
任何人都可以解释如何做到这一点?任何关于从哪里开始的建议都会有所帮助.
我最近从SVN商店搬到了使用TFS的地方.在旧的地方,我在检查后进入了检查我的项目到一个新文件夹的例程,所以我可以在那里单独构建它,并检查我没有忘记包含任何文件等.
在TFS中,显而易见的方法似乎是更改我的项目映射到的本地路径,"获取最新版本",然后再次更改映射的文件夹.这看起来有点笨重.有没有更好的方法让我失踪?
(是的,理想情况下,会有一个门禁登记,一个构建服务器和所有mod-cons,但暂时我会用一种简单的方法来检查我是否犯了错误.)
我正在使用NDatabase来做一些非常简单的对象存储 - 基本上构建一个持久的工作队列.计划是创建一组对象,将它们保存到磁盘,然后在其中一个属性上读取它们.我无法使"已排序"部分工作 - NDatabase抛出异常.
这是我想要持久化的对象的超类型:
public abstract class Instruction: IComparable, IComparable<Instruction>
{
public virtual DateTime Timestamp
{
get;
set;
}
public int CompareTo(Instruction other)
{
if (this.Timestamp.Equals(other.Timestamp))
return 0;
return (this.Timestamp < other.Timestamp) ? -1 : 1;
}
public int CompareTo(object obj)
{
var other = obj as Instruction;
return other == null ? -1 : this.CompareTo(other);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我创建对象存储的方式:
using (var odb = OdbFactory.Open(storeName))
{
odb.IndexManagerFor<Instruction>().AddIndexOn("TimestampIndex", "Timestamp");
foreach (var instruction in instructions)
{
odb.Store(instruction);
}
odb.IndexManagerFor<Instruction>().RebuildIndex("TimestampIndex");
}
Run Code Online (Sandbox Code Playgroud)
以下是如何在以后检索商店: …