I know c# well, but it is something strange for me.
In some old program, I have seen this code:
public MyType this[string name]
{
......some code that finally return instance of MyType
}
How it is called? What is the use of this?
...
I have a Property File like this:
frame.server.dev=mark.is.cool
frame.server.test=chris.is.cool
frame.server.qa=mitch.is.cool
frame.server.prod=cory.is.cool
I need to inject the correct value based on the environment. Since we have one ear file that we move from environment to environment, I need to do something like this:
<util:pro...
I am writing some unit tests for an extension method I have written on IPrincipal. To assist, I have created a couple of helper classes (some code for not-implemented members of the interfaces has been omitted for brevity):
public class IPrincipalStub : IPrincipal
{
private IIdentity identityStub = new IIdentityStub();
public ...
Hi All,
In my Asp.Net project I wanna use Property Auto-wiring, e.g. for my ILogger. Basically I placed it as Property into class where I need to use it. Like below.
public class UserControlBase : UserControl
{
public ILogger CLogger { get; set; }
....
}
public partial class IPTracking : UserControlBase
{
protected void Pa...
I'm making a game for the iPhone, and I have a class called Robot.
Then I have a class called View, which renders everything.
I want to send a copy of my Robot, which I defined in my ViewController, and I send it to gameView (which is View *gameView), like this:
robot = [Robot new];
[gameView setRobot: [robot copy]];
I tried to make...
I am currently working on a project with some help and it has been going well, until this incident.
function runCommand(commandString)
{
commands = new Object();
commands.clear = function(){ $('#terminal').html('') }
parameters = commandString.split(" ");
command = parameters.shift();
if( commands.hasOwnProperty(comm...
I have a object with properties that are expensive to compute, so they are only calculated on first access and then cached.
private List<Note> notes;
public List<Note> Notes
{
get
{
if (this.notes == null)
{
this.notes = CalcNotes();
}
return this.note...
In a C# Winforms (3.5) application I have added a class that contains many properties (get/set) used to stored values from a 12 form long process.
After form 12 I would like wipe out all the property values in the storing class so that the next user won't accidentally record values when starting the process at form 1.
Is it possible to...
Hi,
I'm not quite sure how to do that, but what I would like to do is to create a special type of property that will perform specific tasks at the get and set, and will be defined on generic type.
For example, when writing this:
MyProp<String> name;
a pre-defined get and set will be performed on the string value.
How can that b...
I like c#, but why can I do :
public static bool Initialized { private set; get; }
or this :
public static bool Initialized = false;
but not a mix of both in one line ?
I just need to set access level to my variable (private set), and I need it set at false on startup. I wouldn't like to make that boring private _Initialized varia...
When we define a property like
public string Name {get; set;}
dot net can make our properties code. but when we use
public string Name {get;}
public string Name {set;}
we face with
'Hajloo.SomeThing.PropertyName.set' must declare a body because it is not marked abstract or extern. Automatically implemented properties ...
I've inherited some python code that contains a rather cryptic decorator. This decorator sets properties in classes all over the project. The problem is that this I have traced my debugging problems to this decorator. Seems it "fubars" all debuggers I've tried and trying to speed up the code with psyco breaks everthing. (Seems psyco and ...
To create a delegate from a method you can use the compile type-safe syntax:
private int Method() { ... }
// and create the delegate to Method...
Func<int> d = Method;
A property is a wrapper around a getter and setter method, and I want to create a delegate to a property getter method. Something like
public int Prop { get; set; }
...
In classes that implement INotifyPropertyChanged I often see this pattern :
public string FirstName
{
get { return _customer.FirstName; }
set
{
if (value == _customer.FirstName)
return;
_customer.FirstName = value;
base.OnPropertyChanged("FirstName");
...
I am trying to understand dynamic linq and expression trees. Very basically trying to do an equals supplying the column and value as strings. Here is what I have so far
private IQueryable<tblTest> filterTest(string column, string value)
{
TestDataContext db = new TestDataContext();
// The IQueryable data to query...
I'm using the automapping feature of FluentNHibernate and need a property that derives its return value. This property must return an Enum value, e.g.
public virtual MyEnum MyDerivedProperty
{
get
{
MyEnum retval;
// do some calculations
return retval;
}
}
Currently I get the following exception:
NHib...
I am using Visual Studio 2008. In my editor whenever I write an automatic property it's "get" and "set" wraps to a single line whenever I wrote "set" and put semicolon(;). like this:
public string MyProperty
{
get; set;
}
I want it to be formatted like this
public string MyProperty
{
get;
set;
}
Currently I am manually ...
interface IAnimal
{
string Name { get; set; }
}
class Dog : IAnimal
{
private string name;
public Dog(string name)
{
Name = name;
}
public string Name
{
get { return name; }
set { name = value; }
}
}
...
Hi,
Background:
I have a WPF UserControl (MainControl - not shown in code below) that contains another one (called MyControl in the code below).
MainControl has it's DataContext set to an object, that has a Project-property.
When MainControl loads, the Project-property is always null.
The problem:
When MainControl loads, I want to f...
Hi everyone,
I'm trying to write a batch script, this script is responsible to launch a jar with one parameters.
This parameter indicate to my jar wich property file to use in order to setup some configuration.
Then the script will zip the results produced by the jar and send them to a location. But in order to set the name of the zi...