private List <Keyword> ReadKeywords(BinaryReader r) { var keywords = new List <Keyword>(); var keywordEntries = new List <KeywordEntry>(); ReadMagic(r, CrimsonTags.KEYW); var length = r.ReadUInt32(); var count = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var mask = r.ReadUInt64(); var messageId = r.ReadUInt32(); var nameOffset = r.ReadUInt32(); string name = r.ReadCountedStringAt(nameOffset); keywordEntries.Add( new KeywordEntry { Mask = mask, MessageId = messageId, Name = name, }); var keyword = new Keyword(QName.Parse(name, nsr), Located.Create(mask)); keyword.Message = ResolveMessage(messageId); MarkObject(offset, keyword); keywords.Add(keyword); } foreach (var keyword in keywordEntries) { } return(keywords); }
public static LocatedNullable <bool> GetOptionalBool( this XElement elem, string name, bool?defaultValue = null) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { return(Located.Create(defaultValue)); } if (attrib.Value == "true" || attrib.Value == "1") { return(Located.Create((bool?)true, attrib.GetValueLocation())); } if (attrib.Value == "false" || attrib.Value == "0") { return(Located.Create((bool?)false, attrib.GetValueLocation())); } throw CreateInvalidBoolValueException(attrib); }
private List <Level> ReadLevels(BinaryReader r) { var levels = new List <Level>(); var levelEntries = new List <LevelEntry>(); ReadMagic(r, CrimsonTags.LEVL); var length = r.ReadUInt32(); var count = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var value = r.ReadUInt32(); var messageId = r.ReadUInt32(); var nameOffset = r.ReadUInt32(); string name = r.ReadCountedStringAt(nameOffset); levelEntries.Add( new LevelEntry { Value = value, MessageId = messageId, Name = name, }); var level = new Level(QName.Parse(name, nsr), Located.Create((byte)value)); level.Message = ResolveMessage(messageId); MarkObject(offset, level); levels.Add(level); } foreach (var level in levelEntries) { } return(levels); }
public static LocatedRef <string> GetString(this XElement elem, string name) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { throw CreateMissingAttributeException(elem, name); } return(Located.Create(attrib.Value, attrib.GetValueLocation())); }
public static LocatedRef <string> GetCSymbol( this XElement elem, string name, string defaultValue = null) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { return(Located.Create(defaultValue)); } return(Located.Create(attrib.Value, attrib.GetValueLocation())); }
private List <Event> ReadEvents(BinaryReader r) { var events = new List <Event>(); ReadMagic(r, CrimsonTags.EVNT); uint length = r.ReadUInt32(); uint count = r.ReadUInt32(); uint unk1 = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var desc = ReadEventDescriptor(r); uint messageId = r.ReadUInt32(); uint templateOffset = r.ReadUInt32(); uint opcodeOffset = r.ReadUInt32(); uint levelOffset = r.ReadUInt32(); uint taskOffset = r.ReadUInt32(); uint keywordCount = r.ReadUInt32(); uint keywordsOffset = r.ReadUInt32(); uint channelOffset = r.ReadUInt32(); uint[] keywordOffsets = r.ReadUInt32At(keywordsOffset, keywordCount); var @event = new Event(Located.Create((uint)desc.EventId), Located.Create(desc.Version)); @event.Channel = GetObject <Channel>(channelOffset); @event.Level = GetObject <Level>(levelOffset); @event.Task = GetObject <Task>(taskOffset); @event.Opcode = GetObject <Opcode>(opcodeOffset); foreach (var keywordOffset in keywordOffsets) { var keyword = GetObject <Keyword>(keywordOffset); if (keyword != null) { @event.Keywords.Add(keyword); } } @event.Template = GetObject <Template>(templateOffset); @event.Message = ResolveMessage(messageId); MarkObject(offset, @event); events.Add(@event); } return(events); }
private List <Channel> ReadChannels(BinaryReader r) { var channels = new List <Channel>(); var channelEntries = new List <ChannelEntry>(); ReadMagic(r, CrimsonTags.CHAN); var length = r.ReadUInt32(); var count = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var flags = r.ReadUInt32(); var nameOffset = r.ReadUInt32(); var value = r.ReadUInt32(); var messageId = r.ReadUInt32(); string name = r.ReadCountedStringAt(nameOffset); channelEntries.Add( new ChannelEntry { Flags = (ChannelFlags)flags, Name = name, Value = (byte)value, MessageId = messageId, }); var channel = new Channel(name, Located.CreateStruct(ChannelType.Analytic)); if (value != 0) { channel.Value = (byte)value; } channel.Message = ResolveMessage(messageId); MarkObject(offset, channel); channels.Add(channel); } foreach (var channel in channelEntries) { } return(channels); }
public static LocatedVal <uint> GetUInt32(this XElement elem, string name) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { throw CreateMissingAttributeException(elem, name); } if (!TryParse(attrib.Value, NumberFormat.HexDec, out uint value)) { throw CreateInvalidNumberValueException <uint>(attrib); } return(Located.Create(value, attrib.GetValueLocation())); }
public static LocatedVal <Guid> GetGuid(this XElement elem, string name) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { throw CreateMissingAttributeException(elem, name); } if (!Guid.TryParseExact(attrib.Value, "B", out var value)) { throw CreateInvalidNumberValueException <byte>(attrib); } return(Located.Create(value, attrib.GetValueLocation())); }
public static LocatedVal <ulong> GetHexInt64(this XElement elem, string name) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { throw CreateMissingAttributeException(elem, name); } if (!TryParse(attrib.Value, NumberFormat.PrefixedHex, out ulong value)) { throw CreateInvalidHexNumberValueException <ulong>(attrib); } return(Located.Create(value, attrib.GetValueLocation())); }
public static LocatedRef <QName> GetQName(this XElement elem, string name) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { throw CreateMissingAttributeException(elem, name); } return(Located.Create( QName.Parse(attrib.Value, new XElementNamespaceResolver(elem)), attrib.GetValueLocation())); }
public static LocatedNullable <Guid> GetOptionalGuid( this XElement elem, string name, Guid?defaultValue = null) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { return(Located.Create(defaultValue)); } if (!Guid.TryParseExact(attrib.Value, "B", out var value)) { throw CreateInvalidNumberValueException <byte>(attrib); } return(Located.Create((Guid?)value, attrib.GetValueLocation())); }
public static LocatedNullable <ushort> GetOptionalUInt16( this XElement elem, string name, ushort?defaultValue = null) { if (elem == null) { throw new ArgumentNullException(nameof(elem)); } XAttribute attrib = elem.Attribute(name); if (attrib == null) { return(Located.Create(defaultValue)); } if (!TryParse(attrib.Value, NumberFormat.HexDec, out ushort value)) { throw CreateInvalidNumberValueException <ushort>(attrib); } return(Located.Create((ushort?)value, attrib.GetValueLocation())); }
private List <Task> ReadTasks(BinaryReader r) { var tasks = new List <Task>(); var taskEntries = new List <TaskEntry>(); ReadMagic(r, CrimsonTags.TASK); var length = r.ReadUInt32(); var count = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var value = r.ReadUInt32(); var messageId = r.ReadUInt32(); var guid = r.ReadGuid(); var nameOffset = r.ReadUInt32(); string name = r.ReadCountedStringAt(nameOffset); taskEntries.Add( new TaskEntry { Value = value, MessageId = messageId, Guid = guid, Name = name, }); var task = new Task(QName.Parse(name, nsr), Located.Create((ushort)value)); task.Guid = guid == Guid.Empty ? null : (Guid?)guid; task.Message = ResolveMessage(messageId); MarkObject(offset, task); tasks.Add(task); } foreach (var task in taskEntries) { } return(tasks); }
private List <Tuple <ushort, Opcode> > ReadOpcodes(BinaryReader r) { var opcodes = new List <Tuple <ushort, Opcode> >(); var opcodeEntries = new List <OpcodeEntry>(); ReadMagic(r, CrimsonTags.OPCO); var length = r.ReadUInt32(); var count = r.ReadUInt32(); for (uint i = 0; i < count; ++i) { long offset = r.BaseStream.Position; var taskId = r.ReadUInt16(); var value = r.ReadUInt16(); var messageId = r.ReadUInt32(); var nameOffset = r.ReadUInt32(); string name = r.ReadCountedStringAt(nameOffset); opcodeEntries.Add( new OpcodeEntry { TaskId = taskId, Value = value, MessageId = messageId, Name = name, }); var opcode = new Opcode(QName.Parse(name, nsr), Located.Create((byte)value)); opcode.Message = ResolveMessage(messageId); MarkObject(offset, opcode); opcodes.Add(Tuple.Create(taskId, opcode)); } foreach (var opcode in opcodeEntries) { } return(opcodes); }
public ElementSetGridRegularPoints( ParametersGridRegular grid, Located location, bool fastN) : base(new SpatialDefinition(new Describes("Regular Grid Points", "Point set specified on a regular grid"), -1), ElementType.Point) { GridParameters = grid.Clone() as ParametersGridRegular; PointsLocated = location; FastN = fastN; ElementCount = PointsLocated == Located.CellCentre ? grid.CellCountX * grid.CellCountY : (grid.CellCountX + 1) * (grid.CellCountY + 1); Caption = string.Format("Regular Grid {0}x{1} ({2}, {3})", GridParameters.CellCountX, GridParameters.CellCountY, PointsLocated.ToString(), ElementCount.ToString()); Arguments = new IArgument[] { new ArgumentGridRegular(new Identity("Grid Parameters"), GridParameters), }.ToList(); ElementType = ElementType.Point; }
private Tuple <Map, MapEntry> ReadMap(BinaryReader r) { long offset = r.BaseStream.Position; uint magic = r.ReadUInt32(); if (magic != CrimsonTags.VMAP && magic != CrimsonTags.BMAP) { throw new InternalException("Unknown map magic {0}", magic); } uint length = r.ReadUInt32(); uint nameOffset = r.ReadUInt32(); uint flags = r.ReadUInt32(); uint count = r.ReadUInt32(); var itemEntries = new List <MapItemEntry>(); for (uint i = 0; i < count; ++i) { var value = r.ReadUInt32(); var messageId = r.ReadUInt32(); itemEntries.Add(new MapItemEntry { Value = value, MessageId = messageId }); } if (r.BaseStream.Position != offset + length) { throw new IOException(); } string name = r.ReadCountedStringAt(nameOffset); var mapEntry = new MapEntry { Flags = (MapFlags)flags, Name = name, Items = itemEntries }; var map = magic == CrimsonTags.VMAP ? new ValueMap(name) : (Map) new BitMap(name); foreach (var itemEntry in itemEntries) { var value = Located.Create(itemEntry.Value); var ls = ResolveMessage(itemEntry.MessageId); MapItem item; if (magic == CrimsonTags.VMAP) { item = new ValueMapItem( (ValueMap)map, value, ls); } else { item = new BitMapItem((BitMap)map, value, ls); } map.Items.Add(item); } MarkObject(offset, map); return(Tuple.Create(map, mapEntry)); }
/// <summary> /// This examples creates a NewsML-G2 News Item as shown in the QuickStart NewsML-G2 Text /// document in this package http://www.iptc.org/std/NewsML-G2/2.15/documentation/IPTC-NewsML-G2-QuickStartGuides_2014.zip /// </summary> private void GenerateQuickStartTextExample1() // Code History: // 2014-03-03 mws { // variables global only to this method XmlNode foundNode = null; // *** create an object for the NewsML-G2 News Item var g2NI = new NewsItemPwrXml(); // * add the GUID and the version number to it g2NI.InitEmptyXMLDoc("urn:newsml:acmenews.com:20131121:US-FINANCE-FED", 3); g2NI.SetRootXmlLang("en-US"); // * add the catalogRefs to it g2NI.AddCatalogRef("http://www.iptc.org/std/catalog/catalog.IPTC-G2-Standards_22.xml"); g2NI.AddCatalogRef("http://catalog.acmenews.com/news/ANM_G2_CODES_2.xml"); // ** add a rightsInfo element as wrapper of properties g2NI.CheckAddNarWrapper1(NarDocXml.PropsWrapping1.RightsInfo); // ** add a copyrightHolder // * create a plain object for the copyrightHolder property var copyrightHolder = new CopyrightHolder(); // * create a placeholder for the copyrightHolder element XmlElement copyrightHolderXe = null; // * add the copyrightHolder property to the rightsInfo wrapper and get the new XML element returned g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.RightsInfo, copyrightHolder, out copyrightHolderXe); // * create a structured object for the copyrightHolder element var copyrightHolderSe = new ConceptStructProp() { Uri = "http://www.acmenews.com/about.html#copyright" }; // * property with a value in the text node var crName = new Name("Acme News and Media LLC"); copyrightHolderSe.Names.Add(crName); // * apply this structure to the already created copyrightHolder element copyrightHolderSe.ApplyToElement(g2NI, copyrightHolderXe); // * property with a value in the text node var copyrightNotice = new CopyrightNotice("(c) 2013 Copyright Acme News and Media LLC"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.RightsInfo, copyrightNotice); // ** add an itemMeta element as wrapper of properties g2NI.CheckAddNarWrapper1(NarDocXml.PropsWrapping1.ItemMeta); // ** add a sequence of properties as children of itemMeta // * property using the qcode attribute var itemClass = new ItemClass { qcode = "ninat:text" }; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ItemMeta, itemClass); // * property using the uri attribute var provider = new Provider { uri = "http://www.acmenews.com/about/" }; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ItemMeta, provider); var versionCreated = new VersionCreated("2013-11-21T16:25:32-05:00"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ItemMeta, versionCreated); var embargoed = new Embargoed("2013-11-26T12:00:00-05:00"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ItemMeta, embargoed); var pubStatus = new PubStatus { qcode = "stat:usable" }; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ItemMeta, pubStatus); // ** add a contentMeta element as wrapper of properties g2NI.CheckAddNarWrapper1(NarDocXml.PropsWrapping1.ContentMeta); // ** add a sequence of properties as children of itemMeta var contentCreated = new ContentCreated("2013-11-21T15:21:06-05:00"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, contentCreated); var contentModified = new ContentModified("2013-11-21T16:22:45-05:00"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, contentModified); // * a structured property var located = new Located { qcode = "geoloc:NYC" }; XmlElement locatedXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, located, out locatedXe); var locatedSe = new ConceptStructProp(); locatedSe.Names.Add(new Name("New York, NY")); locatedSe.ApplyToElement(g2NI, locatedXe); var creator = new Creator { uri = "http://www.acmenews.com/staff/mjameson" }; XmlElement creatorXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, creator, out creatorXe); var creatorSe = new ConceptStructProp(); creatorSe.Names.Add(new Name("Meredith Jameson")); creatorSe.ApplyToElement(g2NI, creatorXe); var infoSource = new InfoSource { qcode = "is:AP" }; XmlElement infoSourceXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, infoSource, out infoSourceXe); var infoSourceSe = new ConceptStructProp(); infoSourceSe.Names.Add(new Name("Associated Press")); infoSourceSe.ApplyToElement(g2NI, infoSourceXe); var language = new Language { tag = "en-US" }; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, language); var subject = new Subject { qcode = "medtop:04000000" }; XmlElement subjectXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, subject, out subjectXe); var subjectSe = new ConceptStructProp(); subjectSe.Names.Add(new Name("economy, business and finance")); subjectSe.ApplyToElement(g2NI, subjectXe); // * note: as this is another subject the type definitions of the variables have been removed subject = new Subject { qcode = "medtop:20000350" }; subjectXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, subject, out subjectXe); subjectSe = new ConceptStructProp(); subjectSe.Names.Add(new Name("central bank")); subjectSe.ApplyToElement(g2NI, subjectXe); subject = new Subject { qcode = "medtop:20000379" }; subjectXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, subject, out subjectXe); subjectSe = new ConceptStructProp(); subjectSe.Names.Add(new Name("money and monetary policy")); subjectSe.ApplyToElement(g2NI, subjectXe); var slugline = new Slugline("US-Finance-Fed"); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, slugline); var headline = new Headline("Fed to halt QE to avert \"bubble\""); g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentMeta, headline); // ** add a contentMeta element as wrapper of properties representing the content of the News Item g2NI.CheckAddNarWrapper1(NarDocXml.PropsWrapping1.ContentSet); // ** an inlineXML holds any kind of XML - in its own namespace. var inlineXML = new InlineXML(); XmlElement inlineXmlXe = null; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentSet, inlineXML, out inlineXmlXe); // * the XML content of inlineXML goes into the inner XML of the element inlineXmlXe.InnerXml = "<nitf xmlns='http://iptc.org/std/NITF/2006-10-18/'> <body> <body.head> <hedline> <hl1>Fed to halt QE to avert \"bubble\"</hl1> </hedline> <byline>By Meredith Jameson, <byttl>Staff Reporter</byttl> </byline> </body.head> <body.content> <p>(New York, NY - November 21) Et, sent luptat luptat, commy Nim zzriureet vendreetue modo dolenis ex euisis nosto et lan ullandit lum doloreet vulla. </p> <p>Ugiating ea feugait utat, venim velent nim quis nulluptat num Volorem inci enim dolobor eetuer sendre ercin utpatio dolorpercing. </p> </body.content> </body> </nitf>"; g2NI.AddNarPropertyToWrapper1(NarDocXml.PropsWrapping1.ContentSet, inlineXML); // *** all metadata properties and elements providing the news content have been added // *** Save the serialized XML document g2NI.SaveToFile("QS-Text_1.0-ExampleFull1-generated.xml", true); qsTextEx1Lbl.Text = "Example News Item created."; } // GenerateQuickStartTextExample1
public void UpdateGeometry(IElementSet elementSetEdits) { Contract.Requires(UpdateGeometryAvailable(elementSetEdits), "updateGeometryAvailable(elementSetEdits)"); var es = elementSetEdits as ElementSetGridRegularPoints; GridParameters = es.GridParameters.Clone() as ParametersGridRegular; FastN = es.FastN; PointsLocated = es.PointsLocated; ElementCount = PointsLocated == Located.CellCentre ? GridParameters.CellCountX * GridParameters.CellCountY : (GridParameters.CellCountX + 1) * (GridParameters.CellCountY + 1); Version = elementSetEdits.Version; ElementType = elementSetEdits.ElementType; SpatialReferenceSystemWkt = elementSetEdits.SpatialReferenceSystemWkt; }
private Provider ReadWevtBlock(Guid providerId, BinaryReader r) { ReadMagic(r, CrimsonTags.WEVT); uint length = r.ReadUInt32(); uint messageId = r.ReadUInt32(); uint count = r.ReadUInt32(); var lists = new List <ProviderListOffset>(); for (uint i = 0; i < count; ++i) { var plo = new ProviderListOffset(); plo.Type = (EventFieldKind)r.ReadUInt32(); plo.Offset = r.ReadUInt32(); lists.Add(plo); } var providerMessage = ResolveMessage(messageId); string providerName = string.Format( CultureInfo.InvariantCulture, "Provider_{0:N}", providerId); string providerSymbol = providerName; Guid? controlGuid = null; Guid? groupGuid = null; var allOpcodes = new List <Tuple <ushort, Opcode> >(); var levels = new List <Level>(); var tasks = new List <Task>(); var keywords = new List <Keyword>(); var events = new List <Event>(); var channels = new List <Channel>(); var maps = new List <Map>(); var templates = new List <Template>(); var filters = new List <Filter>(); Dictionary <uint, EventAttributeInfo> eventAttribMap = null; foreach (var list in lists) { r.BaseStream.Position = list.Offset; switch (list.Type) { case EventFieldKind.Level: levels.AddRange(ReadLevels(r)); break; case EventFieldKind.Task: tasks.AddRange(ReadTasks(r)); break; case EventFieldKind.Opcode: allOpcodes.AddRange(ReadOpcodes(r)); break; case EventFieldKind.Keyword: keywords.AddRange(ReadKeywords(r)); break; case EventFieldKind.Event: events.AddRange(ReadEvents(r)); break; case EventFieldKind.Channel: channels.AddRange(ReadChannels(r)); break; case EventFieldKind.Maps: maps.AddRange(ReadMaps(r)); break; case EventFieldKind.Template: templates.AddRange(ReadTemplates(r)); break; case EventFieldKind.Filter: filters.AddRange(ReadFilters(r)); break; case EventFieldKind.ProviderAttribs: ReadProviderAttribs(r, out providerName, out controlGuid, out groupGuid); break; case EventFieldKind.EventAttribs: eventAttribMap = ReadEventAttribs(r); break; default: break; } } if (eventAttribMap != null) { foreach (var evt in events) { var key = evt.Value.Value | (uint)(evt.Version.Value << 16); if (eventAttribMap.TryGetValue(key, out var entry)) { if (entry.Name != null) { evt.Name = entry.Name; } if (entry.Attributes != null) { evt.Attributes.AddRange(entry.Attributes); } } } } var provider = new Provider(providerName, Located.Create(providerId), providerName) { Message = providerMessage, ControlGuid = controlGuid, GroupGuid = groupGuid, }; provider.Levels.AddRange(levels); provider.Tasks.AddRange(tasks); provider.Keywords.AddRange(keywords); provider.Events.AddRange(events); provider.Channels.AddRange(channels); provider.Maps.AddRange(maps); provider.Templates.AddRange(templates); provider.Filters.AddRange(filters); provider.Opcodes.AddRange(allOpcodes.Where(x => x.Item1 == 0).Select(x => x.Item2)); foreach (var taskSpecificOpcode in allOpcodes.Where(x => x.Item1 != 0)) { var task = provider.Tasks.First(x => x.Value == taskSpecificOpcode.Item1); task.Opcodes.Add(taskSpecificOpcode.Item2); } return(provider); }