public static DateTime?ToDateTime(this IPropertyContent propertyContent)
 {
     if (!propertyContent.IsLiteral())
     {
         return(null);
     }
     return(((PropertyContentLiteral)propertyContent).ToDateTime());
 }
 public static int?ToInt(this IPropertyContent propertyContent)
 {
     if (!propertyContent.IsLiteral())
     {
         return(null);
     }
     return(((PropertyContentLiteral)propertyContent).ToInt());
 }
 public static long?ToLong(this IPropertyContent propertyContent)
 {
     if (!propertyContent.IsLiteral())
     {
         return(null);
     }
     return(((PropertyContentLiteral)propertyContent).ToLong());
 }
 /// <summary>
 /// Convert to a compact resource
 /// </summary>
 /// <remarks>
 /// TResourceType must be a compact resource object
 /// </remarks>
 public static TResourceType ToResource <TResourceType>(this IPropertyContent propertyContent)
     where TResourceType : class, IPropertyContent
 {
     if (propertyContent.IsLiteral())
     {
         return(null);
     }
     return(propertyContent as TResourceType);
 }
Ejemplo n.º 5
0
        public static IPropertyContent DeserializePropertyReference(string type, string json)
        {
            IPropertyContent ret = null;

            if (String.IsNullOrEmpty(type) || String.IsNullOrEmpty(json))
            {
                return(null);
            }
            switch (type)
            {
            case PropertyTypes.PROJECT:
                ret = JsonSerializer.DeserializeFromString <ProjectCompact>(json);
                break;

            case PropertyTypes.APPRESULT:
                ret = JsonSerializer.DeserializeFromString <AppResultCompact>(json);
                break;

            case PropertyTypes.SAMPLE:
                ret = JsonSerializer.DeserializeFromString <SampleCompact>(json);
                break;

            case PropertyTypes.RUN:
                ret = JsonSerializer.DeserializeFromString <RunCompact>(json);
                break;

            case PropertyTypes.APPSESSION:
                ret = JsonSerializer.DeserializeFromString <AppSessionCompact>(json);
                break;

            case PropertyTypes.FILE:
                ret = JsonSerializer.DeserializeFromString <FileCompact>(json);
                break;
            }
            return(ret);
        }
 public static PropertyContentMap ToMap(this IPropertyContent propertyContent)
 {
     return(propertyContent as PropertyContentMap);
 }
 public static RunCompact ToRun(this IPropertyContent propertyContent)
 {
     return(propertyContent.ToResource <RunCompact>());
 }
 public static AppResultCompact ToAppResult(this IPropertyContent propertyContent)
 {
     return(propertyContent.ToResource <AppResultCompact>());
 }
 public static SampleCompact ToSample(this IPropertyContent propertyContent)
 {
     return(propertyContent.ToResource <SampleCompact>());
 }
 public static ProjectCompact ToProject(this IPropertyContent propertyContent)
 {
     return(propertyContent.ToResource <ProjectCompact>());
 }
 public static AppSessionCompact ToAppSession(this IPropertyContent propertyContent)
 {
     return(propertyContent.ToResource <AppSessionCompact>());
 }
 public static bool IsLiteral(this IPropertyContent propertyContent)
 {
     return(propertyContent as PropertyContentLiteral != null);
 }
Ejemplo n.º 13
0
 public PropertyItem(string id, IPropertyContent content)
 {
     Id      = id;
     Content = content;
 }
Ejemplo n.º 14
0
 public PropertyItem(string id, IPropertyContent content)
 {
     Id = id;
     Content = content;
 }
 /// <summary>
 /// Sets the property content to a single-value resource reference
 /// </summary>
 public void SetContentReference(IPropertyContent referencedContent)
 {
     Type    = referencedContent.Type;
     Content = referencedContent.Href.ToString();
     Items   = null;
 }