|
led mike wrote: Perhaps reading Allen Holub discuss why Getters and Setters are Evil[^] will help you.
Read the article but it is focused more on the class design. If I understand it correctly, I am doing fine because I am creating an interface to define the contract that will be passed around.
I will have a calculator object that accepts the ICalculatable as a parameter to a RunCalc method. This will ensure I have access to the values I need to do the calculation. BaseObject is a business object. The calculator object will be business intelligence. I don't care about the actual implementation under the covers.
How do I define IBaseObject to imply that the FirstPaymentDate property is the same in both the IBaseObject definition and the ICalculatable definition?
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|
|
Ware@Work wrote: How do I define IBaseObject to imply that the FirstPaymentDate property is the same in both the IBaseObject definition and the ICalculatable definition?
You leave it off of IBaseObject altogether, as IBaseObject inhertits from ICalculatable (and assuming you implicitly implement the interface) any instance of a class which implements IBaseObject will have access to the required method.
Scratch all that, I see it is get/set in IBaseObject and get only in ICalculatable. In which case I would do it as follows:
public class BaseObject : IBaseObject
{
#region IBaseObject Members
public string Identifier
{
get { throw new NotImplementedException(); }
}
public DateTime FirstPaymentDate
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public decimal InterestRate
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region ICalculatable Members
public decimal MonthlyCompoundingRate
{
get { throw new NotImplementedException(); }
}
#endregion
}
Anything that has a reference to BaseObject (or IBaseObject) can get/set FirstPaymentdate. However anything with a reference to ICalculatable will only be able to get.
|
|
|
|
|
You got into the implementation. I want to define the contract so that any object that satifies IBaseObject will by nature satisfy ICalulatable and be usable as such.
Is using new on FirstPaymentDate the correct way to do so? I tried using virtual/override and it wouldn't let me do that. So I am beginnining to believe it must be.
Thanks all for the help.
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|
|
The Interfaces seem absolutely fine to me. And I was just demonstrating how I would implement those interfaces in a base class.
|
|
|
|
|
does this help
class Program
{
static void Main(string[] args)
{
Three inst = new Three();
inst.Name = "Hello";
IOne foo = new Three();
ITwo bar = new Three();
bar.Name = "Hello";
}
}
public interface IOne
{
string Name { get; }
}
public interface ITwo : IOne
{
new string Name { get;set; }
}
public class Three : ITwo
{
private string _name;
#region ITwo Members
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
#endregion
}
|
|
|
|
|
I think it is a new error message in the 2005 and later version of the compiler. I think the 1.1 allows this. The best way, I have found, to get around this error is to create another common interface such as IHasFirstPaymentDate. Then IBaseObject and ICalculateable can both inherit without the warning.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Say i have the following
public class CollageClass
{
public List<Student> Students{ get; set; }
public string Name { get; set; }
public string RoomNumber{ get; set; }
}
public class Student
{
public string Name { get; set; }
public int Age{ get; set; }
public int BestGrade{ get; set; }
}
nice and simple, now i want to create a report, to display the CollageClass info at the top of the page and the students info under.
How is the best/easyest way to do this? i was going to make a crystal report, but i cant just give it my instance of CollageClass. If i used crystal, i was thinking of making a strongly typed dataset to match the contents of the class, populate that and then bind the report to it, is this the correct way to do this? (just seems like a lot of work as my class is much bigger than the above example)
i dont normally make many reports, so this is kinda a bit new to me
Regards
Mark
|
|
|
|
|
That is the way I do it. It may sound like a lot of work but crystal is quirky unless you do things there way.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hi mark,
i don´t know if that works for you, my coding different
static string _image_path;
public static string Image_Path
{
get { return _image_path; }
set { _image_path = value; }
}
but, were is the database?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Ever tried to make an property with the type of what you think should be Nullable<Single> a.k.a. Single?.
CodeDom will make cast this as Nullable<float>.
In short i cant seem to find anything on the net about this bug.
heres an test script:
CodeMemberProperty MyProperty = new CodeMemberProperty();
MyProperty.Type = new CodeTypeReference(typeof( Nullable<Single> ));
MyProperty.Name = "MySingleValue";
MyProperty.Attributes = MemberAttributes.Public | MemberAttributes.Final;
this will generate this:
public Nullable<float> MySingleValue
{
...
}
Has anyone any fix for this ???
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
|
well excuse me, for using that word...
I do know atbout the float/single. but thats not my point. read my entry again... if you dont get, what im trying to point out here.
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Paw Jershauge wrote: if you dont get, what im trying to point out here.
Are you trying to make it sealed?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I read it again, you're missing the point. float is C# syntactic sugar for the .NET type System.Single . They are one and the same thing.
If you're wondering why CodeDom changes your definition of float to System.Single its because CodeDom is language agnostic and the float keyword is only relevant to C#
|
|
|
|
|
UPS!!!!!
I did actualy find the solution to this... its because im an old VB developer but havent been using this for some years now...
Single is float in C# terms BUT in VB.Net its still Single.
So if i look in the VB generated code its an Single and in the C# generated code its Float.
My mistake...
I let it rest here...
Thanks for hammering my head, with the correct answer...
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Ok, I read it again. What do you not understand that System.Single is identical to float?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hello everyone,
I am using IIS 6.0 and I am going to using the built-in function of basic authentication of IIS.
To authenticate, we must have user name and password. After some search, I am still confused where are the user name and password coming from? From Windows existing user account or somewhere else?
thanks in advance,
George
|
|
|
|
|
You can create user accounts on the machine or domain and then assign the security to the directories using standard windows security features. Basic authentication is not recommended for domain accounts as they are sent in plain text. BTW, I think this is a web dev question.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Hi Ennis,
1.
I understand how to create user account for local machine, but how to create user account for a domain? Any guides or documents?
2.
"assign the security to the directories using standard windows security features" -- not sure which management function do you mean, confused -- both Windows Server and IIS has a couple of various account management dialogs. Could you post some links or documents about what do you mean "assign the security to the directories using standard windows security features" please?
regards,
George
|
|
|
|
|
|
Hi leppie,
The GUI of this site looks fancy, but a little messy information on this site. This site is specialized for what topics?
regards,
George
|
|
|
|
|
Title says it all really, is it possible to call a .NET 2 library from a .NET 1.1 library?
The obvious and immediate answer is no, as the 1.1 library will be running in a 1.1 AppDomain that does not include the 2.0 framework. However is there anyway to "bridge" across, maybe remoting/custom socket server?
modified on Thursday, September 25, 2008 8:47 AM
|
|
|
|
|
Haven't tested Remoting (although I think it is possible) but low level socket communication is definitely functioning.
Robert
|
|
|
|
|
I mean, why not.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
I like the cut of your jib, however....
When I find a hack frig solution this will be deployed out to over 10 thousand servers and unfortunately the current build of these does not have MSMQ installed. Installing this as part of the deployment process is not feasible.
|
|
|
|