internal static void FillItemRef(ItemReference result, IReadOnlyItem elem, bool getKeyedName)
        {
            result.Type = elem.Type().Value;
            if (elem.Attribute("id").Exists)
            {
                result.Unique = elem.Attribute("id").Value;
            }
            else if (elem.Attribute("where").Exists)
            {
                result.Unique = elem.Attribute("where").Value;
            }
            if (getKeyedName)
            {
                if (result.Type == "FileType" && elem.Property("mimetype").HasValue())
                {
                    result.KeyedName = elem.Property("extension").AsString("") + ", "
                                       + elem.Property("mimetype").AsString("");
                }
                else
                {
                    IReadOnlyProperty_Base node = elem.Property("id");
                    if (node.Exists && node.KeyedName().Exists)
                    {
                        result.KeyedName = node.KeyedName().Value;
                    }
                    else
                    {
                        result.KeyedName = node.Attribute("_keyed_name").Value
                                           ?? elem.KeyedName().AsString(null)
                                           ?? elem.Property("name").AsString(null);
                    }

                    node = elem.SourceId();
                    if (node.Exists && node.KeyedName().Exists)
                    {
                        if (result.KeyedName.IsGuid())
                        {
                            var related = elem.RelatedId();
                            if (related.Exists && related.KeyedName().Exists)
                            {
                                result.KeyedName = node.Attribute("keyed_name").Value + " > " + related.Attribute("keyed_name").Value;
                            }
                            else
                            {
                                result.KeyedName = node.Attribute("keyed_name").Value + ": " + result.KeyedName;
                            }
                        }
                        else if (!string.IsNullOrEmpty(node.Attribute("keyed_name").Value))
                        {
                            result.KeyedName += " {" + node.Attribute("keyed_name").Value + "}";
                        }
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>Retrieve the <c>type</c> attribute of the property</summary>
 public static IReadOnlyAttribute Type(this IReadOnlyProperty_Base item)
 {
     return(item.Attribute("type"));
 }
Exemple #3
0
 /// <summary>Retrieve the <c>keyed_name</c> attribute of the property</summary>
 public static IReadOnlyAttribute KeyedName(this IReadOnlyProperty_Base item)
 {
     return(item.Attribute("keyed_name"));
 }
Exemple #4
0
 /// <summary>Retrieve the <c>is_null</c> attribute of the property</summary>
 public static IReadOnlyAttribute IsNull(this IReadOnlyProperty_Base item)
 {
     return(item.Attribute("is_null"));
 }
Exemple #5
0
 /// <summary>Retrieve the <c>condition</c> attribute of the property</summary>
 public static IReadOnlyAttribute Condition(this IReadOnlyProperty_Base item)
 {
     return(item.Attribute("condition"));
 }