Ejemplo n.º 1
0
        public async Task <List <CSpecification> > GetObjectSpecification(string database, string projectuid, string layer, string lcid, string target)
        {
            var content = await communicationManager.GetObjectSpecification(m_Url, database, projectuid, target, lcid, layer, m_Session.Id, serverName);

            if (content == null)
            {
                return(null);
            }
            JArray jarray = JArray.Parse(content);
            List <CSpecification> result = new List <CSpecification>();

            if (jarray == null)
            {
                return(result);
            }

            foreach (var token in jarray)
            {
                CSpecification s = new CSpecification()
                {
                    IsEditable = token.SelectToken("IsEditable").Value <bool>(),
                    IsReauthenticationRequired = token.SelectToken("IsReauthenticationRequired").Value <bool>(),
                    NestedName      = token.SelectToken("NestedName").Value <string>(),
                    ObjectUID       = token.SelectToken("ObjectUID").Value <string>(),
                    OverlayName     = token.SelectToken("OverlayName").Value <string>(),
                    ProjectName     = token.SelectToken("ProjectName").Value <string>(),
                    ClassType       = token.SelectToken("ClassType").Value <string>(),
                    Description     = token.SelectToken("Description").Value <string>(),
                    IsClientPicture = token.SelectToken("IsClientPicture").Value <bool>(),
                    Name            = token.SelectToken("Name").Value <string>(),
                    OverlayUID      = token.SelectToken("OverlayUID").Value <string>(),
                    Picture         = token.SelectToken("Picture").Value <string>(),
                    ProjectUID      = token.SelectToken("ProjectUID").Value <string>(),
                    SystemFullName  = token.SelectToken("SystemFullName").Value <string>(),
                    UID             = token.SelectToken("UID").Value <string>(),
                };

                List <CSpecification> children = new List <CSpecification>();
                var json_children = token.SelectToken("children");
                if (json_children != null && json_children.HasValues)
                {
                    foreach (var child in (JArray)json_children)
                    {
                        CSpecification v = new CSpecification()
                        {
                            ClassType                  = child.SelectToken("ClassType").Value <string>(),
                            ProjectName                = child.SelectToken("ProjectName").Value <string>(),
                            OverlayName                = child.SelectToken("OverlayName").Value <string>(),
                            Description                = child.SelectToken("Description").Value <string>(),
                            IsClientPicture            = child.SelectToken("IsClientPicture").Value <bool>(),
                            IsEditable                 = child.SelectToken("IsEditable").Value <bool>(),
                            IsReauthenticationRequired = child.SelectToken("IsReauthenticationRequired").Value <bool>(),
                            Name           = child.SelectToken("Name").Value <string>(),
                            NestedName     = child.SelectToken("NestedName").Value <string>(),
                            ObjectUID      = child.SelectToken("ObjectUID").Value <string>(),
                            OverlayUID     = child.SelectToken("OverlayUID").Value <string>(),
                            Picture        = child.SelectToken("Picture").Value <string>(),
                            ProjectUID     = child.SelectToken("ProjectUID").Value <string>(),
                            SystemFullName = child.SelectToken("SystemFullName").Value <string>(),
                            UID            = child.SelectToken("UID").Value <string>(),
                            children       = null,
                        };

                        v.CachedValue = "";
                        children.Add(v);
                    }
                    s.children = children;
                }
                result.Add(s);
            }
            return(result);
        }