Example #1
0
        JNode IJsonSerializable.ToJNode(Object config)
        {
            var jo = new JNode();

            jo.AddPrimitive("name", this.Name);
            jo.AddPrimitive("entityTypeName", this.EntityTypeName);
            jo.AddPrimitive("isScalar", this.IsScalar);
            jo.AddPrimitive("associationName", this.AssociationName);
            // jo.AddArray("validators", this.Validators);
            jo.AddArray("foreignKeyNames", this.ForeignKeyNames);
            jo.AddArray("invForeignKeyNames", this.InvForeignKeyNames);
            // jo.Add("custom", this.Custom.ToJObject)
            return(jo);
        }
Example #2
0
        JNode IJsonSerializable.ToJNode(Object config)
        {
            var jo = new JNode();

            jo.AddPrimitive("shortName", this.ShortName);
            jo.AddPrimitive("namespace", this.Namespace);
            jo.AddPrimitive("isComplexType", true);
            // jo.AddProperty("baseTypeName", this.BaseTypeName);
            // jo.AddProperty("isAbstract", this.IsAbstract, false);
            jo.AddArray("dataProperties", this.DataProperties.Where(dp => dp.IsInherited == false));
            // jo.AddArrayProperty("validators", this.Validators);
            // jo.AddProperty("custom", this.Custom.ToJObject)
            return(jo);
        }
Example #3
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 #4
0
        JNode IJsonSerializable.ToJNode(object config)
        {
            var jn = new JNode();

            jn.AddPrimitive("entityType", this.EntityType.Name);
            jn.AddArray("values", this.Values);

            return(jn);
        }
Example #5
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 #6
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);
        }
Example #7
0
        JNode IJsonSerializable.ToJNode(Object config)
        {
            var jo = new JNode();

            jo.AddPrimitive("shortName", this.ShortName);
            jo.AddPrimitive("namespace", this.Namespace);
            jo.AddPrimitive("baseTypeName", this.BaseTypeName);
            jo.AddPrimitive("isAbstract", this.IsAbstract, false);
            jo.AddPrimitive("autoGeneratedKeyType", this.AutoGeneratedKeyType.ToString());
            jo.AddPrimitive("defaultResourceName", this.DefaultResourceName);
            jo.AddArray("dataProperties", this.DataProperties.Where(dp => dp.IsInherited == false));
            jo.AddArray("navigationProperties", this.NavigationProperties.Where(np => np.IsInherited == false));
            // jo.AddArrayProperty("validators", this.Validators);
            // jo.AddProperty("custom", this.Custom.ToJObject)
            return(jo);
        }
Example #8
0
        JNode IJsonSerializable.ToJNode(Object config)
        {
            var jn = new JNode();

            jn.AddPrimitive("name", this.Name);
            jn.AddPrimitive("dataType", this.DataType != null ? this.DataType.Name : null);
            jn.AddPrimitive("complexTypeName", this.ComplexType != null ? this.ComplexType.Name : null);
            jn.AddPrimitive("isNullable", this.IsNullable, true);
            jn.AddPrimitive("defaultValue", this.DefaultValue);
            jn.AddPrimitive("isPartOfKey", this.IsPartOfKey, false);
            jn.AddPrimitive("isUnmapped", this.IsUnmapped, false);
            jn.AddPrimitive("isAutoIncrementing", this.IsAutoIncrementing, false);
            jn.AddPrimitive("concurrencyMode", this.ConcurrencyMode == ConcurrencyMode.None ? null : this.ConcurrencyMode.ToString());
            jn.AddPrimitive("maxLength", this.MaxLength);
            jn.AddArray("validators", this.Validators);
            jn.AddPrimitive("enumType", this.EnumTypeName);
            jn.AddPrimitive("isScalar", this.IsScalar, true);
            // jo.AddProperty("custom", this.Custom.ToJObject)
            return(jn);
        }