Example #1
0
        private JNode ExportAspect(StructuralAspect aspect, IEnumerable <DataProperty> dps)
        {
            var jn = new JNode();

            dps.ForEach((dp) => {
                var propName = dp.Name;
                var value    = aspect.GetRawValue(propName);
                var co       = value as IComplexObject;
                if (co != null)
                {
                    var complexAspect = co.ComplexAspect;
                    jn.AddJNode(propName, ExportAspect(complexAspect, complexAspect.ComplexType.DataProperties));
                }
                else
                {
                    if (value != dp.DefaultValue)
                    {
                        jn.AddPrimitive(propName, value);
                    }
                }
            });
            if (aspect is ComplexAspect)
            {
                var complexAspectNode = ExportComplexAspectInfo((ComplexAspect)aspect);
                jn.AddJNode("complexAspect", complexAspectNode);
            }
            else
            {
                var entityAspectNode = ExportEntityAspectInfo((EntityAspect)aspect);
                jn.AddJNode("entityAspect", entityAspectNode);
            }
            return(jn);
        }
Example #2
0
        private JNode PrepareSaveBundle(IEnumerable <IEntity> entitiesToSave, SaveOptions saveOptions)
        {
            var jn = new JNode();

            jn.AddArray("entities", entitiesToSave.Select(e => EntityToJNode(e)));
            jn.AddJNode("saveOptions", saveOptions);
            return(jn);
        }
Example #3
0
        private JNode BuildEntityAspectNode(EntityAspect entityAspect)
        {
            var nc         = MetadataStore.Instance.NamingConvention;
            var jn         = new JNode();
            var entityType = entityAspect.EntityType;

            jn.AddPrimitive("entityTypeName", entityType.Name);
            jn.AddEnum("entityState", entityAspect.EntityState);
            jn.AddPrimitive("defaultResourceName", entityType.DefaultResourceName);
            jn.AddJNode("originalValuesMap", BuildOriginalValuesMapNode(entityAspect, nc));
            var agkType = entityType.AutoGeneratedKeyType;

            if (agkType != AutoGeneratedKeyType.None)
            {
                var agkNode = new JNode();
                agkNode.AddPrimitive("propertyName", entityType.KeyProperties[0].Name);
                agkNode.AddEnum("autoGeneratedKeyType", agkType);
                jn.AddJNode("autoGeneratedKey", agkNode);
            }
            return(jn);
        }
Example #4
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, dp.DefaultValue);
                }
            });
            return(jn);
        }