コード例 #1
0
 private static DateTime?GetDateFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         return(meta.GetValue(fieldname) as DateTime?);
     }
     return(null);
 }
コード例 #2
0
 private static string GetTextFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         return meta.GetValue(fieldname).ToString();
     }
     return null;
 }
コード例 #3
0
 private static string GetTextFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         return(meta.GetValue(fieldname).ToString());
     }
     return(null);
 }
コード例 #4
0
 private static string GetTextFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         object value = meta.GetValue(fieldname);
         return (value == null) ? null : value.ToString();
     }
     return null;
 }
コード例 #5
0
 private static string GetTextFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         object value = meta.GetValue(fieldname);
         return((value == null) ? null : value.ToString());
     }
     return(null);
 }
コード例 #6
0
 public static object GetPageCustomMetaValue(Page page, string keyName)
 {
     using (CustomMeta meta = GetPageCustomMeta(page))
     {
         if (meta != null)
         {
             return(meta.GetFirstValue(keyName));
         }
         return(null);
     }
 }
コード例 #7
0
        /// <summary>
        /// Converts a <see cref="T:Tridion.ContentDelivery.Meta.CustomMeta" /> to a <see cref="T:TcmCDService.Contracts.CustomMeta" /> data contract.
        /// </summary>
        /// <param name="customMeta"><see cref="T:Tridion.ContentDelivery.Meta.CustomMeta" /></param>
        /// <returns><see cref="I:System.Collections.Generic.IEnumerable{TcmCDService.Contracts.CustomMeta}" /></returns>
        internal static IEnumerable <Contracts.CustomMeta> ToContract(this CustomMeta customMeta)
        {
            if (customMeta != null)
            {
                List <Contracts.CustomMeta> result = new List <Contracts.CustomMeta>();

                foreach (NameValuePair metaValue in customMeta.NameValues.Values)
                {
                    try
                    {
                        Contracts.CustomMeta contract = new Contracts.CustomMeta()
                        {
                            Name     = metaValue.Name,
                            DataType = (Contracts.CustomMetaType)metaValue.ValueType
                        };

                        switch (metaValue.ValueType)
                        {
                        case (int)Contracts.CustomMetaType.String:
                            contract.StringValues = metaValue.MultipleValues.Cast <String>();
                            break;

                        case (int)Contracts.CustomMetaType.Date:
                            contract.DateTimeValues = metaValue.MultipleValues.Cast <DateTime>().Select(d => DateTime.SpecifyKind(d, DateTimeKind.Unspecified));
                            break;

                        case (int)Contracts.CustomMetaType.Float:
                            contract.FloatValues = metaValue.MultipleValues.Cast <float>();
                            break;
                        }

                        result.Add(contract);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("CustomMeta: Error parsing value {0}.", ex, metaValue.Name);
                    }
                }

                return(result);
            }

            return(null);
        }
コード例 #8
0
 private static DateTime? GetDateFromCustomMeta(CustomMeta meta, string fieldname)
 {
     if (meta.NameValues.Contains(fieldname))
     {
         return meta.GetValue(fieldname) as DateTime?;
     }
     return null;
 }
コード例 #9
0
 public static CustomMeta CreateCustomMeta(int ID, int itemId, int itemType, int publicationId, string keyName)
 {
     CustomMeta customMeta = new CustomMeta();
     customMeta.Id = ID;
     customMeta.ItemId = itemId;
     customMeta.ItemType = itemType;
     customMeta.PublicationId = publicationId;
     customMeta.KeyName = keyName;
     return customMeta;
 }
コード例 #10
0
 public void AddToCustomMetas(CustomMeta customMeta)
 {
     base.AddObject("CustomMetas", customMeta);
 }