Beispiel #1
0
        /// <summary>
        /// Load all the information tasks available.
        /// </summary>
        /// <param name="assembliesDelimited"></param>
        public virtual void Load(string assembliesDelimited)
        {
            if (string.IsNullOrEmpty(assembliesDelimited))
            {
                assembliesDelimited = _defaultAssemblyForExtensions;
            }
            var assemblies = assembliesDelimited.Split(',');

            foreach (var assemblyname in assemblies)
            {
                // This dynamically gets all the classes that have the InfoAttribute on them,
                // which means they return some information.
                var extensions = AttributeHelper.GetClassAttributesFromAssembly <TAttrib>(assemblyname, (pair) =>
                {
                    pair.Value.DeclaringType     = pair.Key.FullName;
                    pair.Value.DeclaringDataType = pair.Key;
                    pair.Value.DeclaringAssembly = assemblyname;
                    if (_onLoadCallback != null)
                    {
                        _onLoadCallback(pair);
                    }
                    Register(pair.Value);
                });
            }
            if (_onLoadCompleteCallback != null)
            {
                _onLoadCompleteCallback();
            }
        }
        /// <summary>
        /// Load widgets from the assembly provided.
        /// </summary>
        /// <param name="assemblyname">Name of assembly to load widgets from.</param>
        /// <param name="author">Override author</param>
        /// <param name="email">Override email</param>
        /// <param name="version">Override version</param>
        /// <param name="url">Ovverride url</param>
        /// <returns></returns>
        public static IList <KeyValuePair <Type, ModelSettings> > LoadFromAssembly(string assemblyname, string author = "kishore reddy", string email = "*****@*****.**", string version = "0.9.4.1", string url = "http://commonlibrarynetcms.codeplex.com")
        {
            var models = AttributeHelper.GetClassAttributesFromAssembly <ModelAttribute>("CommonLibrary.Web.Modules", pair =>
            {
                if (string.IsNullOrEmpty(pair.Value.Name))
                {
                    pair.Value.Name = pair.Key.Name;
                }
                if (string.IsNullOrEmpty(pair.Value.DisplayName))
                {
                    pair.Value.DisplayName = pair.Key.Name;
                }
                if (!string.IsNullOrEmpty(author))
                {
                    pair.Value.Author = author;
                }
                if (!string.IsNullOrEmpty(email))
                {
                    pair.Value.Email = email;
                }
                if (!string.IsNullOrEmpty(version))
                {
                    pair.Value.Version = version;
                }
                if (!string.IsNullOrEmpty(url))
                {
                    pair.Value.Url = url;
                }
                pair.Value.DeclaringType     = pair.Key.FullName;
                pair.Value.DeclaringAssembly = assemblyname;
            });
            var modelDefs = new List <KeyValuePair <Type, ModelSettings> >();

            foreach (var pair in models)
            {
                var model = Convert(pair.Value);
                model.Model = pair.Key;
                modelDefs.Add(new KeyValuePair <Type, ModelSettings>(pair.Key, model));
            }

            return(modelDefs);
        }
        /// <summary>
        /// Load widgets from the assembly provided.
        /// </summary>
        /// <param name="assemblyname">Name of assembly to load widgets from.</param>
        /// <param name="author">Override author</param>
        /// <param name="email">Override email</param>
        /// <param name="version">Override version</param>
        /// <param name="url">Ovverride url</param>
        /// <returns></returns>
        public static IList <KeyValuePair <Type, Widget> > LoadFromAssembly(string assemblyname, string author = "kishore reddy", string email = "*****@*****.**", string version = "0.9.4.1", string url = "http://commonlibrarynetcms.codeplex.com")
        {
            var widgets = AttributeHelper.GetClassAttributesFromAssembly <WidgetAttribute>("CommonLibrary.Web.Modules", pair =>
            {
                if (!string.IsNullOrEmpty(author))
                {
                    pair.Value.Author = author;
                }
                if (!string.IsNullOrEmpty(email))
                {
                    pair.Value.Email = email;
                }
                if (!string.IsNullOrEmpty(version))
                {
                    pair.Value.Version = version;
                }
                if (!string.IsNullOrEmpty(url))
                {
                    pair.Value.Url = url;
                }
                pair.Value.DeclaringType     = pair.Key.FullName;
                pair.Value.DeclaringAssembly = assemblyname;

                // Now setup the included properties comma-delimited list.
                var props = LoadWidgetPropertiesToDisplay(new List <Type>()
                {
                    pair.Key
                }, 1);
                string includedProps         = EnumerableExtensions.JoinDelimited <KeyValuePair <PropertyInfo, PropertyDisplayAttribute> >(props, ",", item => item.Key.Name);
                pair.Value.IncludeProperties = includedProps;
            });
            var widgetdefs = new List <KeyValuePair <Type, Widget> >();

            widgets.ForEach(pair => widgetdefs.Add(new KeyValuePair <Type, Widget>(pair.Key, Convert(pair.Value))));
            return(widgetdefs);
        }