public Boolean MoveNext() { if (m_toWalk.Count == 0) { return(false); } m_current = m_toWalk.Pop(); foreach (PropertyInfo info in m_current.GetType().GetProperties()) { if (MapperHelper.IsPrimitive(info.PropertyType) == false) { if (info.PropertyType.Namespace == "System.Collections.Generic") { object obj = ((IEnumerable)info.GetValue(m_current, null)).Cast <object>().ToArray(); //((ICollection)info.GetValue(m_current, null)); Schedule(obj, m_current); } else { Schedule(info.GetValue(m_current, null), null); } } } return(true); }
public void Intercept(IInvocation invocation) { bool isIntercepted = false; string propName = invocation.Method.Name.Replace("get_", ""); if (invocation.Method.Name.StartsWith("get_", StringComparison.OrdinalIgnoreCase)) { Type type = invocation.TargetType.GetProperty(propName).PropertyType; if (MapperHelper.IsPrimitive(type) == false) { isIntercepted = true; invocation.Proceed(); if (invocation.ReturnValue == null) { invocation.ReturnValue = this.DoLazyLoad(type, invocation.Proxy, propName); } Console.WriteLine(type.ToString()); } } if (isIntercepted == false) { invocation.Proceed(); } }
private Node CreateNode(object entity) { Node node = new Node(); node.AddProperty("clazz", entity.GetType().ToString()); entity.GetType().GetProperties().Where(pr => pr.CanRead && MapperHelper.IsAnId(pr) == false).ToList().ForEach(property => { if (MapperHelper.IsPrimitive(property.PropertyType)) { node.AddProperty(property.Name, property.GetValue(entity, null).ToString()); } }); return(node); }
private void UpdateNode(Node nodeToUpdate, object entity) { string propVal = string.Empty; entity.GetType().GetProperties().Where(pr => pr.CanRead && MapperHelper.IsAnId(pr) == false).ToList().ForEach(property => { if (MapperHelper.IsPrimitive(property.PropertyType)) { propVal = property.GetValue(entity, null).ToString(); if (nodeToUpdate.GetProperty(property.Name) != propVal) { nodeToUpdate.SetProperty(property.Name, propVal); } } }); }