Search Results

Search found 150 results on 6 pages for 'elysium'.

Page 4/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Question about how to implement a c# host application with a plugin-like architecture

    - by devoured elysium
    I want to have an application that works as a Host to many other small applications. Each one of those applications should work as kind of plugin to this main application. I call them plugins not in the sense they add something to the main application, but because they can only work with this Host application as they depend on some of its services. My idea was to have each of those plugins run in a different app domain. The problem seems to be that my host application should have a set of services that my plugins will want to use and from what is my understanding making data flow in and out from different app domains is not that great of a thing. On one hand I'd like them to behave as stand-alone applications(although, as I said, they need to use lots of times the host application services), but on the other hand I'd like that if any of them crashes, my main application wouldn't suffer from it. What is the best (.NET) approach to this kind of situation? Make them all run on the same AppDomain but each one in a different Thread? Use different AppDomains? One for each "plugin"? How would I make them communicate with the Host Application? Any other way of doing this? Although speed is not an issue here, I wouldn't like for function calls to be that much slower than they are when we're working with just a regular .NET application. Thanks

    Read the article

  • Returning a ReadOnlyCollection from a method with an IList return type

    - by devoured elysium
    Here I have the following bit of code: private IList<IState> _states = new List<IState>(); private ReadOnlyCollection<IState> _statesViewer; public IList<IState> States { get { return _statesViewer; } } Generally it is preferable to return interfaces than the concrete classes themselves, but in this case, shouldn't I set as the return type of the States property a ReadOnlyCollection? Any user of my library will think it is possible to anything you can do with an IList if I set it as so, and that means adding elements. That is not true and I'm definitely breaking the contract exposing it as an IList. Am I right with this view or there is something else I am missing here?

    Read the article

  • Applying the Decorator Pattern to Forms

    - by devoured elysium
    I am trying to apply the Decorator Design Pattern to the following situation: I have 3 different kind of forms: Green, Yellow, Red. Now, each of those forms can have different set of attributes. They can have a minimize box disabled, a maximized box disabled and they can be always on top. I tried to model this the following way: Form <---------------------------------------FormDecorator /\ /\ |---------|-----------| |----------------------|-----------------| GreenForm YellowForm RedForm MinimizeButtonDisabled MaximizedButtonDisabled AlwaysOnTop Here is my GreenForm code: public class GreenForm : Form { public GreenForm() { this.BackColor = Color.GreenYellow; } public override sealed Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } } FormDecorator: public abstract class FormDecorator : Form { private Form _decoratorForm; protected FormDecorator(Form decoratorForm) { this._decoratorForm = decoratorForm; } } and finally NoMaximizeDecorator: public class NoMaximizeDecorator : FormDecorator { public NoMaximizeDecorator(Form decoratorForm) : base(decoratorForm) { this.MaximizeBox = false; } } So here is the running code: static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(CreateForm()); } static Form CreateForm() { Form form = new GreenForm(); form = new NoMaximizeDecorator(form); form = new NoMinimizeDecorator(form); return form; } The problem is that I get a form that isn't green and that still allows me to maximize it. It is only taking in consideration the NoMinimizeDecorator form. I do comprehend why this happens but I'm having trouble understanding how to make this work with this Pattern. I know probably there are better ways of achieving what I want. I made this example as an attempt to apply the Decorator Pattern to something. Maybe this wasn't the best pattern I could have used(if one, at all) to this kind of scenario. Is there any other pattern more suitable than the Decorator to accomplish this? Am I doing something wrong when trying to implement the Decorator Pattern? Thanks

    Read the article

  • Which Queue implementation to use in Java?

    - by devoured elysium
    I need to use a FIFO structure in my application. It needs to have at most 5 elements. I'd like to have something easy to use (I don't care for concurrency) that implements the Collection interface. I've tried the LinkedList, that seems to come from Queue, but it doesn't seem to allow me to set it's maximum capacity. It feels as if I just want at max 5 elements but try to add 20, it will just keep increasing in size to fit it. I'd like something that'd work the following way: XQueue<Integer> queue = new XQueue<Integer>(5); //where 5 is the maximum number of elements I want in my queue. for (int i = 0; i < 10; ++i) { queue.offer(i); } for (int i = 0; i < 5; ++i) { System.out.println(queue.poll()); } That'd print: 5 6 7 8 9 Thanks

    Read the article

  • How do actually castings work at the CLR level?

    - by devoured elysium
    When doing an upcast or downcast, what does really happen behind the scenes? I had the idea that when doing something as: string myString = "abc"; object myObject = myString; string myStringBack = (string)myObject; the cast in the last line would have as only purpose tell the compiler we are safe we are not doing anything wrong. So, I had the idea that actually no casting code would be embedded in the code itself. It seems I was wrong: .maxstack 1 .locals init ( [0] string myString, [1] object myObject, [2] string myStringBack) L_0000: nop L_0001: ldstr "abc" L_0006: stloc.0 L_0007: ldloc.0 L_0008: stloc.1 L_0009: ldloc.1 L_000a: castclass string L_000f: stloc.2 L_0010: ret Why does the CLR need something like castclass string? There are two possible implementations for a downcast: You require a castclass something. When you get to the line of code that does an castclass, the CLR tries to make the cast. But then, what would happen had I ommited the castclass string line and tried to run the code? You don't require a castclass. As all reference types have a similar internal structure, if you try to use a string on an Form instance, it will throw an exception of wrong usage (because it detects a Form is not a string or any of its subtypes). Also, is the following statamente from C# 4.0 in a Nutshell correct? Upcasting and downcasting between compatible reference types performs reference conversions: a new reference is created that points to the same object. Does it really create a new reference? I thought it'd be the same reference, only stored in a different type of variable. Thanks

    Read the article

  • Circular dependency with generics

    - by devoured elysium
    I have defined the following interface: public interface IStateSpace<State, Action> where State : IState where Action : IAction<State, Action> // <-- this is the line that bothers me { void SetValueAt(State state, Action action); Action GetValueAt(State state); } Basically, an IStateSpace interface should be something like a chess board, and in each position of the chess board you have a set of possible movements to do. Those movements here are called IActions. I have defined this interface this way so I can accommodate for different implementations: I can then define concrete classes that implement 2D matrix, 3D matrix, graphs, etc. public interface IAction<State, Action> { IStateSpace<State, Action> StateSpace { get; } } An IAction, would be to move up(this is, if in (2, 2) move to (2, 1)), move down, etc. Now, I'll want that each action has access to a StateSpace so it can do some checking logic. Is this implementation correct? Or is this a bad case of a circular dependence? If yes, how to accomplish "the same" in a different way? Thanks

    Read the article

  • Check if there are any repeated elements in an array recursively

    - by devoured elysium
    I have to find recursively if there is any repeated element in an integer array v. The method must have the following signature: boolean hasRepeatedElements(int[] v) I can't see any way of doing that recursively without having to define another method or at least another overload to this method (one that takes for example the element to go after or something). At first I thought about checking for the current v if there is some element equal to the first element, then creating a new array with L-1 elements etc but that seems rather inefficient. Is it the only way? Am I missing here something?

    Read the article

  • Versioning issues with assemblies

    - by devoured elysium
    Let's assume I have two assemblies: MyExecutable.dll version 1.0.0 MyClassLibrary.dll version 1.0.0 Now, MyExecutable.dll currently uses MyClassLibrary.dll's classes and methods (which include some algorithms). Most of those algorithms were made on the run, being that later I'll want to refine them if needed. This means, I won't change the interface of those classes but the code itself will see some changes. The question at hand is, MyExecutable.dll will be expecting MyClassLibrary.dll 1.0.0 and I'll want it to use version 1.0.1 (or something like that). I don't want to have to recompile MyExecutable.dll(because actually there might be more than just one executable using MyClassLibrary.dll). Is there a solution for this problem? I've heard about the GAC, but if possible I'd like to stay away from it. Thanks

    Read the article

  • Designing a class in such a way that it doesn't become a "God object"

    - by devoured elysium
    I'm designing an application that will allow me to draw some functions on a graphic. Each function will be drawn from a set of points that I will pass to this graphic class. There are different kinds of points, all inheriting from a MyPoint class. For some kind of points it will be just printing them on the screen as they are, others can be ignored, others added, so there is some kind of logic associated to them that can get complex. How to actually draw the graphic is not the main issue here. What bothers me is how to make the code logic such that this GraphicMaker class doesn't become the so called God-Object. It would be easy to make something like this: class GraphicMaker { ArrayList<Point> points = new ArrayList<Point>(); public void AddPoint(Point point) { points.add(point); } public void DoDrawing() { foreach (Point point in points) { if (point is PointA) { //some logic here else if (point is PointXYZ) { //...etc } } } } How would you do something like this? I have a feeling the correct way would be to put the drawing logic on each Point object (so each child class from Point would know how to draw itself) but two problems arise: There will be kinds of points that need to know all the other points that exist in the GraphicObject class to know how to draw themselves. I can make a lot of the methods/properties from the Graphic class public, so that all the points have a reference to the Graphic class and can make all their logic as they want, but isn't that a big price to pay for not wanting to have a God class?

    Read the article

  • How to run an "empty" Windows Application that only has a NotifyIcon?

    - by devoured elysium
    I want to make an Application that only has a NotifyIcon. It doesn't need to have at all a "Main" Form. When I want to achieve something like this, I just create an invisible form and run it, but would there be a more "elegant" way of doing this, I'd like to know it. How do you generally do this? This application can't be a Windows Service, as having the NotifyIcon and its Context Menus is important (each one of them will run a different command). Thanks

    Read the article

  • Searching in graphs trees with Depth/Breadth first/A* algorithms

    - by devoured elysium
    I have a couple of questions about searching in graphs/trees: Let's assume I have an empty chess board and I want to move a pawn around from point A to B. A. When using depth first search or breadth first search must we use open and closed lists ? This is, a list that has all the elements to check, and other with all other elements that were already checked? Is it even possible to do it without having those lists? What about A*, does it need it? B. When using lists, after having found a solution, how can you get the sequence of states from A to B? I assume when you have items in the open and closed list, instead of just having the (x, y) states, you have an "extended state" formed with (x, y, parent_of_this_node) ? C. State A has 4 possible moves (right, left, up, down). If I do as first move left, should I let it in the next state come back to the original state? This, is, do the "right" move? If not, must I transverse the search tree every time to check which states I've been to? D. When I see a state in the tree where I've already been, should I just ignore it, as I know it's a dead end? I guess to do this I'd have to always keep the list of visited states, right? E. Is there any difference between search trees and graphs? Are they just different ways to look at the same thing?

    Read the article

  • Detecting Visual Studio Smart-tags events

    - by devoured elysium
    Is it possible to detect with VSX when any (or a particular) smart tag event is happening? I mean, every time we rename a variable, for example, a smart tag is available that allows us to change it through a form. I'd like to know if I can access that "text is changing" event. I don't mean to have to check for myself if the text is being changed and such, I'd like to make use of VS event system (if there is one). I gave this example but I'd like to know the "general system" of how smart tags work with VSX. Thanks

    Read the article

  • Design by contracts and constructors

    - by devoured elysium
    I am implementing my own ArrayList for school purposes, but to spice up things a bit I'm trying to use C# 4.0 Code Contracts. All was fine until I needed to add Contracts to the constructors. Should I add Contract.Ensures() in the empty parameter constructor? public ArrayList(int capacity) { Contract.Requires(capacity > 0); Contract.Ensures(Size == capacity); _array = new T[capacity]; } public ArrayList() : this(32) { Contract.Ensures(Size == 32); } I'd say yes, each method should have a well defined contract. On the other hand, why put it if it's just delegating work to the "main" constructor? Logicwise, I wouldn't need to. The only point I see where it'd be useful to explicitly define the contract in both constructors is if in the future we have Intelisense support for contracts. Would that happen, it'd be useful to be explicit about which contracts each method has, as that'd appear in Intelisense. Also, are there any books around that go a bit deeper on the principles and usage of Design by Contracts? One thing is having knowledge of the syntax of how to use Contracts in a language (C#, in this case), other is knowing how and when to use it. I read several tutorials and Jon Skeet's C# in Depth article about it, but I'd like to go a bit deeper if possible. Thanks

    Read the article

  • Using methods from the "outer" class in inner classes

    - by devoured elysium
    When defining nested classes, is it possible to access the "outer" class' methods? I know it's possible to access its attributes, but I can't seem to find a way to use its methods. addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && //<-- Here I'd like to } // reference a method }); //from the class where //addMouseListener() is defined! Thanks

    Read the article

  • Implementing clone on a LinkedList

    - by devoured elysium
    I am trying to implement a clone() method on a DoubleLinkedList. Now, the problem is that implementing it by "the convention" is a lot more troublesome than just creating a new DoubleLinkedList and filling it with all the elements of my current DoubleLinkedList. Is there any inconvenient I am not seeing when doing that? Here is my current approach: @Override public DoubleLinkedList<T> clone() { DoubleLinkedList<T> dll = new DoubleLinkedList<T>(); for (T element : dll) { dll.add(element); } return dll; } Here is what it would be by the convention: @Override public DoubleLinkedList<T> clone() { try { DoubleLinkedList<T> dll = (DoubleLinkedList<T>)super.clone(); //kinda complex code to copy elements return dll; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }

    Read the article

  • Controlling CodeModel's code output formatting: putting lines between namespace declarations

    - by devoured elysium
    I'm making some experiments with Visual Studio's CodeModel. I tried creating a file with two namespaces in there through VS's Code Model: CodeModel codeModel = projItem.ContainingProject.CodeModel; codeModel.AddNamespace("Namespaces.FirstNamespace", "namespacestest.cs"); codeModel.AddNamespace("Namespaces.SecondNamespace", "namespacestest.cs"); the output of such code is: //file namespacestest.cs namespace Namespaces.FirstNamespace { } namespace Namespaces.SecondNamespace { } Which is almost what I'm looking for. The only catch here is that I'd like to control the spacing: having at least one line between the first and the second namespace. Does by chance anyone know of a way of achieving this? This is what I want: //file namespacestest.cs namespace Namespaces.FirstNamespace { } namespace Namespaces.SecondNamespace { } Thanks

    Read the article

  • Does Java have something like C#'s ref and out keywords?

    - by devoured elysium
    Something like the following: ref example: void changeString(ref String str) { str = "def"; } void main() { String abc = "abc"; changeString(ref abc); System.out.println(abc); //prints "def" } out example: void setString(out String str) { str = "def"; } void main() { String abc; changeString(out abc); System.out.println(abc); //prints "def" }

    Read the article

  • How to signal object instantiation in a Collaboration/Communication Diagram?

    - by devoured elysium
    I'd like to know how to translate the following line of code to a Collaboration Diagram: Food food = new Food("abc", 123); I know that I can call an Food's method using the following notation: MyStaticMethod() ----------------------> -------- | | | Food | | | -------- being that equivalent to Taste taste = Food.MyStaticMethod(); and MyInstanceMethod() ----------------------> --------------- | | | food : Food | | | --------------- is equivalent to food.MyInstanceMethod(); but how do I signal that I want to call a given constructor on Food? Thanks

    Read the article

  • Where to start when doing a Domain Model?

    - by devoured elysium
    Let's say I've made a list of concepts I'll use to draw my Domain Model. Furthermore, I have a couple of Use Cases from which I did a couple of System Sequence Diagrams. When drawing the Domain Model, I never know where to start from: Designing the model as I believe the system to be. This is, if I am modelling a the human body, I start by adding the class concepts of Heart, Brain, Bowels, Stomach, Eyes, Head, etc. Start by designing what the Use Cases need to get done. This is, if I have a Use Case which is about making the human body swallow something, I'd first draw the class concepts for Mouth, Throat, Stomatch, Bowels, etc. The order in which I do things is irrelevant? I'd say probably it'd be best to try to design from the Use Case concepts, as they are generally what you want to work with, not other kind of concepts that although help describe the whole system well, much of the time might not even be needed for the current project. Is there any other approach that I am not taking in consideration here? How do you usually approach this? Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >