Пример #1
0
        /// <summary>
        /// Gets the view from metadata.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="container">The container.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static T GetView <T>(this IMetadataContainer container, object context)
        {
            var viewMetadata = container.GetMetadata <ViewMetadata>();

            return(viewMetadata == null
                       ? default(T)
                       : viewMetadata.GetView <T>(context));
        }
Пример #2
0
        /// <summary>
        /// Stores the view in metadata.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="view">The view.</param>
        /// <param name="context">The context.</param>
        /// <param name="useWeakReference">Indicates whether the view should be referenced weakly.</param>
        public static void SetView(this IMetadataContainer container, object view, object context, bool useWeakReference)
        {
            var viewMetadata = container.GetMetadata <ViewMetadata>();

            if (viewMetadata == null)
            {
                viewMetadata = new ViewMetadata();
                container.AddMetadata(viewMetadata);
            }

            viewMetadata.SetView(view, context, useWeakReference);
        }
Пример #3
0
        public static Dictionary <string, string> GetAllMetadata(this IMetadataContainer container)
        {
            var count = container.GetMetadataCount();

            if (count < 0)
            {
                throw new ArgumentException("Metadata container does not support iteration");
            }
            var output = new Dictionary <string, string>();

            for (var i = 0; i < count; i++)
            {
                string key = container.GetKeyByIndex(i);
                output[key] = container.GetMetadata(key);
            }
            return(output);
        }