public static void LoadFeatureSetting(
            ContentFeature feature,
            XmlNode featureSettingNode)
        {
            if (feature == null)
            {
                return;
            }
            if (featureSettingNode == null)
            {
                return;
            }

            if (featureSettingNode.Name == "featureSetting")
            {
                ContentFeatureSetting featureSetting = new ContentFeatureSetting();

                XmlAttributeCollection attributeCollection
                    = featureSettingNode.Attributes;

                if (attributeCollection["resourceFile"] != null)
                {
                    featureSetting.resourceFile = attributeCollection["resourceFile"].Value;
                }

                if (attributeCollection["resourceKey"] != null)
                {
                    featureSetting.resourceKey = attributeCollection["resourceKey"].Value;
                }

                if (attributeCollection["defaultValue"] != null)
                {
                    featureSetting.defaultValue = attributeCollection["defaultValue"].Value;
                }

                if (attributeCollection["controlType"] != null)
                {
                    featureSetting.controlType = attributeCollection["controlType"].Value;
                }

                if (attributeCollection["controlSrc"] != null)
                {
                    featureSetting.controlSrc = attributeCollection["controlSrc"].Value;
                }

                if (attributeCollection["helpKey"] != null)
                {
                    featureSetting.helpKey = attributeCollection["helpKey"].Value;
                }

                if (attributeCollection["sortOrder"] != null)
                {
                    try
                    {
                        featureSetting.sortOrder = Convert.ToInt32(attributeCollection["sortOrder"].Value);
                    }
                    catch (System.FormatException) { }
                    catch (System.OverflowException) { }
                }

                if (attributeCollection["regexValidationExpression"] != null)
                {
                    featureSetting.regexValidationExpression = attributeCollection["regexValidationExpression"].Value;
                }

                feature.Settings.Add(featureSetting);
            }
        }
Beispiel #2
0
        public static void LoadFeature(
            ContentFeatureConfiguration contentFeatureConfig,
            XmlNode documentElement)
        {
            if (HttpContext.Current == null)
            {
                return;
            }
            if (documentElement.Name != "featureDefinitions")
            {
                return;
            }

            foreach (XmlNode node in documentElement.ChildNodes)
            {
                if (node.Name == "featureDefinition")
                {
                    ContentFeature feature = new ContentFeature();

                    XmlAttributeCollection attributeCollection
                        = node.Attributes;

                    if (attributeCollection["featureGuid"] != null)
                    {
                        feature.featureGuid = new Guid(attributeCollection["featureGuid"].Value);
                    }

                    if (attributeCollection["supportedDatabases"] != null)
                    {
                        feature.supportedDatabases = attributeCollection["supportedDatabases"].Value;
                    }



                    if (attributeCollection["resourceFile"] != null)
                    {
                        feature.resourceFile = attributeCollection["resourceFile"].Value;
                    }

                    if (attributeCollection["excludeFromFeatureList"] != null)
                    {
                        try
                        {
                            feature.excludeFromFeatureList = Convert.ToBoolean(attributeCollection["excludeFromFeatureList"].Value);
                        }
                        catch { }
                    }

                    if (attributeCollection["featureNameReasourceKey"] != null)
                    {
                        feature.featureNameReasourceKey = attributeCollection["featureNameReasourceKey"].Value;
                    }


                    if (attributeCollection["isSearchable"] != null)
                    {
                        try
                        {
                            feature.isSearchable = Convert.ToBoolean(attributeCollection["isSearchable"].Value);
                        }
                        catch { }
                    }

                    if (attributeCollection["supportsPageReuse"] != null)
                    {
                        try
                        {
                            feature.supportsPageReuse = Convert.ToBoolean(attributeCollection["supportsPageReuse"].Value);
                        }
                        catch { }
                    }

                    if (attributeCollection["isCacheable"] != null)
                    {
                        try
                        {
                            feature.isCacheable = Convert.ToBoolean(attributeCollection["isCacheable"].Value);
                        }
                        catch { }
                    }

                    if (attributeCollection["deleteProvider"] != null)
                    {
                        feature.deleteProvider = attributeCollection["deleteProvider"].Value;
                    }


                    if (attributeCollection["searchListNameResourceKey"] != null)
                    {
                        feature.searchListNameResourceKey = attributeCollection["searchListNameResourceKey"].Value;
                    }

                    if (attributeCollection["controlSource"] != null)
                    {
                        feature.controlSource = attributeCollection["controlSource"].Value;
                    }

                    if (!feature.controlSource.EndsWith(".ascx"))
                    {
                        log.Error("could not install feature " + feature.FeatureNameReasourceKey
                                  + ". Invalid ControlSource Setting");

                        return;
                    }

                    if (attributeCollection["icon"] != null)
                    {
                        feature.icon = attributeCollection["icon"].Value;
                    }

                    if (attributeCollection["sortOrder"] != null)
                    {
                        int sort = 300;
                        if (int.TryParse(attributeCollection["sortOrder"].Value,
                                         out sort))
                        {
                            feature.sortOrder = sort;
                        }
                    }

                    if (attributeCollection["defaultCacheTime"] != null)
                    {
                        int cacheTime = 300;
                        if (int.TryParse(attributeCollection["defaultCacheTime"].Value,
                                         out cacheTime))
                        {
                            feature.defaultCacheTime = cacheTime;
                        }
                    }

                    foreach (XmlNode featureSettingNode in node.ChildNodes)
                    {
                        if (featureSettingNode.Name == "featureSetting")
                        {
                            ContentFeatureSetting.LoadFeatureSetting(
                                feature,
                                featureSettingNode);
                        }
                    }

                    if (feature.FeatureGuid == Guid.Empty)
                    {
                        log.Error("could not install feature " + feature.FeatureNameReasourceKey
                                  + ". Invalid FeatureGuid.");
                        return;
                    }

                    string controlPath = feature.controlSource;
                    if (!controlPath.StartsWith("/"))
                    {
                        controlPath = "~/" + controlPath;
                    }
                    else
                    {
                        controlPath = "~" + controlPath;
                    }

                    if (File.Exists(HttpContext.Current.Server.MapPath(controlPath)))
                    {
                        contentFeatureConfig.ContentFeatures.Add(feature);
                    }
                    else
                    {
                        log.Error("could not install feature " + feature.FeatureNameReasourceKey
                                  + ". Invalid ControlSource Setting. Filenot found: " + controlPath);
                    }
                }
            }
        }