Esempio n. 1
0
        public static void SetTranslation(this IContentList <DetailCollection> collections, string key, string value, string collectionKey = DefaultCollectionKey)
        {
            if (string.IsNullOrEmpty(key))
            {
                return;
            }

            var collection = collections[collectionKey];
            var detail     = collection.Details.Where(cd => cd.Meta == key).FirstOrDefault();

            if (detail == null)
            {
                if (value == null)
                {
                    return;
                }
                detail = new ContentDetail(collection.EnclosingItem, collection.Name, value)
                {
                    Meta = key
                };
                detail.AddTo(collection);
            }
            else if (value == null)
            {
                collection.Details.Remove(detail);
            }
            else
            {
                detail.StringValue = value;
            }
        }