Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

dbaseman

@dbaseman
About
Posts
8
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Form_Load equivalent from C#.Silverlight
    D dbaseman

    It's the "Loaded" event.

    void MyUserControl_Loaded(object sender, RoutedEventArgs e)
    {
    }

    To set up the event handler, you can use

    this.Loaded += MyUserControl_Loaded

    in code behind, or

    Loaded="MyUserControl_Loaded"

    in XAML

    WPF csharp design help question

  • Binding to an XML list of attributes
    D dbaseman

    I'm not really an XPath expert, but my guess would be: //System[1]/Kind

    WPF wpf xml wcf question

  • Binding to an XML list of attributes
    D dbaseman

    You can select an item by using the XPath expression. Instead of XPath=//Kind, use XPath=//Kind[0], or XPath=//Kind[1], etc.

    WPF wpf xml wcf question

  • Generics Problems
    D dbaseman

    The best way to do this is to create an interface that encapsulates the common properties of your entities:

    public interface IEntity
    {
    string SomeProperty { get; set; }
    }

    public interface IAnotherInterface
    {
    string Name { get; set; }
    }

    Each entity can inherit multiple interfaces, depending on how you want it set up:

    public class Entity1 : IEntity, IAnotherInterface
    {
    public string SomeProperty { get; set; }
    public string Name { get; set; }
    }

    If every entity has a certain interface, then you can require it in the Form definition:

    public partial class Form1 : Form
    where T : IEntity

    Finally, cast to the interfaces to set properties. If only some entities implement a given interface, check first.

    void SetSomeProperties()
    {
    (entity as IEntity).SomeProperty = "foo";
    if (entity is IAnotherInterface)
    {
    (entity as IAnotherInterface).Name = "bar";
    }
    }

    C# help question csharp winforms

  • Binding to an XML list of attributes
    D dbaseman

    I think I see what the problem is. In the ListBox XAML, you don't need the Source=data (that's incorrect syntax, and besides, you already set the DataContext from the code-behind, so it's not needed. Take that part out, and it should work:

    WPF wpf xml wcf question

  • C# application obtain results of program it executes
    D dbaseman

    That's an interesting point, but I'm not sure how it's relevant to the question (remember, this relates to a C# console app).

    C# question csharp tutorial

  • C# application obtain results of program it executes
    D dbaseman

    Right, of course, but my point is that it's far better to interact with an API, than trying to parse the output from a console application.

    C# question csharp tutorial

  • C# application obtain results of program it executes
    D dbaseman

    I think it would be better to reorganize your code. The console project you wrote really should be a library/API, if you're going to consume it from another application (ie, the windows service). I'd suggest converting your console application into a class library project. Then, both the windows service and console can create their own implementations. So, let's say you execute the console app like this: myconsoleapp.exe "servicename" Then, create a library project with a public method "RunService":

    public class MyAPI
    {
        public string ExecuteService(string serviceName)
        {
            // logic goes here
        }
    }
    

    Now both the console app, and your new windows service can consume MyAPI as needed.

    C# question csharp tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups