Getting custom class type returning functions on the Datasnap client autogenerated methods - server

I am using a TDSServerModule in which I place the functions needed.
When I create the TDSAdminClient with the wizard, I get the autogenerated functions from the TDSServerModule, but not all of them.
Some of the functions need a result types of my custom classes
TStringArray = array of string;
TStringArrayOfString = array of TStringArray;
TStringArrayOfArrayOfString = array of TStringArrayOfString;
Those functions are not autogenerated. I changed the result type of them as TObject in order to get the autogenerated ones in the client side.
Then I changed the type to my custom type again in client and server, but the server does not recognize them any way.
How can this be solved?

Related

override equals method in protobuf generated files in flutter

I am using protocol buffers in flutter. I have several objects, one of them is:
message LogTag{
string name = 1;
int32 color = 2;
int32 icon = 3;
}
I have generated necessary dart files using protoc compiler. But, what I want is that its equals method should check only name field to compare 2 LogTag objects in my project.
How can I do this?
Altering the protoc-generated sources will potentially break the generated code's ability to (un)marshal the types into protobuf messages and is strongly discouraged.
If you wish to create user-defined methods that leverage the underlying (generated) types, you should create user-defined classes and convert these to|from the protoc-generated types.
Not only does this permit you to add arbitrary methods but the classes are less tightly-coupled.

Unity Custom Editor - Add Data Fields Based on Derived Type

Final goal: create a custom editor that will let me select from a list of types and then enter additional parameters specific to that type.
To this end, I have created a pure data type, let's call it BasicData, with a SpecificData parameter of an abstract base type, let's call it ExtraData. The idea is to have the type information in BasicData (enum value), and then populate the SpecificData field in the custom editor code so that when I change selection a new object from a class derived from ExtraData. Then its values can be further edited by additional fields created for that specific type, as shown here.
I started doing the above, but I ran into problems trying to get the actual object being edited in order to set the SpecificData property. My classes are not Unity objects or scripts, and I'd rather not turn them into such just for this. I might be able to use reflection to do this but then changes in the editor won't take effect while it runs, from what I understand.
What is the best way to accomplish this?

How to generate a Roslyn TypeExpression for a type that has not yet been generated?

I have a chicken/egg problem here. I am using SyntaxGenerator to generate some classes. Some of these classes will have fields and properties whose types are types generated in other classes. So my question is how can you declare a field in a class that has a type defined in another generated class that has not yet been generated? Do I have to generate and compile all classes that the currently generated class depends on first?
foreach (var attribute in datatype.Attributes)
{
var fieldName = $"_{MessageNode.FormatResourceName(attribute.Name)}";
var fieldNode = Generator.FieldDeclaration(fieldName, Generator.TypeExpression(**???**), Accessibility.Private);
}
Thanks
You can generate any type name you like, whether the type exists or not, using the SyntaxFactory.
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Simplification;
var name = SyntaxFactory
.ParseTypeName("My.Generated.Type")
.WithAdditionalAnnotations(Simplifier.Annotation);
Alternatively, for a simple name, you can use SyntaxFactory.IdentifierName, for a generic name you can use SyntaxFactory.GenericName. Equivalent API's exist to generate Visual Basic as well.

Is IEnumerable<object> the proper container for generic data sets?

Using Entity Framework, is IEnumerable the correct container to use to send back a generic data set? I.e. when I do not want to send back a list of the object, but just a generic a result set.
public IEnumerable<object> SelectPlayerFirstAndLastNameList()
{
return (from p in rlpEntities.Players select new { p.PlayerFirstName, p.PlayerLastName });
}
Thanks.
Here is the reference article, which talks about IList(inherits ICollection( and IEnumerable(Base Generic Interface for IQueryable,ICollection,List).
Here are the links which states generics & it's differences & it's usages,
Difference among IEnumerable , IQueryable, ICollection,IList, List
IEnumerable vs. ICollection vs. IQueryable vs. IList
Looking at your linq, it's about specific object & can be extended further in future. IQueryable is right fit for such scenario, as it gives client to iterate/add/remove items.
Check this link out Why use ICollection and not IEnumerable or List<T> on many-many/one-many relationships?.
It really depends on your scenario, but IEnumerable<> would be used when you need to iterate, and List<> when you need to iterate and modify or sort the data.
IEnunerable<> - http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx
List<> - http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
You can also use generics, to pass on whatever types you are querying against, like for instance
public IEnumerable<T> SelectPlayerFirstAndLastNameList<T>()
{
return (IEnumerable<T>)(from p in rlpEntities.Players);
}
So you can pass either object, or a known defined type. To call this you would do
var x = SelectPlayerFirstAndLastNameList<YourClassHere>();
I think what you have is correct but decide for yourself whether you should use it.
From MSDN: Anonymous Types in the Remarks section:
Anonymous types are class types that derive directly from object, and
that cannot be cast to any type except object.
and
To pass an anonymous type, or a collection that contains anonymous
types, as an argument to a method, you can declare the parameter as
type object. However, doing this defeats the purpose of strong typing.
If you must store query results or pass them outside the method
boundary, consider using an ordinary named struct or class instead of
an anonymous type.

C# dynamic type how to access some methods and slef tracking entities

I have use the type dynamic, a new type in .NET 4.0.
I want to use a dynamic type because I want to use some types that in advance I don't know what type is, but I know that all this possible type has some common methods.
In my case, I am using self tracking entities in entity framework 4.0, and I know that all the entities has the methods markedXXX (to set the state of the entity).
Through the dynamic object that I created, I can access and set the properties of one of this entities, but when I try to execute the MarkedAsXXX method I get an exception that says that the object has not definied the method.
I would like to know how to access to this methods. Is it possible?
Because I have a function that can access to the original values and set this values to the current one, but I need to set the entity as Unchenged.
Thanks.
I want to use a dynamic type because I want to use some types that in advance I don't know what type is, but I know that all this possible type has some common methods.
That suggests you should create an interface with those common methods, and make all the relevant types implement the interface.
Through the dynamic object that I created, I can access and set the properties of one of this entities, but when I try to execute the MarkedAsXXX method I get an exception that says that the object has not defined the method.
It's possible that this is due to explicit interface implementation. If the types have those methods declared as public methods in the normal way, it should be fine.
If you really want to use dynamic typing with these types, is there some base interface which declares the MarkedAsXXX methods, which you could cast the objects to before calling those methods? (I'm not familiar with the entity framework, so I don't know the details of those methods.)
Basically, I would try to avoid dynamic typing unless you really need it, partly because of edge cases like this - but if explicit interface implementation is the cause, then casting to that interface should be fine.
If you define an interface to the dynamically generated classes you can call the methods without the hassle of reflection calling.