Example #1
0
        public RestEntityProperty(object jsonObject, object jsonRootObject, string name, RestEntityType parent) : base(parent)
        {
            XmlTypeCode xmlType;
            Type        type;

            this.JsonRootObject       = jsonRootObject;
            this.JsonObject           = jsonObject;
            this.PathPrefix           = parent.PathPrefix;
            this.ConfigPrefix         = parent.ConfigPrefix;
            this.ControllerNamePrefix = parent.ControllerNamePrefix;

            this.name   = name;
            this.parent = parent;

            this.JsonRootObject = jsonRootObject;
            this.JsonObject     = jsonObject;
            this.NoUIOrConfig   = parent.NoUIOrConfig;

            id = this.MakeID("Property='" + this.name + "'");

            xmlType = TypeMapper.GetXMLType((string)this.JsonObject.type);
            type    = xmlType.GetDotNetType();

            dataType  = new ScalarType(type, this);
            debugInfo = this.GetDebugInfo();
        }
Example #2
0
        public RestNavigationProperty(object jsonRootObject, object jsonObject, object jsonOriginalRootObject, object jsonOriginalObject, string name, RestEntityType parentEntity) : base(parentEntity)
        {
            string _namespace = null;
            string multiplicity;
            var    ancestor         = (IBase)parent;
            var    restEntityParent = (RestEntityBase)parent;
            IEnumerable <IElement> childEntities;

            this.parent = parentEntity;

            this.JsonRootObject         = jsonRootObject;
            this.JsonObject             = jsonObject;
            this.JsonOriginalRootObject = jsonOriginalRootObject;
            this.JsonOriginalObject     = jsonOriginalObject;

            this.NoUIOrConfig         = parentEntity.NoUIOrConfig;
            this.PathPrefix           = parentEntity.PathPrefix;
            this.ConfigPrefix         = parent.ConfigPrefix;
            this.ControllerNamePrefix = parent.ControllerNamePrefix;

            this.name = name;

            id = this.MakeID("Property='" + this.name + "'");

            while (ancestor != null)
            {
                if (ancestor is RestModel)
                {
                    _namespace = ((RestModel)ancestor).Namespace;

                    break;
                }

                ancestor = ancestor.Parent;
            }

            childOrdinal  = 2;
            childEntities = this.ChildElements;

            multiplicity = this.JsonObject.type == "array" ? "*" : "1..1";

            this.ParentMultiplicity    = multiplicity == "*" ? "0..1" : "1..1";
            this.ThisMultiplicity      = multiplicity;
            this.ThisPropertyRefName   = "id";
            this.ParentPropertyRefName = "id";

            if (isCollectionType)
            {
                dataType = new ScalarType(typeof(IEnumerable), this);
                dataType.IsCollectionType = true;
            }
            else
            {
                dataType = new ScalarType(childEntities.Single().GetType(), this);
            }

            this.NoUIOrConfig = parent.NoUIOrConfig;
        }