public void ReadXml(XmlReader reader) { Title = reader.GetAttribute(ATTR.title); Command = reader.GetAttribute(ATTR.command); Arguments = reader.GetAttribute(ATTR.arguments) ?? string.Empty; InitialDirectory = reader.GetAttribute(ATTR.initial_directory) ?? string.Empty; OutputToImmediateWindow = reader.GetBoolAttribute(ATTR.output_to_immediate_window); ReportTitle = reader.GetAttribute(ATTR.report_title); PreviousCommandLineArgs = reader.GetAttribute(ATTR.argument_generated) ?? string.Empty; ArgsCollectorDllPath = reader.GetAttribute(ATTR.argscollector_dll_path) ?? string.Empty; ArgsCollectorClassName = reader.GetAttribute(ATTR.argscollector_class_name) ?? string.Empty; ToolDirPath = reader.GetAttribute(ATTR.tool_dir_path) ?? string.Empty; PackageVersion = reader.GetAttribute(ATTR.package_version) ?? string.Empty; PackageIdentifier = reader.GetAttribute(ATTR.package_identifier) ?? string.Empty; PackageName = reader.GetAttribute(ATTR.package_name) ?? string.Empty; UpdateAvailable = reader.GetBoolAttribute(ATTR.update_available); Annotations = new List <AnnotationDef>(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); reader.ReadElementList(EL.annotation, Annotations); reader.ReadEndElement(); } else { reader.Read(); } Validate(); }
public static void ReadElementList <TItem>(this XmlReader reader, Enum name, List <TItem> list) { reader.ReadElementList(name, list, new XmlElementHelper <TItem>()); }
public void ReadXml(XmlReader reader) { // Read start tag attributes ExcludeNTermAAs = reader.GetIntAttribute(ATTR.start); MinPeptideLength = reader.GetIntAttribute(ATTR.min_length); MaxPeptideLength = reader.GetIntAttribute(ATTR.max_length); AutoSelect = reader.GetBoolAttribute(ATTR.auto_select); var list = new List<PeptideExcludeRegex>(); // Consume tag if (reader.IsEmptyElement) reader.Read(); else { reader.ReadStartElement(); // Read child elements reader.ReadElementList(EL.peptide_exclusions, list); reader.ReadEndElement(); } Exclusions = list; DoValidate(); }
public void ReadXml(XmlReader reader) { var list = new List<TypedModifications>(); var internalStandardTypes = new[] {IsotopeLabelType.heavy}; MaxVariableMods = reader.GetIntAttribute(ATTR.max_variable_mods, DEFAULT_MAX_VARIABLE_MODS); MaxNeutralLosses = reader.GetIntAttribute(ATTR.max_neutral_losses, DEFAULT_MAX_NEUTRAL_LOSSES); // Consume tag if (reader.IsEmptyElement) { list.Add(new TypedModifications(IsotopeLabelType.light, new StaticMod[0])); reader.Read(); } else { var internalStandardNames = new List<string>(); string internalStandardName = reader.GetAttribute(ATTR.internal_standard); reader.ReadStartElement(); if (internalStandardName != null) { if (internalStandardName == IsotopeLabelType.NONE_NAME) internalStandardTypes = new IsotopeLabelType[0]; else internalStandardNames.Add(internalStandardName); } else { while (reader.IsStartElement(EL.internal_standard)) { internalStandardNames.Add(reader.GetAttribute(ATTR.name)); reader.Read(); } } if (internalStandardNames.Count > 0) internalStandardTypes = new IsotopeLabelType[internalStandardNames.Count]; SetInternalStandardType(IsotopeLabelType.light, internalStandardNames, internalStandardTypes); // Read child elements var listMods = new List<StaticMod>(); reader.ReadElementList(EL.static_modifications, listMods); list.Add(new TypedModifications(IsotopeLabelType.light, listMods)); int typeOrder = IsotopeLabelType.FirstHeavy; while (reader.IsStartElement(EL.heavy_modifications)) { // If first heavy tag has no isotope_label attribute, use the default heavy type var labelType = IsotopeLabelType.heavy; string typeName = reader.GetAttribute(ATTR.isotope_label); if (!string.IsNullOrEmpty(typeName)) { labelType = new IsotopeLabelType(typeName, typeOrder); if (Equals(labelType, IsotopeLabelType.heavy)) labelType = IsotopeLabelType.heavy; // If the created label type is going to be used and there are serialization // context modifications, try to use the label types from the context. else if (_serializationContext != null) { var modsContext = _serializationContext.GetModificationsByName(typeName); if (modsContext != null) { // CONSIDER: Should this require full equality, including order? labelType = modsContext.LabelType; } } } else if (typeOrder > IsotopeLabelType.FirstHeavy) { throw new InvalidDataException( string.Format(Resources.PeptideModifications_ReadXml_Heavy_modifications_found_without__0__attribute, ATTR.isotope_label)); } typeOrder++; SetInternalStandardType(labelType, internalStandardNames, internalStandardTypes); // If no internal standard type was given, use the first heavy type. if (internalStandardNames.Count == 0 && internalStandardTypes.Length != 0) { internalStandardNames.Add(labelType.Name); internalStandardTypes = new[] {labelType}; } listMods = new List<StaticMod>(); reader.ReadElementList(EL.heavy_modifications, listMods); list.Add(new TypedModifications(labelType, listMods)); } int iMissingType = internalStandardTypes.IndexOf(labelType => labelType == null); if (iMissingType != -1) { throw new InvalidDataException(string.Format(Resources.PeptideModifications_ReadXml_Internal_standard_type__0__not_found, internalStandardNames[iMissingType])); } reader.ReadEndElement(); } if (list.Count < 2) list.Add(new TypedModifications(IsotopeLabelType.heavy, new StaticMod[0])); _modifications = MakeReadOnly(list.ToArray()); InternalStandardTypes = internalStandardTypes; DoValidate(); }