Hi All ,
I have a data contract as shown below. I am trying to pass this from a C# application to a method in C++ (where i need to convert it to native C++ and then to manged C++ (C++/CLI).
My question is in this data contract i have a list of data contracts inside one data contract. While I am trying to send this to native C++ and then to Manged C++ (i have converted the Datacontract to a structure in C++.
But i am not sure how handle (Marshall) data types like
object (in C#) and List of dataContracts (in C#) to native and then Manged C++.
I know that if it is a string from C# , i can Marshall as as follows to convert it to Managed C++. but i do not know how to Marshall C# data types like "
object" and
list of datacontracts. to manged C++.
wsdc->UserID = Marshal::PtrToStringAnsi((IntPtr) (char *) sdc.UserID);
In short , I need to convert the attached C# datacontract to native C++ code.
In the attached C# data contract , i have data types like "List<datacontacts>" and "object" .
I would like to know how we can convert the above data contracts,list of data contracts ,object datatypes to native C++ datatypes like structures etc..
Please let me know your suggestions/ideas on this.
Appreciate your help.
Thanks,
Sudhakar
<pre lang="c#">
[DataContract(Name = "TopicDetails")]
[Serializable]
public class TopicDetails
{
protected object baseObjectType;
[DataMember]
public object BaseObjectType
{
get
{
return baseObjectType;
}
set
{
baseObjectType = value;
}
}
static public TopicDetails CreateTopic<T, mT>(IComparable<T> objectType, IComparable<mT> objectID)
{
var topicDetails = new TopicDetails();
topicDetails.BaseObjectType = objectType;
return topicDetails;
}
}
[DataContract(Name = "SubscriptionTopic")]
[KnownType(typeof(List<TopicDetails>))]
[Serializable]
public class SubscriptionTopic
{
private object creator;
[DataMember]
public object DBHandle
{
get
{
return creator;
}
set
{
creator = value;
}
}
static public SubscriptionTopic CreateSubscriptions<T, mT, nT>(IList<TopicDetails> topic, IComparable<mT> target, IComparable<nT> handle)
{
var subscriptionTopic = new SubscriptionTopic();
subscriptionTopic.DBHandle = handle;
return subscriptionTopic;
}
}
[DataContract(Name = "SubscriptionData")]
[KnownType(typeof(List<SubscriptionTopic>))]
[Serializable]
public class SubscriptionDataContracts : IExtensibleDataObject
{
private ExtensionDataObject extensionDataObjectValue;
[DataMember]
public List<SubscriptionTopic> TopicList
{
get;
set;
}
public ExtensionDataObject ExtensionData
{
get
{
return extensionDataObjectValue;
}
set
{
extensionDataObjectValue = value;
}
}
}