小编Ron*_*rby的帖子

Windows窗体应用程序设置的问题

我已经使用Visual Studio为Windows窗体应用程序中的应用程序设置生成一个类.调试时,应用程序设置不会填充值.为什么没有价值观?

这是生成的代码:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Unidata_Client.Properties {


    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {

        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

        public static Settings Default {
            get {
                return defaultInstance;
            }
        }

        [global::System.Configuration.UserScopedSettingAttribute()]
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Configuration.DefaultSettingValueAttribute("blah")]
        public string UnidataUsername {
            get …
Run Code Online (Sandbox Code Playgroud)

.net c# visual-studio

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

nhibernate插入问题 - 有id而不是实体对象

使用NHibernate我需要将实体插入到具有子实体的数据库中.例:

public class Reservation
{
    public int Id { get; set; }
    public Service Service { get; set; }
}

public class Service
{
    public int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我需要创建一个新的预留并插入它.但是,在构建预留插入时,我没有服务实体,但我确实有服务的Id值.有没有办法在不先获取服务的情况下插入我的预订?

.net c# nhibernate orm

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

c#lambda表达式+反思问题

这主要是出于教育目的.我正在尝试创建在此示例中使用的InputMapper类:

var mapper = new InputMapper<SomeType>();
mapper.Map("some user input", someType => someType.IntProperty, "Input was not an integer");
mapper.Map("some user input", someType => someType.BoolProperty, "Input was not a bool");

SomeType someTypeInstance = mapper.CreateInstance();
Run Code Online (Sandbox Code Playgroud)

我的InputMapper类包含使用Map()方法创建的所有映射的集合.CreateInstance()将遍历映射,尝试转换用户输入并将其分配给lambda表达式中使用的属性.当它循环时,它将保存抛出的任何FormatExceptions的集合.

我的问题是:

  • 在InputMapper.Map()方法中,lambda参数类型应该是什么?
  • 在InputMapper.CreateInstance()方法中,如何尝试在我创建的T实例上设置属性?

谢谢!

更新

斯凯特博士要求提供有关我的意图的更多信息.

InputMapper类将用于将用户输入分配给任何对象的成员,负责将用户输入转换为属性类型.可以从上面的示例推断出类的接口.

更新2

握了几手,乔恩和丹,把我带到了那里.你能建议改进吗?这就是我所拥有的:http://pastebin.com/RaYG5n2h

.net c# reflection lambda

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

我可以在Visual Studio 2010中折叠foreach,using和其他c#代码块吗?

我可以在Visual Studio 2010中折叠foreach,using和其他c#代码块,就像我可以折叠方法,属性,类,命名空间等一样吗?有时它会非常有用.

.net c# visual-studio-2010 visual-studio

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

如何绑定到silverlight中的页面属性?

我在代码隐藏中有一个带有布尔属性的silverlight页面.

在xaml中我有一个tabcontrol,其中一个tabitem的内容是一个忙碌的指示符.

我想将busyindicator的isbusy属性绑定到代码隐藏中的boolean属性,但无论我使用什么绑定语句,我都无法解析它.

.net c# silverlight wpf xaml

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

实体框架4.1 - 如何使DbContext实体可序列化

我正在使用EF4.1 DbContext代码生成,它会创建像这样的POCO实体:

public partial class Employee
{
    public Employee()
    {
        this.Roles = new HashSet<Role>();
    }

    public System.Guid EmployeeGUID { get; set; }
    public string EmployeeID { get; set; }
    public string PIN { get; set; }
    public string FullName { get; set; }
    public string FirstName { get; set; }
    public string MiddleName { get; set; }
    public string LastName { get; set; }
    public string JobTitle { get; set; }
    public string DepartmentDescription { get; set; }
    public Nullable<System.DateTime> …
Run Code Online (Sandbox Code Playgroud)

.net entity-framework workflow-foundation entity-framework-4.1

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

c#模式问题

我不知道还有什么可以标题这篇文章,所以如果你有一个更好的标题,随时编辑.


我有两个类:Form和Field.

Form有一个名为Fields的属性,它是Field对象的List.

表单有一个名为Prefix的属性.

Field有一个方法需要使用包含它的Form的Prefix属性.

这是我现在正在做的事情:

class Form
    {
        private List<Field> fields;
        public string Prefix { get; set; }

        public void AddField(Field field)
        {
            field.Form = this;
            fields.Add(field);
        }
    }

    class Field
    {
        public void RenderHtml()
        {
            // render html element with ID attribute
            // prefixed with the parent form's Prefix property
        }
    }
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

.net c#

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

在c#中使用sql server元数据

是否有任何工具将SQL Server元数据的检索封装到一个漂亮的对象模型中?

我的当前需求是从SQL Server 2000-2008 R2收集这些东西:

  • 数据库
  • 外键约束
  • 触发器

所以,也许给定一个SqlConnection对象,我可以这样做:

var dbs = conn.GetDatabases();
var db = dbs.Single(x => x.Name == "AdventureWorks");
var tables = db.GetTables();
var triggers = db.GetAllTriggers();
Run Code Online (Sandbox Code Playgroud)

当然,这些例子会非常方便,但任何类型的对象模型都会比我现在所做的更好.在我建立自己之前,那里有什么东西吗?

.net c# sql sql-server metadata

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

WCF错误 - 邮件安全验证失败

我正在尝试使用新的WCF服务.该服务在分层安全性之前正在运行.现在我收到此错误:

An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

Server stack trace: 
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at MyProject.IntegrationSample.MyProjectService.IMyProjectService.GetData(Int32 …
Run Code Online (Sandbox Code Playgroud)

.net wcf web-services

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

需要帮助在C#中使用泛型和lambda表达式创建扩展方法

我将所有高级功能集中在一起,但是没有使用泛型或lambda表达式:

以下是我想要创建的方法的示例用法:

MyClass mc = null;
int x = mc.TryGetOrDefault(z => z.This.That.TheOther); // z is a reference to mc
// the code has not failed at this point and the value of x is 0 (int's default)
// had mc and all of the properties expressed in the lambda expression been initialized
// x would be equal to mc.This.That.TheOther's value
Run Code Online (Sandbox Code Playgroud)

就我所知,但是Visual Studio抱怨道:

在此输入图像描述

c# generics lambda extension-methods

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