Пример #1
0
 public ResPatchOperation(Group parent, String path) : base(parent, path)
 {
     ResourceSet   = new PatchResourceSet(base.Condition, parent, null);
     _resourceSets = new List <PatchResourceSet>()
     {
         ResourceSet
     };
 }
Пример #2
0
        private Boolean EvaluatePatchResourceSet(PatchResourceSet set, String fileName)
        {
            // you can't move this to PatchResourceSet.Evaluate because it contains references to protected members

            if (set.ParentGroup != null)
            {
                if (set.ParentGroup.Evaluate() != EvaluationResult.True)
                {
                    return(false);
                }
            }

            if (!String.IsNullOrEmpty(set.ConditionHash))
            {
                String currentHash = PackageUtility.GetMD5Hash(fileName);
                if (!String.Equals(set.ConditionHash, currentHash, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }

            if (set.Condition != null)
            {
                Dictionary <String, Double> symbols = GetSymbols(fileName);

                try {
                    Double result = set.Condition.Evaluate(symbols);

                    if (result != 1)
                    {
                        return(false);
                    }
                } catch (ExpressionException ex) {
                    if (Package != null)
                    {
                        Package.Log.Add(LogSeverity.Warning, "Expression evaluation exception: " + ex.Message);
                    }

                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public ResPatchOperation(Group parent, XmlElement operationElement) : base(parent, operationElement)
        {
            ResourceSet   = new PatchResourceSet(base.Condition, parent, ConditionHash);
            _resourceSets = new List <PatchResourceSet>()
            {
                ResourceSet
            };

            foreach (XmlNode node in operationElement.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                XmlElement child = node as XmlElement;

                if (child.Name != "res")
                {
                    continue;
                }

                PatchResource res = new PatchResource()
                {
                    Type   = child.GetAttribute("type"),
                    Name   = child.GetAttribute("name"),
                    Lang   = child.GetAttribute("lang"),
                    Source = child.GetAttribute("src"),
                    Add    = child.GetAttribute("add") == "true" || child.GetAttribute("add") == "1"
                };

                if (!res.Source.StartsWith("comp:", StringComparison.Ordinal))
                {
                    res.Source = P.Combine(parent.Package.RootDirectory.FullName, res.Source);
                }

                ResourceSet.Resources.Add(res);
            }
        }