Serializable class attribute in FSharp - serialization

I have a class developed in F# that must be serializable. How can I set it as serializable? Like [Serializable] in c# using class attribute

You can use [<Serializable>] in the same way that you'd use C#'s [Serializable].

Related

EJB 3.0 Interface class extending Serializable throwing cannot marshal EJB parameters

One of my POJO class is implementing an interface which extends Serializable
My doubt is, As we cant include serialVersionUID in interface class can it result in Cannot Marshal EJB parameters Exception?
You can not pass ,,an interface" as parameter of java method. You can only pass an instance of some class, that implements such interface. That class will be marked as Serializable due to abstraction hierarchy. The Serializable interface is a marker interface, and your implementation class will be serializable even if it does not declare the serialVersionUid attribute(However, it is strongly recommended that you do declare the serialVersionUID).
So to answer your question: as long as the particular instance you pass to your EJB method is marked as serializable it will be fine.

Xml serialization in Silverlight 4

Let say I have following classes:
public class Entity { ... }
public class MyEntity : Entity
{
}
MyEntity can be complex object, which has list of Entity as its property.
I'd like to serialize MyEntity to xml, but only properties of base class, i.e Entity object.
I tried to use DataContractSerializer with DataMemberAttribute, but it seems, starting
with .NET 3.5 it serializes all public properties even if DataMemberAttribute is not applied.
What are my options?
Okay, answer to my own question. My current solution is to implement IXmlSerializable in the base class (Entity class), and not implement this interface for derived classes (MyEntity). Then XmlSerializer serializes public properties of only the base class. Tricky part is implementing IXmlSerializable; especially ReadXml() method. An answer by Paul Alexander (not selected answer!) in the following post was helpful to me:
Reading Xml with XmlReader in C#

What does Public Class [Interface] mean in vb.net?

I saw the following class declaration in vb.net:
Public Class [Interface] Implements TestInterface
What does the above mean? Is there an equivalent in c#?
It's a normal class that is named Interface.
Since Interface is also a keyword, it must be wrapped in brackets to force the compiler to parse it as an identifier.
In C#, you can write public class #interface : TestInterface (It must be lowercase to conflict with the C# keyword).
In either language, don't do this. It's confusing and serves no purpose.

Applying Spring .Net Advice to HibernateTemplate object

I have an class for auditing:
public class AuditAfterAdvise : IAfterReturningAdvice
This is applied to a Dao class in my Spring.Net configuration, using a RegularExpressionMethodPointcutAdvisor.
The Dao class implementation calls HibernateTemplate.SaveOrUpdate(object entity) to commit changes.
I would like to be able to apply AuditAfterAdvise class to the HibernateTemplate SaveOrUpdate() method used in my Dao, rather than the methods on the Dao itself.
The NHibenate/Spring setup is to use a LocalSessionFactoryObject for the Dao. Is this possible?
Thanks.
It certainly should be possible.
Instead of configuring the Dao, add the advice to the object definition for the LocalSessionFactoryObject. The RegularExpressionPointCutAdvisor should continue to work -- just applied to a different object.
I'm assuming the HibernateTemplate is retrieved from a Spring.NET object factory...

is it possible to return an array of object Interface's rather than an object?

I have an interface that describes an specialized list in my application...
Public Interface IAlphabeticListItem
Property StartingLetter() As String
Property DetailsList() As Generic.List(Of DetailsData)
End Interface
Multiple objects implement this interface, but I want to return them in a webservice not as the underlying object, but as the interface.
<WebMethod()> _
Public Function GetCategoryList(...) As Generic.List(Of IAlphabeticListItem)
...
End Function
Sadly, this causes an exception
Cannot serialize interface IAlphabeticListItem.
Exception Details: System.NotSupportedException: Cannot serialize interface IAlphabeticListItem.
Is there a way to make an interface serializable, or am I going to have to convert each of my objects into a concrete class implementing the interface, and then return that class?
Yes and no. You cannot directly expose the generic class for XML serialization because it's not supported. You can however expose a non-generic interface on the same collection and serialize that. This blog goes into great detail on how to make this work
http://srtsolutions.com/blogs/billwagner/archive/2006/11/20/xml-serialization-and-generic-interfaces.aspx
I don't have time to test it right now, but in C# you can extend interfaces, so I suppose you can do that in VB.NET.
Just make IAlphabeticListItem extend ISerializable