Beispiel #1
0
        /// <summary>
        /// Parses the given XML report.
        /// </summary>
        /// <param name="report">The XML report.</param>
        /// <returns>The parser result.</returns>
        public ParserResult Parse(XContainer report)
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            var assemblies = new List <Assembly>();

            var modules = report.Descendants("Assembly")
                          .ToArray();
            var files = report.Descendants("File").ToArray();

            var assemblyNames = modules
                                .Select(m => m.Attribute("Name").Value)
                                .Distinct()
                                .Where(a => this.AssemblyFilter.IsElementIncludedInReport(a))
                                .OrderBy(a => a)
                                .ToArray();

            foreach (var assemblyName in assemblyNames)
            {
                assemblies.Add(this.ProcessAssembly(modules, files, assemblyName));
            }

            var result = new ParserResult(assemblies.OrderBy(a => a.Name).ToList(), false, this.ToString());

            return(result);
        }
        /// <summary>
        /// Parses the given XML report.
        /// </summary>
        /// <param name="report">The XML report.</param>
        /// <returns>The parser result.</returns>
        public override ParserResult Parse(XContainer report)
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            var assemblies = new List <Assembly>();

            var modules = report.Descendants("Module")
                          .Where(m => m.Attribute("skippedDueTo") == null)
                          .ToArray();
            var files          = report.Descendants("File").ToArray();
            var trackedMethods = report.Descendants("TrackedMethod")
                                 .ToDictionary(t => t.Attribute("uid").Value, t => t.Attribute("name").Value);

            var assemblyNames = modules
                                .Select(m => m.Element("ModuleName").Value)
                                .Distinct()
                                .Where(a => this.AssemblyFilter.IsElementIncludedInReport(a))
                                .OrderBy(a => a)
                                .ToArray();

            foreach (var assemblyName in assemblyNames)
            {
                assemblies.Add(this.ProcessAssembly(modules, files, trackedMethods, assemblyName));
            }

            var result = new ParserResult(assemblies.OrderBy(a => a.Name).ToList(), true, this.ToString());

            return(result);
        }
        /// <summary>
        /// Executes the preprocessing of the report.
        /// </summary>
        /// <param name="report">The report.</param>
        internal void Execute(XContainer report)
        {
            //report.Elements()..att
            //if (report..Attribute("ReportType") != null && report.Attribute("ReportType").Value != "DetailedXml")
            //{

            //}

            bool statementExists = report.Descendants("Assembly")
                                   .Elements("Namespace")
                                   .Elements("Type")
                                   .Descendants("Method")
                                   .Elements("Statement")
                                   .Any();

            if (!statementExists)
            {
                Logger.Error(Resources.ErrorInvalidDotCoverReport);
            }

            foreach (var module in report.Descendants("Assembly").ToArray())
            {
                MoveStartupCodeElementsToParentType(module);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenCoverParser"/> class.
        /// </summary>
        /// <param name="report">The report file as XContainer.</param>
        public OpenCoverParser(XContainer report)
        {
            if (report == null)
            {
                throw new ArgumentNullException("report");
            }

            this.modules = report.Descendants("Module")
                           .Where(m => m.Attribute("skippedDueTo") == null)
                           .ToArray();
            this.files          = report.Descendants("File").ToArray();
            this.trackedMethods = report.Descendants("TrackedMethod")
                                  .ToDictionary(t => t.Attribute("uid").Value, t => t.Attribute("name").Value);

            var assemblyNames = this.modules
                                .Select(m => m.Element("ModuleName").Value)
                                .Distinct()
                                .OrderBy(a => a)
                                .ToArray();

            Parallel.ForEach(assemblyNames, assemblyName => this.AddAssembly(this.ProcessAssembly(assemblyName)));

            this.modules        = null;
            this.files          = null;
            this.trackedMethods = null;
        }
Beispiel #5
0
            public static CredentialsGroup GetFromXElement(XContainer groupElement)
            {
                if (groupElement == null)
                {
                    return(null);
                }

                List <XElement> userElements = groupElement.Descendants("User").ToList();

                if (userElements.Count == 0)
                {
                    return(null);
                }

                List <XElement> rightElements = groupElement.Descendants("Right").ToList();

                if (rightElements.Count == 0)
                {
                    return(null);
                }

                List <string> usernames  = userElements.ConvertAll(element => element.Value.Trim());
                List <string> rightnames = rightElements.ConvertAll(element => element.Value.Trim());

                CredentialsGroup result = new CredentialsGroup
                {
                    Users  = new HashSet <string>(usernames.FindAll(name => name.Trim().Length > 0).ConvertAll(name => name.ToLower())),
                    Rights = new HashSet <string>(rightnames.FindAll(name => name.Trim().Length > 0).ConvertAll(name => name.ToLower()))
                };

                return((result.Users.Count == 0 || result.Rights.Count == 0) ? null : result);
            }
Beispiel #6
0
        private static void CleanUpEmptyElements(this XContainer document)
        {
            // Collapse start and end tags
            document.Descendants().Where(element => string.IsNullOrWhiteSpace(element.Value) && !element.HasElements).ToList().ForEach(x => x.RemoveNodes());

            // Remove empty tags
            document.Descendants().Where(element => element.IsEmpty()).Remove();
        }
Beispiel #7
0
 internal static Stortingsperiode ToStortingsperiode(XContainer p, XNamespace ns)
 {
     return(new Stortingsperiode
     {
         Id = p.Descendants().Where(d => d.Name == ns + "id").Select(d => d.Value).First(),
         Start = DateTime.Parse(p.Descendants().Where(d => d.Name == ns + "fra").Select(d => d.Value).First()),
         Slutt = DateTime.Parse(p.Descendants().Where(d => d.Name == ns + "til").Select(d => d.Value).First())
     });
 }
Beispiel #8
0
    public static XElement FindOrAddElement(this XContainer xml, string nodeName)
    {
        var node = xml.Descendants().FirstOrDefault(x => x.Name == nodeName);

        if (node == null)
        {
            xml.Add(new XElement(nodeName));
        }
        return(xml.Descendants().FirstOrDefault(x => x.Name == nodeName));
    }
Beispiel #9
0
        /// <summary>
        /// Parses the given XML report.
        /// </summary>
        /// <param name="report">The XML report.</param>
        /// <returns>The parser result.</returns>
        public ParserResult Parse(XContainer report)
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            var assemblies = new List <Assembly>();

            var modules = report.Descendants("Module")
                          .Where(m => m.Attribute("skippedDueTo") == null)
                          .ToArray();
            var files = report.Descendants("File").ToArray();

            var trackedMethods = new Dictionary <string, string>();

            foreach (var trackedMethodElement in report.Descendants("TrackedMethod"))
            {
                if (trackedMethods.ContainsKey(trackedMethodElement.Attribute("uid").Value))
                {
                    Logger.WarnFormat(
                        Resources.ErrorNotUniqueTrackedMethodUid,
                        trackedMethodElement.Attribute("name").Value);

                    trackedMethods.Clear();

                    break;
                }
                else
                {
                    trackedMethods.Add(trackedMethodElement.Attribute("uid").Value, trackedMethodElement.Attribute("name").Value);
                }
            }

            var assemblyNames = modules
                                .Select(m => m.Element("ModuleName").Value)
                                .Distinct()
                                .Where(a => this.AssemblyFilter.IsElementIncludedInReport(a))
                                .OrderBy(a => a)
                                .ToArray();

            var assemblyModules = assemblyNames.
                                  ToDictionary(
                k => k,
                v => modules.Where(t => t.Element("ModuleName").Value.Equals(v)).ToArray());

            foreach (var assemblyName in assemblyNames)
            {
                assemblies.Add(this.ProcessAssembly(assemblyModules, files, trackedMethods, assemblyName));
            }

            var result = new ParserResult(assemblies.OrderBy(a => a.Name).ToList(), true, this.ToString());

            return(result);
        }
        private static DateTime GetStartDate(XContainer node)
        {
            var startDate = new DateTime(2000, 1, 1);

            if (node.Descendants("start-date").Any())
            {
                startDate = DateTime.Parse(node.Descendants("start-date").Single().Value);
            }

            return(startDate);
        }
        private static DateTime GetEndDate(XContainer node)
        {
            var endDate = new DateTime(2015, 12, 31);

            if (node.Descendants("end-date").Any())
            {
                endDate = DateTime.Parse(node.Descendants("end-date").Single().Value);
            }

            return(endDate);
        }
        private static string GetLeagueName(XContainer node)
        {
            var leagueName = "no league";

            if (node.Descendants("league").Any())
            {
                leagueName = node.Descendants("league").Single().Value;
            }

            return(leagueName);
        }
Beispiel #13
0
        private static void ParseOrders(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any())
            {
                return;
            }

            var          ordersMapper = new Mapper <Order>(xml.Descendants("Trades").First().Descendants("Order"));
            List <Order> orders       = ordersMapper.ParseAll();

            DateTime lastDate = context.Orders.Any(x => x.AccountID == account.ID)
                ? context.Orders.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var instruments = context.Instruments.ToList();
            var currencies  = context.Currencies.ToList();

            //then add the new ones
            foreach (Order order in orders)
            {
                if (order.TradeDate > lastDate || skipLastDateCheck)
                {
                    order.IsReal = true;
                    if (order.AssetCategory == AssetClass.Cash)
                    {
                        //These are currency trades. But currencies aren't provided in the SecuritiesInfos
                        //So we have to hack around it and add the currency as an instrument "manually" if it's not in yet
                        order.Instrument = TryAddAndGetCurrencyInstrument(order, context);
                    }
                    else
                    {
                        order.Instrument = instruments.FirstOrDefault(x => x.ConID == order.ConID);
                    }

                    order.Account            = account;
                    order.Currency           = currencies.FirstOrDefault(x => x.Name == order.CurrencyString);
                    order.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == order.CommissionCurrencyString);
                    context.Orders.Add(order);
                }
            }
            context.SaveChanges();

            //<Order accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="AAPL"
            //description="APPLE INC" conid="265598" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="--" reportDate="20140325" tradeDate="20140325"
            //tradeTime="093002" settleDateTarget="20140328" transactionType="--" exchange="--" quantity="-48"
            //tradePrice="541.37" multiplier="1" tradeMoney="-25985.76" proceeds="25985.76" taxes="0" ibCommission="-1.574285"
            //ibCommissionCurrency="USD" closePrice="544.99" openCloseIndicator="C" notes="C" cost="-25877.8" fifoPnlRealized="106.385715"
            //mtmPnl="-173.76" origTradePrice="--" origTradeDate="--" origTradeID="--" origOrderID="--" strike="" expiry="" putCall=""
            //buySell="SELL" ibOrderID="537171278" ibExecID="--" brokerageOrderID="--" orderReference="--" volatilityOrderLink="--"
            //orderPlacementTime="--" clearingFirmID="--" exchOrderId="--" extExecID="--" orderTime="20140325;093002" openDateTime="--"
            //holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="ORDER" changeInPrice="--" changeInQuantity="--"
            //netCash="25984.185715" orderType="LMT" />
        }
Beispiel #14
0
 public static IEnumerable <XElement> Descendants(this XContainer container, XName name, bool ignoreNamespace)
 {
     if (ignoreNamespace)
     {
         return(container.Descendants().Where(e => e.Name.LocalName == name.LocalName));
     }
     else
     {
         return(container.Descendants(name));
     }
 }
Beispiel #15
0
        private void FillValidTafor(int airportNumber, XContainer taforParsedXml, List <IGrouping <string, XElement> > airport, int i, string airportId)
        {
            // TAFOR XML
            List <XElement> taforsGroup = (from n in taforParsedXml.Descendants("TAF")
                                           where n.Element("station_id").Value == airport[i].Key
                                           select n.Element("raw_text")).ToList();


            // DATETIME TAFOR
            var             taforUtcList  = new List <DateTime>();
            List <XElement> taforUtcGroup = (from n in taforParsedXml.Descendants("TAF")
                                             where n.Element("station_id").Value == airport[i].Key
                                             select n.Element("issue_time")).ToList();


            // PROCESS TAFOR
            var taforList = new List <string>();

            for (var j = 0; j < taforsGroup.Count(); j++)
            {
                taforList.Add(taforsGroup[j].Value);

                taforUtcList.Add(Convert.ToDateTime(taforUtcGroup[j].Value).ToUniversalTime());
            }


            // If the TAFOR could not be found, we'll try an alternate website
            // This could happen as the AviationWeather TextServer is not always updating correctly
            if (taforsGroup.Count() == 0)
            {
                string   alternateTaforString = String.Empty;
                DateTime alternateTaforUtc    = DateTime.MinValue;

                TryToGetAlternateTaforString(ref alternateTaforString, ref alternateTaforUtc, airportId);

                if (alternateTaforString != String.Empty &&
                    alternateTaforString != @"<html><head>" &&
                    alternateTaforUtc != DateTime.MinValue)
                {
                    taforList.Add(alternateTaforString);
                    taforUtcList.Add(alternateTaforUtc);
                }
                else
                {
                    taforUtcList.Add(DateTime.MinValue);
                }
            }


            // Fill the information in the WxInfoContainer class
            _wxinfo.AirportTaforsUtc.Insert(airportNumber, taforUtcList);
            _wxinfo.AirportTafors.Insert(airportNumber, taforList);
        }
Beispiel #16
0
        private static void ParseExecutions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any())
            {
                return;
            }

            var tradesMapper            = new Mapper <Execution>(xml.Descendants("Trades").First().Descendants("Trade"));
            List <Execution> executions = tradesMapper.ParseAll();

            DateTime lastDate = context.Executions.Any(x => x.AccountID == account.ID)
                ? context.Executions.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var currencies        = context.Currencies.ToList();
            var instruments       = context.Instruments.ToList();
            var orderReferenceSet = new List <long>(); //used to keep track of which orders we have set the order reference for, so we don't do it multiple times

            //then add the new ones
            foreach (Execution i in executions)
            {
                if (i.TradeDate > lastDate || skipLastDateCheck)
                {
                    i.Account            = account;
                    i.Instrument         = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    i.Currency           = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == i.CommissionCurrencyString);
                    var order = context.Orders.FirstOrDefault(x => x.IBOrderID == i.IBOrderID);
                    i.Order = order;
                    if (!string.IsNullOrEmpty(i.OrderReference) && !orderReferenceSet.Contains(i.IBOrderID))
                    {
                        orderReferenceSet.Add(i.IBOrderID);
                        order.OrderReference = i.OrderReference;

                        ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(order, EntityState.Modified);
                    }
                    context.Executions.Add(i);
                }
            }
            context.SaveChanges();

            //<Trade accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="VGK"
            //description="VANGUARD MSCI EUROPEAN ETF" conid="27684070" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="812956946" reportDate="20121231" tradeDate="20121231"
            //tradeTime="160000" settleDateTarget="20130104" transactionType="ExchTrade" exchange="ARCA" quantity="-60" tradePrice="48.84"
            //multiplier="1" tradeMoney="-2930.4" proceeds="2930.4" taxes="0" ibCommission="-1" ibCommissionCurrency="USD" closePrice="48.84"
            //openCloseIndicator="C" notes="P;" cost="-2869.2" fifoPnlRealized="60.2" mtmPnl="0" origTradePrice="0" origTradeDate=""
            //origTradeID="" origOrderID="0" strike="" expiry="" putCall="" buySell="SELL" ibOrderID="415554439"
            //ibExecID="0000d3de.50e1a59d.01.01" brokerageOrderID="" orderReference="" volatilityOrderLink=""
            //orderPlacementTime="" clearingFirmID="" exchOrderId="N/A" extExecID="AD_5629512420665350" orderTime="20121231;142412"
            //openDateTime="--" holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="EXECUTION"
            //changeInPrice="0" changeInQuantity="0" netCash="2929.4" orderType="MOC" />
        }
        public static string GetValue(XContainer product)
        {
            var rrp = product.Descendants("rrp").FirstOrDefault();

            if (rrp != null && !String.IsNullOrEmpty(rrp.Value))
            {
                return(rrp.Value);
            }
            else
            {
                return(product.Descendants("store").FirstOrDefault().Value);
            }
        }
Beispiel #18
0
        void ReadResults(XContainer reader)
        {
            var modules = reader.Descendants("Module").Where(m => m.Attribute("skippedDueTo") == null);

            foreach (XElement file in reader.Descendants("File"))
            {
                AddFileName(file);
            }
            foreach (XElement assembly in modules)
            {
                AddAssembly(assembly);
                RegisterAssembly(assembly);
            }
        }
Beispiel #19
0
        static OpmlDocument GetRawDocument(XContainer root)
        {
            if (root == null)
            {
                return(null);
            }

            var data = new OpmlDocument
            {
                OpmlBody = GetBody(root.Descendants("body").FirstOrDefault()),
                OpmlHead = GetHead(root.Descendants("head").FirstOrDefault(), "ownerEmail", "ownerName", "title", "dateCreated", "dateModified")
            };

            return(data);
        }
Beispiel #20
0
        private static XElement GetOrCreateAssemblyReferenceParentElement(XContainer document)
        {
            var assemblyReference = document.Descendants().FirstOrDefault(f => f.Name.LocalName == ProjectConfigConstants.AssemblyReferenceTagLocalName);

            if (assemblyReference != null)
            {
                return(assemblyReference.Parent);
            }

            var projectElement   = document.Descendants().First(f => f.Name.LocalName == ProjectConfigConstants.ProjectTagName);
            var itemGroupElement = new XElement(ProjectConfigConstants.ItemGroupTagName);

            projectElement.Add(itemGroupElement);
            return(itemGroupElement);
        }
        /// <summary>
        /// Executes the preprocessing of the report.
        /// </summary>
        /// <param name="report">The report.</param>
        internal void Execute(XContainer report)
        {
            var sources = report.Descendants("sources")
                          .Elements("source")
                          .Select(s => s.Value)
                          .ToArray();

            if (sources.Length == 0)
            {
                return;
            }

            var classes = report.Descendants("package")
                          .Elements("classes")
                          .Elements("class")
                          .ToArray();

            if (sources.Length == 1)
            {
                foreach (var @class in classes)
                {
                    var    fileNameAttribute = @class.Attribute("filename");
                    string path = Path.Combine(sources[0], fileNameAttribute.Value)
                                  .Replace('\\', Path.DirectorySeparatorChar)
                                  .Replace('/', Path.DirectorySeparatorChar);
                    fileNameAttribute.Value = path;
                }
            }
            else
            {
                foreach (var @class in classes)
                {
                    foreach (var source in sources)
                    {
                        var    fileNameAttribute = @class.Attribute("filename");
                        string path = Path.Combine(sources[0], fileNameAttribute.Value)
                                      .Replace('\\', Path.DirectorySeparatorChar)
                                      .Replace('/', Path.DirectorySeparatorChar);

                        if (File.Exists(path))
                        {
                            fileNameAttribute.Value = path;
                            break;
                        }
                    }
                }
            }
        }
        /// <exclude />
        public static IEnumerable <FieldReferenceDefinition> GetFieldReferenceDefinitions(XContainer container, string typeManagerName)
        {
            Type type = null;

            foreach (XElement referenceElement in container.Descendants(_fieldReferenceElementName))
            {
                string referencedTypeName = referenceElement.Attribute(_fieldReferenceTypeAttributeName).Value;

                if (referencedTypeName != typeManagerName)
                {
                    type = type ?? TypeManager.TryGetType(typeManagerName);
                    if (type == null)
                    {
                        continue;
                    }

                    Type referencedType = TypeManager.TryGetType(referencedTypeName);
                    if (referencedType == null || !referencedType.Equals(type))
                    {
                        continue;
                    }
                }

                string fieldName = referenceElement.Attribute(_fieldReferenceFieldAttributeName).Value;

                yield return(new FieldReferenceDefinition {
                    FieldName = fieldName, FieldReferenceElement = referenceElement
                });
            }
        }
Beispiel #23
0
        public IEnumerable <IInputOutputViewModel> GetMapping(XContainer xml, bool isInput, ObservableCollection <IInputOutputViewModel> oldMappings)
        {
            var result = new ObservableCollection <IInputOutputViewModel>();

            var input = xml.Descendants(isInput ? "Input" : "Output").FirstOrDefault();

            if (input != null)
            {
                var newMappings = DeserializeMappings(isInput, input);

                foreach (var newMapping in newMappings)
                {
                    var mapping    = newMapping;
                    var oldMapping = oldMappings.FirstOrDefault(m => m.Name.Equals(mapping.Name, StringComparison.InvariantCultureIgnoreCase));
                    if (oldMapping != null)
                    {
                        newMapping.MapsTo = oldMapping.MapsTo;
                        newMapping.Value  = oldMapping.Value;
                    }
                    else
                    {
                        newMapping.IsNew = true;
                    }
                    result.Add(newMapping);
                }
            }
            return(result);
        }
Beispiel #24
0
 /// <summary>
 /// Executes the preprocessing of the report.
 /// </summary>
 /// <param name="report">The report.</param>
 internal void Execute(XContainer report)
 {
     foreach (var module in report.Descendants("Module").ToArray())
     {
         ApplyClassNameToStartupCodeElements(module);
     }
 }
Beispiel #25
0
        /// <summary>
        /// Adds the method to batch for SharePoint
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="command">The command.</param>
        /// <param name="sharePointId">The share point id.</param>
        /// <param name="fields">The fields.</param>
        /// <returns></returns>
        private static void AddMethodToBatch(this XContainer batch, SharePointMethodCommand command, string sharePointId, Dictionary <string, object> fields)
        {
            string Id = "New";

            if (!string.IsNullOrEmpty(sharePointId))
            {
                Id = sharePointId;
            }

            XElement methodElement = new XElement("Method",
                                                  new XAttribute("ID", batch.Descendants().Count() + 1),
                                                  new XAttribute("Cmd", command.ToSharePointString()),
                                                  new XElement("Field",
                                                               new XAttribute("Name", "ID"),
                                                               Id));

            if (fields != null)
            {
                if (fields.Count == 0)
                {
                    return;
                }

                foreach (KeyValuePair <string, object> field in fields)
                {
                    methodElement.Add(new XElement("Field",
                                                   new XAttribute("Name", field.Key),
                                                   field.Value));
                }
            }

            batch.Add(methodElement);
        }
Beispiel #26
0
        public async Task ParseStocks(XContainer variables, XMileModel model)
        {
            if (variables == null)
            {
                throw new ArgumentNullException(nameof(variables));
            }

            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            foreach (var stock in variables.Descendants(_ns + "stock"))
            {
                await Stock.CreateInstance(stock.FirstAttribute.Value,
                                           model,
                                           ParseEquation(stock),
                                           ParseInflows(stock),
                                           ParseOutflows(stock),
                                           ParseGraphicalFunction(stock),
                                           ParseRange(stock, "range"),
                                           ParseRange(stock, "scale"),
                                           ParseNonNegative(stock), ParseAccess(stock));
            }
        }
        /// <exclude />
        public static void Parse(XContainer container)
        {
            IEnumerable <XElement> elements = container.Descendants().ToList();

            foreach (XElement element in elements)
            {
                if (element.Name.Namespace == LocalizationXmlConstants.XmlNamespace)
                {
                    if (element.Name.LocalName == "string")
                    {
                        HandleStringElement(element);
                    }
                    else if (element.Name.LocalName == "switch")
                    {
                        HandleSwitchElement(element);
                    }
                }

                IEnumerable <XAttribute> attributes = element.Attributes().ToList();
                foreach (XAttribute attribute in attributes)
                {
                    Match match = _attributRegex.Match(attribute.Value);
                    if ((match.Success) && (match.Groups["type"].Value == "lang"))
                    {
                        string newValue = StringResourceSystemFacade.ParseString(string.Format("${{{0}}}", match.Groups["id"].Value));
                        attribute.SetValue(newValue);
                    }
                }
            }
        }
Beispiel #28
0
        /// <summary>
        ///     Deserialize the history log file.
        /// </summary>
        /// <param name="logFile">The file path.</param>
        private void Deserialize(XContainer logFile)
        {
            try
            {
                _historyLogs = new List <HistoryLogEntry>();

                foreach (XElement _historyLogEntries in logFile.Descendants("LogEntry"))
                {
                    var    _entryFilePath = _historyLogEntries.Descendants("FilePath").Nodes();
                    string _file          = string.Concat(_entryFilePath);

                    // var _dateModified = _historyLogEntries.Descendants("DateModified").Nodes();
                    // string _dateTime = string.Concat(_dateModified);
                    if (File.Exists(_file))
                    {
                        HistoryLogEntry _historyLogEntry = new HistoryLogEntry(_file);

                        if (!Exists(_historyLogEntry))
                        {
                            _historyLogs.Add(_historyLogEntry);
                        }
                    }
                }

                UpdateMenu();
            }
            catch (Exception e)
            {
                VisualExceptionDialog.Show(e);
            }
        }
Beispiel #29
0
 private static string InnerText(XContainer e)
 {
     return(e.Descendants(W.r)
            .Where(r => r.Parent.Name != W.del)
            .Select(UnicodeMapper.RunToString)
            .StringConcatenate());
 }
Beispiel #30
0
        /// <summary>
        /// Executes the preprocessing of the report.
        /// </summary>
        /// <param name="report">The report.</param>
        internal void Execute(XContainer report)
        {
            var files = report.Descendants("package").Elements("file").ToArray();

            if (this.sourceDirectories.Count == 0)
            {
                foreach (var file in files)
                {
                    if (!Path.IsPathRooted(file.Attribute("path").Value))
                    {
                        Logger.Warn("  " + string.Format(Resources.NoSouceDirectories, "Clover"));
                        return;
                    }
                }

                return;
            }

            foreach (var file in files)
            {
                var pathAttribute = file.Attribute("path");

                pathAttribute.Value = this.GetFullFilePath(pathAttribute.Value);
            }
        }