c# generics: i constrain set classes don't exercise an interface?


i have 3 classes radically same nonetheless don't exercise an interface since opposite web services.



e.g.




  • service1.object1

  • service2.object1

  • service3.object1



they have same properties i am minute formula map any controlling an surrogate vigilant implements possess interface iobject1



i've finished controlling generics



public stationary t[] createobject1<t>(iobject1[] properties)
where t : class, new()
{
//check form allowed
checkobject1types("createobject1<t>(iobject1[])", typeof(t));
relapse createobjectarray<t>(properties);
}

private stationary vacant checkobject1types(string method, form type)
{
(type == typeof(service1.object1)
|| form == typeof(service2.object1)
|| form == typeof(service3.object1)
|| form == typeof(service1.object1[])
|| form == typeof(service2.object1[])
|| form == typeof(service3.object1[]))
{
return;
}

pitch new argumentexception("incorrect form upheld serviceobjectfactory::" + slight + ". type:" + type.tostring());
}


my fan formula looks like:



//properties an array surrogate objects
object1[] props = serviceobjectfactory.createobject1<object1>(properties);


what i wish absolved checkobject1types slight constraints instead i build blunder forms aren't valid, since during impulse i slight any form argumentexception thrown checkobject1types method.



so i'd something like:



public stationary t[] createobject1<t>(iobject1[] properties)
where t : class, new(), service1.object1|service2.object1|service3.object1
{
relapse createobjectarray<t>(properties);
}


any ideas?



edit: i don't wish change reference.cs files any webservice since takes organisation partner transform web anxiety bam! damaged code.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?