Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        private static void AddDescriptiveFeatureOverrides(XElement root, ref FeatureOverrides overrides)
        {
            var featureTypeElement = root.Elements("featureType")
                                     .FirstOrDefault(e => (string)e.Attribute("class") == "descriptive");

            if (featureTypeElement == null)
            {
                return;
            }

            // Get only the overriding features if they can be found in the descriptive feature cache.
            var list = from element in featureTypeElement.Elements("featureOverride")
                       let phone = (string)element.Attribute("segment")
                                   let fnames = element.Elements("feature").Select(e => e.Value).Where(fname => App.AFeatureCache.Keys.Any(n => n == fname))
                                                where !string.IsNullOrEmpty(phone) && fnames != null && fnames.Count() > 0
                                                select new FeatureOverride {
                Phone = phone, AFeatureNames = fnames.ToArray()
            };

            overrides.AddRange(list);
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Loads the default and project-specific list of overriding phone features.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static FeatureOverrides Load(PaProject project)
        {
            var overrides = new FeatureOverrides(project);

            var filename = GetFileForProject(project.ProjectPathFilePrefix);

            if (!File.Exists(filename))
            {
                return(overrides);
            }

            var root = XElement.Load(filename);

            if (root.Nodes().Count() == 0)
            {
                return(overrides);
            }

            AddDescriptiveFeatureOverrides(root, ref overrides);
            AddDistinctiveFeatureOverrides(root, project, ref overrides);
            return(overrides);
        }
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        private static void AddDistinctiveFeatureOverrides(XElement root, PaProject project,
                                                           ref FeatureOverrides overrides)
        {
            var featureTypeElement = root.Elements("featureType").FirstOrDefault(e =>
                                                                                 (string)e.Attribute("class") == "distinctive" && (string)e.Attribute("set") == project.DistinctiveFeatureSet);

            if (featureTypeElement == null)
            {
                return;
            }

            foreach (var element in featureTypeElement.Elements("featureOverride"))
            {
                var phone = element.Attribute("segment").Value;

                // Get only the overriding feature names if they
                // can be found in the distinctive feature cache.
                var fnames = element.Elements("feature").Select(e => e.Value)
                             .Where(fname => project.BFeatureCache.Keys.Any(n => n == fname)).ToArray();

                if (string.IsNullOrEmpty(phone) || fnames.Length == 0)
                {
                    continue;
                }

                var foverride = overrides.GetOverridesForPhone(phone);
                if (foverride == null)
                {
                    foverride = new FeatureOverride {
                        Phone = phone
                    };
                    overrides.Add(foverride);
                }

                foverride.BFeatureNames = fnames;
            }
        }