コード例 #1
0
        private JNode BuildOriginalValuesMapNode(StructuralAspect aspect, NamingConvention nc)
        {
            var stType = aspect.StructuralType;
            var ovMap  = aspect.OriginalValuesMap.ToDictionary(
                kvp => stType.GetProperty(kvp.Key).NameOnServer,
                kvp => kvp.Value);
            var cps = stType.ComplexProperties;

            cps.ForEach(cp => {
                var co         = aspect.GetValue(cp.Name);
                var serverName = cp.NameOnServer;
                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);
        }
コード例 #2
0
        private JNode DataToJNode(StructuralAspect aspect)
        {
            var jn    = new JNode();
            var stype = aspect.StructuralType;

            stype.DataProperties.ForEach(dp => {
                var val = aspect.GetValue(dp.Name);
                // handle nonscalar dps
                if (dp.IsComplexProperty)
                {
                    jn.AddJNode(dp.NameOnServer, DataToJNode(((IComplexObject)val).ComplexAspect));
                }
                else
                {
                    jn.AddPrimitive(dp.NameOnServer, val, TypeFns.GetDefaultValue(dp.DataType.ClrType));
                }
            });
            return(jn);
        }
コード例 #3
0
        private JNode DataToJNode(StructuralAspect aspect)
        {
            var jn    = new JNode();
            var stype = aspect.StructuralType;

            stype.DataProperties.ForEach(dp => {
                var val = aspect.GetValue(dp.Name);
                // handle nonscalar dps
                if (dp.IsComplexProperty)
                {
                    jn.AddJNode(dp.NameOnServer, DataToJNode(((IComplexObject)val).ComplexAspect));
                }
                else
                {
                    // always add the val even if equal to the default
                    jn.AddPrimitive(dp.NameOnServer, val);
                }
            });
            return(jn);
        }