|
Background:
My app has a layer that fetches objects and stores them in a cache (own implementation). All items are identified by the signature and params of the calling method. This works pretty well. The gui layer uses data binding to bind those cached objects to the controls. If a form ist closed, the user can save or cancel all changes.
Problem:
The data binding automatically changes the objects that are referenced by the gui AND the cache - even if the user cancels the changes... So the object in the cache is accidentally changed, too. My first idea would be to return only copies of the objects (new references), but how to create a "stand-alone" copy of unknown objects?
Any suggestions?
thx in advance
glFrustum
|
|
|
|
|
Take a look at the Memento pattern for these objects.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for the quick response. Using memento would be a better design, but right now I'm looking for a solution that can be applied to the cache itself and not everywhere it is used.
|
|
|
|
|
Theoretically, you could make the cache use the Memento pattern - without seeing your implementation, it's hard to say, but you could have:
public class Cache
{
private List<IMemento> _cache = new List<IMemento>
public void AddToCache<T>(T cacheItem)
{
_cache.Add(new MementoCache(cacheItem));
}
public T CancelChanges<T>(T cacheItem)
{
T item = _cache[...];
_cache.Remove(...);
return item;
}
internal class CacheMemento : IMemento
{
public void AddToCache<T>(T cacheItem)
{
}
}
} I'm just doing this off the top of my head, so I apologise that it's rough and needs to be tidied up.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello everyone,
If I am using Visual Studio 2005 to build a C# Class Library (COM), it is as default dependent on .Net Runtime Framework 2.0 when running?
If I am using Visual Studio 2003 to build a C# Class Library (COM), it is as default dependent on .Net Runtime Framework 1.1 when running?
How to check the .Net Framework Runtime dependencies when using Visual Studio?
thanks in advance,
George
|
|
|
|
|
The answer to both is obviously yes, as they in C#
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks Christian,
I want to confirm that when using Visual Studio 2005 to build a C# Class Library, the generated assembly Class Library is dependent on .Net 2.0? And for the same case, Class Library generated by Visual Studio 2003 is dependent on .Net 1.1? Could you help to confirm again?
Are thre any ways to change the hard-coded dependencies? For example, in Visual Studio 2005, I could make a C# Class Library which is dependent on .Net 1.1?
regards,
George
|
|
|
|
|
|
Thanks Hessam,
It seems that binary code for .Net 2.0 is not compatible with .Net 1.1? And it is why users need to make build for .Net 1.1 in VS 2005 (so that Microsoft provides MsBee)?
regards,
George
|
|
|
|
|
In the software on which i am working there is module just like Microsoft outlook i.e a user can configure its mail id and can download his mails in software.
What my problem is while downloading mails:-
If content is plain text then its all OK,
But if its colour text or having different encoding then its shows tags(related to colour, text size).
means look messed up.
So, how can i overcome this, so that mails display correct?
|
|
|
|
|
I think it happens because the body of those mails are HTML so why you don't use the WebBrowser Control for showing them.
it can show both plain text and HTML
|
|
|
|
|
hello friends
can anybody tell me how to convert the .nt 2005 to 2003 version can it
be possible plzzzz reply
|
|
|
|
|
Microsoft Has a tool name "MSBuild Extra Toolkit for .NET1.1" aka "MSBee"
which can compile your solutions in vs 2005 with .net1.1
http://msdn2.microsoft.com/en-us/vstudio/aa718347.aspx
but it didn't work for me because I used somethings that did not exist in .net1.1
maybe works for you
good luck
|
|
|
|
|
DataBase Rights
Time - 1 month , 3 months , 6 months , 1 year
DBRIGHTS
id auto inc , primary
employerid
startdate , enddate
this is the database and time zone is given for each register user he has to click any one from 1month to 1 year. depending upon this he will recive msg that his account get expire please register again
anyoone plz told me how i do that
|
|
|
|
|
Use Thread which is always active in background.
For more help contact on chetan.patel@rigelnetworks.com
Best Regards,
Chetan Patel
|
|
|
|
|
use Session concept in ur application.This will help to count amount of days/time/month.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
Hi,
Thanks in advance.
I want to post a XML file to a URL (in window application) and i m trying this code but system give me a error message at oBjStreamWriter = File.CreateText("http://...../XMLFolder/Test.xml"); "URI format are not supported", please help me if anybody can.
StreamWriter mWriter;
StreamWriter oBjStreamWriter;
StreamReader oBjStreamReader;
StringReader ReadOutput;
XmlTextReader xmltextreader;
HttpWebRequest oBjRequest = (HttpWebRequest)WebRequest.Create("http://...../XMLFolder/");
oBjRequest.Method = "POST";
oBjRequest.ContentLength = XMLStr.Length;
oBjRequest.ContentType = "application/x-www-form-urlencoded";
mWriter = new StreamWriter(oBjRequest.GetRequestStream());
mWriter.Write(XMLStr);
mWriter.Close();
oBjStreamWriter = File.CreateText("http://...../XMLFolder/Test.xml");
oBjStreamWriter.WriteLine(XMLStr);
oBjStreamWriter.Close();
WebResponse oBjWebResponse = oBjRequest.GetResponse();
oBjStreamReader = new StreamReader(oBjWebResponse.GetResponseStream());
string ResultOutput = oBjStreamReader.ReadToEnd();
oBjStreamReader.Close();
Arun Kr
|
|
|
|
|
Once you put HTTP, you are asking for an online resource. If the file is local, lose the HTTP
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
if u r dealing with local desktop, dont use http ://..., as this will make it to use online resource.Instead, use localhost://<path of="" virtual="" directory=""> and keep the file say file.txt to this virtual directory.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
can we choose printer during execution if yes please give me source.
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
I'm not sure if you're using Visual Studio 2005 but if you are, theres a component called a PrintDialog that allow the user to choose which printer they would like to use.
Lester
http://www.lestersconyers.com
|
|
|
|
|
|
You can use classes in System.Management namespace and some WMI query to do that
for that I suggest you to search MSDN for WMI or windows management instruments
and of course the program "Scriptomatic2" from Microsoft guys can help you a lot it can generate queries you needed for retrieving current printers and set the default printer.
all you need is just some coding.!
good luck
|
|
|
|
|
Hello developers,
Does anybody know a good e-link to Threading tutorial for windows application in C#.Net.
Please make sure i am looking for windows application and not console because i could already see many for console.
But i cant find good article for windows application. I am looking for such article which takes me from beginner to advance level threading for windows application only.
Thanx
James
|
|
|
|
|
they work exactly the same in both instances.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|