Beispiel #1
0
        public string DataLink(ROntologyDatatypePropertyDefinition prop)
        {
            SDataLink result         = null;
            SDataLink somelangresult = null;

            foreach (var dprop in DirectProperties <SDataLink>().Where(p => p.Definition == prop))
            {
                if (dprop.Lang == "ru")
                {
                    result = dprop;
                    break;
                }
                if (dprop.Lang == "en")
                {
                    result = dprop;
                }
                else
                {
                    somelangresult = dprop;
                }
            }
            if (result == null && somelangresult != null)
            {
                result = somelangresult;
            }
            return(result == null ? null : result.InnerText);
        }
        public static XObject DmDataField(SGraph.SNode item, SGraph.ROntologyDatatypePropertyDefinition prop)
        {
            string str        = null;
            var    range_name = prop.DirectObjectLinks("range")
                                .Select(p => p.TargetId).FirstOrDefault();

            if (range_name == "string")
            {
                str = item.DataField(prop.Id);
            }
            else if (range_name == "date")
            {
                str = item.DataField(prop.Id);
                str = SSNodeExt.DatePrinted(str);
            }
            else if (range_name == "text")
            {
                str = item.TextField(prop.Id, "ru");
            }
            else if (range_name == "Email")
            {
                str = item.TextField(prop.Id, "ru");
            }
            else if (range_name == "URI")
            {
                string uri_text = item.DataField(prop.Id);
                return(uri_text != null
                           ? new XElement("a",
                                          new XAttribute("href", uri_text),
                                          new XAttribute("target", "external"),
                                          uri_text)
                           : null);
            }
            else if (range_name != null)
            {
                var range_def = StaticModels.sDataModel.OntologyModel.GetItemById(range_name);
                if (range_def != null && range_def.Definition.Id == "EnumerationType")
                {
                    string enum_value = item.DataField(prop.Id);
                    if (enum_value != null)
                    {
                        str = range_def.DirectProperties().Where(p => p.Definition.Id == "state").Cast <SGraph.SDataLink>()
                              .Select(p => p.XOriginal).Where(px =>
                                                              px.Attribute("value").Value == enum_value &&
                                                              px.Attribute(SGraph.SNames.xmllang).Value == "ru")
                              .Select(px => px.Value).FirstOrDefault();
                    }
                }
            }
            return(str == null ? null : new XText(str));
        }