private static Dictionary <string, PropertyInfo> GetNodeProperties <TNode>() where TNode : IGraphElement { var nodeType = typeof(TNode).Name; lock (NodeProperties) { if (NodeProperties.TryGetValue(nodeType, out Dictionary <string, PropertyInfo> result)) { return(result); } var nodePropsDic = typeof(TNode) .GetProperties() .Where(x => x.CanRead && x.CanWrite) .Where(x => x.MemberType == MemberTypes.Property && x.PropertyType.IsPublic) .Where(x => !x.PropertyType.IsSubclassOf(typeof(IEnumerable))) .Where(x => x.GetSetMethod() != null && (x.GetSetMethod().Attributes & MethodAttributes.Static) == 0) .ToDictionary(x => x.Name, x => x); NodeProperties[nodeType] = nodePropsDic; return(nodePropsDic); } }