示例#1
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["partialView"] != null)
                    {
                        feature.partialView = attributeCollection["partialView"].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);
                    }
                }
            }
        }
        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["grouNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["grouNameKey"].Value;
                }

                if (attributeCollection["groupNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["groupNameKey"].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);

            }
        }
示例#3
0
        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["grouNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["grouNameKey"].Value;
                }

                if (attributeCollection["groupNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["groupNameKey"].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);
            }
        }
        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["grouNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["grouNameKey"].Value;
                }

                if (attributeCollection["groupNameKey"] != null)
                {
                    featureSetting.groupNameKey = attributeCollection["groupNameKey"].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;
                }

                StringBuilder attributes = new StringBuilder();
                StringBuilder options    = new StringBuilder();
                foreach (XmlNode subNode in featureSettingNode)
                {
                    StringBuilder sb = XmlHelper.GetKeyValuePairsAsStringBuilder(subNode.ChildNodes);

                    switch (subNode.Name)
                    {
                    case "Options":
                        featureSetting.options = sb.ToString();
                        break;

                    case "Attributes":
                        featureSetting.attributes = sb.ToString();
                        break;
                        //case "PreTokenString":
                        //	field.PreTokenString = subNode.InnerText.Trim();
                        //	break;
                        //case "PostTokenString":
                        //	field.PostTokenString = subNode.InnerText.Trim();
                        //	break;
                    }
                }
                feature.Settings.Add(featureSetting);
            }
        }