Exemplo n.º 1
0
        private JNode BuildOriginalValuesMapNode(StructuralAspect aspect, NamingConvention nc)
        {
            var ovMap = aspect.OriginalValuesMap.ToDictionary(kvp => nc.ClientPropertyNameToServer(kvp.Key), kvp => kvp.Value);
            var cps   = aspect is EntityAspect
        ? ((EntityAspect)aspect).EntityType.ComplexProperties
        : ((ComplexAspect)aspect).ComplexType.ComplexProperties;

            cps.ForEach(cp => {
                var co         = aspect.GetValue(cp.Name);
                var serverName = nc.ClientPropertyNameToServer(cp.Name);
                if (cp.IsScalar)
                {
                    var ovmNode       = BuildOriginalValuesMapNode(((IComplexObject)co).ComplexAspect, nc);
                    ovMap[serverName] = ovmNode;
                }
                else
                {
                    var ovmNodes      = ((IEnumerable)co).Cast <IComplexObject>().Select(co2 => BuildOriginalValuesMapNode(co2.ComplexAspect, nc));
                    ovMap[serverName] = JNode.ToJArray(ovmNodes);
                }
            });
            var result = JNode.BuildMapNode(ovMap);

            return(result);
        }