Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SObjectLink"/> class.
 /// </summary>
 /// <param name="x">
 /// The x.
 /// </param>
 /// <param name="source">
 /// The source.
 /// </param>
 public SObjectLink(XElement x, SNode source)
 {
     // _Definition.Id = x.Name;
     Source    = source;
     _targetId = SNode.Coding(x.Attribute(SNames.rdfresource).Value);
     System.DateTime tt1 = System.DateTime.Now;
     if (source._rDataModel is SOntologyModel)
     {
         Definition = ROntologyPropertyDefinition.Abstract(x.Name);
     }
     else
     {
         var def = source._rDataModel.OntologyModel.GetOntologyNode(x.Name.ToString()) as SGraph.ROntologyObjectPropertyDefinition;
         if (def != null)
         {
             Definition = def;
         }
         else
         {
             Definition = source.Definition.DirectPropertyDefinitions <ROntologyObjectPropertyDefinition>()
                          .FirstOrDefault(propDef => propDef.Id == x.Name.ToString())
                          ?? source._rDataModel
                          .OntologyModel
                          .InsertNew <ROntologyObjectPropertyDefinition>(x.Name,
                                                                         source.Definition.Id,
                                                                         Target != null
                                                                 ? Target.Definition.Id
                                                                 : XName.Get("entity"),
                                                                         false);
         }
     }
     //Definition = source._rDataModel is SOntologyModel
     //                 ? ROntologyPropertyDefinition.Abstract(x.Name)
     //                 : source.Definition.DirectPropertyDefinitions<ROntologyObjectPropertyDefinition>()
     //                       .FirstOrDefault(propDef => propDef.Id == x.Name.ToString())
     //                       ?? source._rDataModel
     //                       .OntologyModel
     //                       .InsertNew<ROntologyObjectPropertyDefinition>(x.Name,
     //                                                                     source.Definition.Id,
     //                                                                     Target != null
     //                                                                     ? Target.Definition.Id
     //                                                                     : "entity",
     //                                                                     false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SDataLink"/> class.
        /// вместо статической "пустышки" делаю конструктор с параметрами null, вдруг пригодиться ещё где-то
        /// </summary>
        /// <param name="x">
        /// </param>
        /// <param name="source">
        /// </param>
        public SDataLink(XElement x, SNode source)
        {
            // _Definition.Id = x.Name; // что делать с именем по умолчанию? XName.Get("") не работает
            Source     = source;
            _innerText = x.Value;
            XAttribute langatt = x.Attribute(SNames.xmllang);

            if (langatt != null)
            {
                _lang = langatt.Value;
            }
            //TODO:  Следующий оператор должен был что-то означать, но за ним следовал XOriginal = x;
            //if (x.Attributes().Where(a => a.Name != SNames.xmllang).FirstOrDefault() != null) XOriginal = x;
            if (x.Attributes().Any(att => att.Name != SNames.xmllang))
            {
                XOriginal = XElement.Parse(x.ToString());
            }
            System.DateTime tt1 = System.DateTime.Now;
            if (source._rDataModel is SOntologyModel)
            {
                Definition = ROntologyPropertyDefinition.AbstractDataProp(x.Name);
            }
            else
            {
                var def = source._rDataModel.OntologyModel.GetOntologyNode(x.Name.ToString()) as SGraph.ROntologyDatatypePropertyDefinition;
                if (def != null)
                {
                    Definition = def;
                }
                else
                {
                    Definition = source.Definition.DirectPropertyDefinitions <ROntologyDatatypePropertyDefinition>()
                                 .FirstOrDefault(propDef => propDef.Id == x.Name.ToString())
                                 ?? source._rDataModel.OntologyModel
                                 .InsertNew <ROntologyDatatypePropertyDefinition>(x.Name, source.Definition.Id, "text", false);
                }
            }
            //Definition = source._rDataModel is SOntologyModel
            //                 ? ROntologyPropertyDefinition.AbstractDataProp(x.Name)
            //                 : source.Definition.DirectPropertyDefinitions<ROntologyDatatypePropertyDefinition>()
            //                       .FirstOrDefault(propDef => propDef.Id == x.Name.ToString())
            //                       ?? source._rDataModel.OntologyModel
            //                       .InsertNew<ROntologyDatatypePropertyDefinition>(x.Name, source.Definition.Id, "text", false);
        }