As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am using System.Runtime.Caching for memory cache, but I would like to have a filecache aswell. I am having some trouble, seeing how to do this.
Of course, I can create my own, simply method of doing this. Save to disc, get from disc if it exists. BUT, can I do something more clever, with System.Runtime.Caching? Get expiration on the items, as an example?
I don't really see how to implement expiration, on my simple save-to-disc cache.
Serialization is the key with which you can achieve this sort Caching on the FileSystem. First of all you must be having some object to Cache on the FileSystem. Include the Expiration time factor in it to check for its expiry (can be implemented using Timer) then you just need to design those objects to support Serialization.
To understand more about Serialization use following references:
What is [Serializable] and when should I use it?
.NET Serialization (using BinaryFormater, SoapFormatter and XmlSerializer)
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have class with method that inside of it i take complex object and
from it I create new object with simple structure user can work with it
in more convenient way .I store this object instance in the memory and
and provide simple api to it.
I give it name Serializable but I'm not sure that this is the right name.
Transform
TransformToX (where X is the name of the resulting object)
ToX (you see that a lot, for instance, ToString, ToInt32)
I name methods like that using names like asThing(). I suppose in C# it should be AsThing(). Another choice might be to follow the example of Java's Number class: Number.intValue(), etc.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So far I understand that its good practice to XML comment a classes methods but is there a standard for how much you should use XML comments?
Should I be using them to document field variables, properties & constructors or is that just overkill?
Had a look about the web but can't see any hard and fast rules for this sort of thing.
There are two reason to use XML comments opposed to plain English:
If the comments follow the correct format they will show up in IntelliSense, meaning when I use your class I can see that int a is supposed to be the count or whatever the same way I see helpful info when I'm using .NET methods,
If you use the XML formats Microsoft supports you can create html (or other formats of) documentation using SandCastle or similar third party utilities.
So, if you're taking the time to write comments, you may as well make them the XML ones that VS encourages.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Edit -- I'll try to make my question more to the point
I am working with the DataContractSerializer. I noticed that when I instance the serializer, I can specify the Namespace and the Name. Is there any guidance out there (or maybe a best-practice) to describe when I might want to take control of the name and namespace, and what I might want to use for the values?
I was tempted to use the namespace and class name of the class that I am serializing deserializing. Is that a good or bad practice?
DataContractSerialializer is a contract-based serializer, so forwards compatibility shouldn't a huge problem as long as you are adding - and if you do want to rename, you can hide that by adding the old name via attributes. As such, I would say "keep it simple" - trying to get clever is the cause of many bugs.
Re "What do you think?" (comments) - I think I'd rather use protobuf-net, but I'm somewhat biased :p
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm creating a web-related application and I want to add plugin support to it. But I want the plugin dlls to be restricted from everything except my SaveSettings(), RequestPage() and SendToHost() methods. Any good examples how to do that?
You can require your plugins to implement an interface which contains those three methods. In your code then you would call those methods where it is necessary to apply the plugin functionality.
Of course this will not prevent them from executing code within those methods that is not desirable. This becomes more of a security problem in this case. I can't think of a straightforward way of doing this except to load the plugin assemblies into another AppDomain and set security restrictions on the AppDomain about what they can do. This will also of course complicate how you pass data between your plugin and your code.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to generation automatically Resx files for my project, I've heared that there's program which does it.
Can anyone tell me it's name?
The only program I know is Visual Studio. You can easily create your own program by using the ResXResourceWriter class.
As Hans stated, for components such as forms and user controls, you can do this via the "Localizable" property. For other ".resx" files, you can easily create your own localized ".resx" file but it needs to be properly named (you can read up on this - Google for "satellite assemblies" for starters). If your goal is dealing with translations in general however, then unless your app is very small, this approach is difficult, tedious and error-prone (trying to track changed strings on your own for instance, whose existing translations have become obsolete). There are 3rd-party packages that can help you however, and I'm the author of one of them (in the interest of full disclosure). See http://www.hexadigm.com.