Use different method for COM- and C#-API -
i've got following class , want create c#-api , com-api same class. because i'm not able create list, want array in com-api.
using system; using system.collections.generic; using system.runtime.interopservices; namespace myapi { [attributeusage(attributetargets.all), classinterface(classinterfacetype.autodispatch), guid("aebe2021-209a-4aee-9a42-04cb82bec1cf")] class dataprovider: system.attribute { int[] data = { 1, 2, 3 }; [comvisibleattribute(false)] public list<int> getdataapi() { //only method should available c#-api return new list<int>(data); } [comvisibleattribute(true)] public int[] getdatacom() //only method should available com { return data; } } }
i know able hide first method comvisibleattribute
com-api. there way hide or limit access of second method c#-api? (i mean normal build)
best solution user-interface give both methods same name.
or missing something? there better way bring list com-interface.
it depends on com client. if it's jscript example, won't able use arrays anyway. in case you'll have provide collection methods getitem(index), etc.
if client vb example, should able use old arraylist instead of array, or implement custom collection class.
you can't prevent .net clients calling public methods, can use editorbrowsableattribute, this:
[editorbrowsable(editorbrowsablestate.never)] public int[] getdatacom()
in case, property hidden auto-completion (unless used same assembly). it's better nothing.
Comments
Post a Comment