Я определил интерфейс и класс ниже [code] public interface IXmlKey { string Name { get; set; } string Value { get; set; } bool HasChildren { get; set; } }
public interface IXmlKey : IXmlKey where T : IXmlKey { public T[] Children { get; set; } } [/code] и метод, код [code]private static bool ReadSubXmlKeys(XmlReader subReader, IXmlKey objInstance, bool hasChildren, out string error) { error = null;
var childrenProp = objInstance.GetType().GetProperties().Single(p => p.Name.Equals("Children")); var childType = childrenProp.PropertyType.GetElementType(); var childPis = childType.GetProperties();
var generateList = typeof(List).MakeGenericType(childType);
var childrenList = Activator.CreateInstance(generateList); var childrenListType = childrenList.GetType();
//public static bool Any(this IEnumerable source, Func predicate) var fun = typeof(Func).MakeGenericType(childType, typeof(bool));
var anyMethod = typeof(Enumerable).GetMethodWithLinq("Any", typeof(IEnumerable), typeof(Func)).MakeGenericMethod(childType);
var startNodeName = objInstance.Name;
do { var nodeName = subReader.Name; //var isExist = anyMethod.Invoke(null, [childrenList, ]); ---> here
} while (subReader.Read());
return true; } [/code] как видите, я не уверен, какой правильный параметр следует вызывать List.Any(t => t.Name.Equals(nodeName)), где T : IXmlKey Пожалуйста, помогите.
Я определил интерфейс и класс следующим образом:
public interface IXmlKey
{
string Name { get; set; }
string Value { get; set; }
bool HasChildren { get; set; }
}
public interface IXmlKey : IXmlKey where T : IXmlKey
{
public T[] Children { get; set;...
Я работаю над каким-то похожим на Spring Di Framework, и я столкнулся с проблемой, сканирующей все классы, аннотированные с определенной аннотацией. @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Component {}...
Я работаю над каким-то похожим на Spring Di Framework, и я столкнулся с проблемой, сканирующей все классы, аннотированные с определенной аннотацией. @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Component {}...