Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            // Earlier versions always used decoys only
            UsesDecoys     = reader.GetBoolAttribute(ATTR.uses_decoys, true);
            UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets, false);
            double bias = reader.GetDoubleAttribute(ATTR.bias);

            bool isEmpty = reader.IsEmptyElement;

            // Consume tag
            reader.Read();

            if (!isEmpty)
            {
                // Read calculators
                var calculators = new List <FeatureCalculator>();
                reader.ReadElements(calculators);
                var weights = new double[calculators.Count];
                for (int i = 0; i < calculators.Count; i++)
                {
                    if (calculators[i].Type != PeakFeatureCalculators[i].GetType())
                    {
                        throw new InvalidDataException(Resources.LegacyScoringModel_ReadXml_Invalid_legacy_model_);
                    }
                    weights[i] = calculators[i].Weight;
                }
                Parameters = new LinearModelParams(weights, bias);

                reader.ReadEndElement();
            }

            DoValidate();
        }
Exemplo n.º 3
0
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);
            ControlAnnotation             = reader.GetAttribute(ATTR.control_annotation);
            ControlValue                  = reader.GetAttribute(ATTR.control_value);
            CaseValue                     = reader.GetAttribute(ATTR.case_value);
            IdentityAnnotation            = reader.GetAttribute(ATTR.identity_annotation);
            AverageTechnicalReplicates    = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true);
            NormalizationMethod           = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method));
            IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false);
            SummarizationMethod           = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method));
            ConfidenceLevelTimes100       = reader.GetDoubleAttribute(ATTR.confidence_level, 95);
            PerProtein                    = reader.GetBoolAttribute(ATTR.per_protein, false);
            UseZeroForMissingPeaks        = reader.GetBoolAttribute(ATTR.use_zero_for_missing_peaks, false);
            QValueCutoff                  = reader.GetNullableDoubleAttribute(ATTR.q_value_cutoff);

            var colorRows = new List <MatchRgbHexColor>();

            reader.Read();
            while (reader.IsStartElement(MatchRgbHexColor.XML_ROOT))
            {
                var row = new MatchRgbHexColor();
                row.ReadXml(reader);
                colorRows.Add(row);
            }

            if (colorRows.Any())
            {
                reader.Read();
            }

            ColorRows = ImmutableList <MatchRgbHexColor> .ValueOf(colorRows);
        }
Exemplo n.º 4
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            ColinearWarning = reader.GetBoolAttribute(ATTR.colinear_warning);
            // Earlier versions always used decoys only
            UsesDecoys     = reader.GetBoolAttribute(ATTR.uses_decoys, true);
            UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets);
            double bias = reader.GetDoubleAttribute(ATTR.bias);

            // Consume tag
            reader.Read();

            // Read calculators
            var calculators = new List <FeatureCalculator>();

            reader.ReadElements(calculators);
            var peakFeatureCalculators = new List <IPeakFeatureCalculator>(calculators.Count);
            var weights = new double[calculators.Count];

            for (int i = 0; i < calculators.Count; i++)
            {
                weights[i] = calculators[i].Weight;
                peakFeatureCalculators.Add(PeakFeatureCalculator.GetCalculator(calculators[i].Type));
            }
            SetPeakFeatureCalculators(peakFeatureCalculators);
            Parameters = new LinearModelParams(weights, bias);

            reader.ReadEndElement();

            DoValidate();
        }
Exemplo n.º 5
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Regex          = reader.GetAttribute(ATTR.regex);
            IsIncludeMatch = reader.GetBoolAttribute(ATTR.include);
            IsMatchMod     = reader.GetBoolAttribute(ATTR.match_mod_sequence);
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 6
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            UseForRetentionTimeFilter = reader.GetBoolAttribute(ATTR.use_for_retention_time_prediction, false);
            AnalyteConcentration      = reader.GetNullableDoubleAttribute(ATTR.analyte_concentration);
            SampleType = SampleType.FromName(reader.GetAttribute(ATTR.sample_type));
            // Consume tag
            reader.Read();

            // Check if there is an optimization function element, and read
            // if if there is.
            IXmlElementHelper <OptimizableRegression> helper =
                reader.FindHelper(OPTIMIZATION_HELPERS);

            if (helper != null)
            {
                OptimizationFunction = helper.Deserialize(reader);
            }

            var chromFileInfos = new List <ChromFileInfo>();
            var fileLoadIds    = new List <string>();

            while (reader.IsStartElement(EL.sample_file) ||
                   reader.IsStartElement(EL.replicate_file) ||
                   reader.IsStartElement(EL.chromatogram_file))
            {
                // Note that the file path is actually be a URI that encodes things like lockmass correction as well as filename
                ChromFileInfo chromFileInfo = new ChromFileInfo(MsDataFileUri.Parse(reader.GetAttribute(ATTR.file_path)));
                chromFileInfo = chromFileInfo.ChangeHasMidasSpectra(reader.GetBoolAttribute(ATTR.has_midas_spectra, false));
                chromFileInfos.Add(chromFileInfo);

                string id = reader.GetAttribute(ATTR.id) ?? GetOrdinalSaveId(fileLoadIds.Count);
                fileLoadIds.Add(id);
                reader.Read();
                if (reader.IsStartElement(EL.instrument_info_list))
                {
                    reader.Skip();
                    reader.Read();
                }
            }
            Annotations = SrmDocument.ReadAnnotations(reader);

            MSDataFileInfos = chromFileInfos;
            _fileLoadIds    = fileLoadIds.ToArray();

            // Consume end tag
            reader.ReadEndElement();
        }
Exemplo n.º 7
0
        private static XshdColor ParseColorAttributes(XmlReader reader)
        {
            var color = new XshdColor();

            SetPosition(color, reader);
            color.Foreground    = ParseColor(reader.GetAttribute("foreground"));
            color.Background    = ParseColor(reader.GetAttribute("background"));
            color.FontWeight    = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle     = ParseFontStyle(reader.GetAttribute("fontStyle"));
            color.Underline     = reader.GetBoolAttribute("underline");
            color.Strikethrough = reader.GetBoolAttribute("strikethrough");
            color.FontFamily    = ParseFontFamily(reader.GetAttribute("fontFamily"));
            color.FontSize      = ParseFontSize(reader.GetAttribute("fontSize"));
            return(color);
        }
Exemplo n.º 8
0
 public override void ReadXml(XmlReader reader)
 {
     base.ReadXml(reader);
     ControlAnnotation             = reader.GetAttribute(ATTR.control_annotation);
     ControlValue                  = reader.GetAttribute(ATTR.control_value);
     CaseValue                     = reader.GetAttribute(ATTR.case_value);
     IdentityAnnotation            = reader.GetAttribute(ATTR.identity_annotation);
     AverageTechnicalReplicates    = reader.GetBoolAttribute(ATTR.avg_tech_replicates, true);
     SumTransitions                = reader.GetBoolAttribute(ATTR.sum_transitions, true);
     NormalizationMethod           = NormalizationMethod.FromName(reader.GetAttribute(ATTR.normalization_method));
     IncludeInteractionTransitions = reader.GetBoolAttribute(ATTR.include_interaction_transitions, false);
     SummarizationMethod           = SummarizationMethod.FromName(reader.GetAttribute(ATTR.summarization_method));
     ConfidenceLevelTimes100       = reader.GetDoubleAttribute(ATTR.confidence_level, 95);
     PerProtein                    = reader.GetBoolAttribute(ATTR.per_protein, false);
     reader.Read();
 }
Exemplo n.º 9
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            IsSemiCleaving = reader.GetBoolAttribute(ATTR.semi);
            CleavageC      = reader.GetAttribute(ATTR.cut) ?? reader.GetAttribute(ATTR.cut_c);
            RestrictC      = MakeEmptyNull(reader.GetAttribute(ATTR.no_cut) ?? reader.GetAttribute(ATTR.no_cut_c));
            var type = reader.GetAttribute(ATTR.sense, ToSeqTerminus);

            if (!type.HasValue)
            {
                CleavageN = reader.GetAttribute(ATTR.cut_n);
                RestrictN = MakeEmptyNull(reader.GetAttribute(ATTR.no_cut_n));
            }
            else if (type.Value == SequenceTerminus.N)
            {
                CleavageN = CleavageC;
                CleavageC = null;
                RestrictN = RestrictC;
                RestrictC = null;
            }
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 10
0
        public void ReadXml(XmlReader reader)
        {
            string uri = reader.GetAttribute(Attr.panorama_publish_uri);

            if (!string.IsNullOrEmpty(uri))
            {
                PanoramaPublishUri = new Uri(uri);
            }
            string docGuid = reader.GetAttribute(Attr.document_guid);

            if (!string.IsNullOrEmpty(docGuid))
            {
                DocumentGuid = docGuid;
            }
            AuditLogging = reader.GetBoolAttribute(Attr.audit_logging);

            var allElements = new List <IXmlSerializable>();

            // Consume tag
            if (reader.IsEmptyElement)
            {
                reader.Read();
            }
            else
            {
                reader.ReadStartElement();
                reader.ReadElements(allElements, GetElementHelpers());
                reader.ReadEndElement();
            }
            _annotationDefs      = MakeReadOnly(allElements.OfType <AnnotationDef>());
            _groupComparisonDefs = MakeReadOnly(allElements.OfType <GroupComparisonDef>());
            ViewSpecList         = allElements.OfType <ViewSpecList>().FirstOrDefault() ?? ViewSpecList.EMPTY;
            Lists            = ImmutableList.ValueOf(allElements.OfType <ListData>());
            MetadataRuleSets = ImmutableList.ValueOf(allElements.OfType <MetadataRuleSet>());
        }
Exemplo n.º 11
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context">反序列化上下文</param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            base.Deserialize(component, reader.ReadSubtree(), context);

            var inputField      = (InputField)component;
            var textComponentId = reader.GetIntAttribute(AttributeTextComponent);

            if (textComponentId != 0)
            {
                context.AddReference <Text>(textComponentId, text => { inputField.textComponent = text; });
            }

            inputField.characterLimit      = reader.GetIntAttribute(AttributeCharacterLimit);
            inputField.contentType         = (InputField.ContentType)reader.GetIntAttribute(AttributeContentType);
            inputField.lineType            = (InputField.LineType)reader.GetIntAttribute(AttributeLineType);
            inputField.inputType           = (InputField.InputType)reader.GetIntAttribute(AttributeInputType);
            inputField.keyboardType        = (TouchScreenKeyboardType)reader.GetIntAttribute(AttributeKeyboardType);
            inputField.characterValidation = (InputField.CharacterValidation)reader.GetIntAttribute(AttributeCharacterValidation);

            var placeholderId = reader.GetIntAttribute(AttributePlaceholder);

            if (placeholderId != 0)
            {
                context.AddReference <Text>(textComponentId, placeholder => { inputField.placeholder = placeholder; });
            }
            inputField.caretBlinkRate        = reader.GetFloatAttribute(AttributeCaretBlinkRate);
            inputField.selectionColor        = reader.GetColor32Attribute(AttributeSelectionColor);
            inputField.shouldHideMobileInput = reader.GetBoolAttribute(AttributeHideMobileInput);

            if (reader.ReadToDescendant(ElementText))
            {
                inputField.text = reader.ReadElementString();
            }
        }
Exemplo n.º 12
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Fragment = reader.GetAttribute(ATTR.cut);
            if (IsFragment)
            {
                Restrict          = reader.GetAttribute(ATTR.no_cut);
                Terminus          = reader.GetAttribute(ATTR.sense, ToSeqTerminus);
                MinFragmentLength = reader.GetNullableIntAttribute(ATTR.min_length) ??
                                    DEFAULT_MIN_FRAGMENT_LENGTH;
            }
            else
            {
                var charges = TextUtil.ParseInts(reader.GetAttribute(ATTR.charges)); // Old version?
                if (charges.Length > 1)
                {
                    throw new InvalidDataException(Resources.MeasuredIon_ReadXml_Multiple_charge_states_for_custom_ions_are_no_longer_supported_);
                }
                var    parsedIon = CustomIon.Deserialize(reader);
                Adduct adduct;
                if (charges.Any())  // Old style - fix it up a little for our revised ideas about custom ion ionization
                {
                    adduct = Adduct.FromChargeNoMass(charges[0]);
                    if (string.IsNullOrEmpty(parsedIon.NeutralFormula)) // Adjust the user-supplied masses
                    {
                        SettingsCustomIon = new SettingsCustomIon(parsedIon.NeutralFormula, adduct,
                                                                  Math.Round(parsedIon.MonoisotopicMass + charges[0] * BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision), // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                                                                  Math.Round(parsedIon.AverageMass + charges[0] * BioMassCalc.AVERAGE.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision),           // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                                                                  parsedIon.Name);
                    }
                    else // Adjust the formula to include ion atoms
                    {
                        if (charges[0] > 1) // XML deserializer will have added an H already
                        {
                            var adductProtonated = Adduct.FromChargeProtonated(charges[0] - 1);
                            var formula          = adductProtonated.ApplyToFormula(parsedIon.NeutralFormula);
                            parsedIon = new CustomIon(formula, adduct, parsedIon.MonoisotopicMass, parsedIon.AverageMass, Name);
                        }
                    }
                }
                else
                {
                    adduct = Adduct.FromStringAssumeChargeOnly(reader.GetAttribute(ATTR.charge)); // Ionization mass is already in formula
                }
                if (SettingsCustomIon == null)
                {
                    SettingsCustomIon = new SettingsCustomIon(parsedIon.NeutralFormula, adduct,
                                                              parsedIon.MonoisotopicMass,
                                                              parsedIon.AverageMass,
                                                              parsedIon.Name);
                }
                IsOptional = reader.GetBoolAttribute(ATTR.optional);
            }
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 13
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context"></param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            var outline = (Outline)component;

            outline.effectColor     = reader.GetColor32Attribute(AttributeEffectColor);
            outline.effectDistance  = reader.GetVector2Attribute(AttributeEffectDistance);
            outline.useGraphicAlpha = reader.GetBoolAttribute(AttributeUseGraphicAlpha);
        }
Exemplo n.º 14
0
        public void ReadXml(XmlReader reader)
        {
            SkylineFilePath   = reader.GetAttribute(ATTR.skyline_file_path);
            FolderToWatch     = reader.GetAttribute(ATTR.folder_to_watch);
            IncludeSubfolders = reader.GetBoolAttribute(ATTR.include_subfolders);
            var pattern    = reader.GetAttribute(ATTR.qc_file_pattern);
            var filterType = reader.GetAttribute(ATTR.file_filter_type);

            if (string.IsNullOrEmpty(filterType) && !string.IsNullOrEmpty(pattern))
            {
                // Support for older version where filter type was not written to XML; only regex filters were allowed
                filterType = RegexFilter.NAME;
            }
            QcFileFilter    = FileFilter.GetFileFilter(filterType, pattern);
            RemoveResults   = reader.GetBoolAttribute(ATTR.remove_results, true);
            ResultsWindow   = reader.GetIntAttribute(ATTR.results_window);
            InstrumentType  = reader.GetAttribute(ATTR.instrument_type);
            AcquisitionTime = reader.GetIntAttribute(ATTR.acquisition_time);
        }
Exemplo n.º 15
0
        public void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            MaxMissedCleavages = reader.GetIntAttribute(ATTR.max_missed_cleavages);
            ExcludeRaggedEnds  = reader.GetBoolAttribute(ATTR.exclude_ragged_ends);
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 16
0
        static XshdSpan ParseSpan(XmlReader reader)
        {
            XshdSpan span = new XshdSpan();

            SetPosition(span, reader);
            span.BeginRegex         = reader.GetAttribute("begin");
            span.EndRegex           = reader.GetAttribute("end");
            span.Multiline          = reader.GetBoolAttribute("multiline") ?? false;
            span.SpanColorReference = ParseColorReference(reader);
            span.RuleSetReference   = ParseRuleSetReference(reader);
            if (!reader.IsEmptyElement)
            {
                reader.Read();
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    Debug.Assert(reader.NodeType == XmlNodeType.Element);
                    switch (reader.Name)
                    {
                    case "Begin":
                        if (span.BeginRegex != null)
                        {
                            throw Error(reader, "Duplicate Begin regex");
                        }
                        span.BeginColorReference = ParseColorReference(reader);
                        span.BeginRegex          = reader.ReadElementString();
                        span.BeginRegexType      = XshdRegexType.IgnorePatternWhitespace;
                        break;

                    case "End":
                        if (span.EndRegex != null)
                        {
                            throw Error(reader, "Duplicate End regex");
                        }
                        span.EndColorReference = ParseColorReference(reader);
                        span.EndRegex          = reader.ReadElementString();
                        span.EndRegexType      = XshdRegexType.IgnorePatternWhitespace;
                        break;

                    case "RuleSet":
                        if (span.RuleSetReference.ReferencedElement != null)
                        {
                            throw Error(reader, "Cannot specify both inline RuleSet and RuleSet reference");
                        }
                        span.RuleSetReference = new XshdReference <XshdRuleSet>(ParseRuleSet(reader));
                        reader.Read();
                        break;

                    default:
                        throw new NotSupportedException("Unknown element " + reader.Name);
                    }
                }
            }
            return(span);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context"></param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            var rayCaster = (GraphicRaycaster)component;

            rayCaster.ignoreReversedGraphics = reader.GetBoolAttribute(AttributeIgnoreReversedGraphics);
            rayCaster.blockingObjects        = (GraphicRaycaster.BlockingObjects)reader.GetIntAttribute(AttributeBlockingObjects);

            //被保护的字段,只能通过反射设置
            var mask = (LayerMask)reader.GetIntAttribute(AttributeBlockingMask);

            getBlockMaskFieldInfo().SetValue(rayCaster, mask);
        }
Exemplo n.º 18
0
        static XshdRuleSet ParseRuleSet(XmlReader reader)
        {
            XshdRuleSet ruleSet = new XshdRuleSet();

            SetPosition(ruleSet, reader);
            ruleSet.Name       = reader.GetAttribute("name");
            ruleSet.IgnoreCase = reader.GetBoolAttribute("ignoreCase");

            CheckElementName(reader, ruleSet.Name);
            ParseElements(ruleSet.Elements, reader);
            return(ruleSet);
        }
Exemplo n.º 19
0
        private static XshdColor ParseColorAttributes(XmlReader reader)
        {
            var color = new XshdColor();

            SetPosition(color, reader);

            color.Foreground = ParseColorName(reader.GetAttribute("name"));
            color.Background = ParseColor(reader.GetAttribute("background"));
            color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle  = ParseFontStyle(reader.GetAttribute("fontStyle"));
            color.Underline  = reader.GetBoolAttribute("underline");
            return(color);
        }
Exemplo n.º 20
0
 public override void OnLoadAsset(XmlReader reader)
 {
     base.OnLoadAsset(reader);
     switch (reader.Name)
     {
     case "Skill":
     {
         TargetType  = reader.GetAttrInt("TargetType", 0);
         IncludeSelf = reader.GetBoolAttribute("IncludeSelf", false);
     }
     break;
     }
 }
Exemplo n.º 21
0
        public void ReadXml(XmlReader reader)
        {
            PublishToPanorama = reader.GetBoolAttribute(ATTR.publish_to_panorama);
            PanoramaServerUrl = reader.GetAttribute(ATTR.panorama_server_url);
            PanoramaUserEmail = reader.GetAttribute(ATTR.panorama_user_email);
            PanoramaPassword  = DecryptPassword(reader.GetAttribute(ATTR.panorama_user_password));
            PanoramaFolder    = reader.GetAttribute(ATTR.panorama_folder);

            if (PublishToPanorama)
            {
                PanoramaServerUri = new Uri(PanoramaUtil.ServerNameToUrl(PanoramaServerUrl));
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context">反序列化上下文</param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            var selectable = (Selectable)component;

            selectable.interactable = reader.GetBoolAttribute(AttributeInteractable);
            selectable.transition   = (Selectable.Transition)reader.GetIntAttribute(AttributeTransition);

            switch (selectable.transition)
            {
            case Selectable.Transition.None:
                break;

            case Selectable.Transition.ColorTint:
                var graphicInstanceId = reader.GetIntAttribute(AttributeTargetGraphic);
                context.AddReference <Graphic>(graphicInstanceId, graphic => { selectable.targetGraphic = graphic; });
                var subReader = reader.ReadSubtree();
                subReader.Read();
                if (subReader.Read())
                {
                    selectable.colors = subReader.GetColorBlockElement(ElementColors);
                }
                break;

            case Selectable.Transition.SpriteSwap:
                var graphicInstanceId2 = reader.GetIntAttribute(AttributeTargetGraphic);
                context.AddReference <Graphic>(graphicInstanceId2, graphic => { selectable.targetGraphic = graphic; });
                var subReader2 = reader.ReadSubtree();
                subReader2.Read();
                if (subReader2.Read())
                {
                    reader.GetSpriteStateElement(ElementSpriteState, spriteState => { selectable.spriteState = spriteState; }, context);
                    reader.Skip();
                }
                break;

            case Selectable.Transition.Animation:
                var subReader3 = reader.ReadSubtree();
                subReader3.Read();
                if (subReader3.Read())
                {
                    selectable.animationTriggers = reader.GetAnimationTriggers(ElementAnimationTriggers);
                    reader.Skip();
                }
                break;

            default:
                Debug.LogWarning("Unsupported transition mode " + selectable.transition);
                break;
            }
            reader.GetNavigationElement(ElementNavigation, navigation => { selectable.navigation = navigation; }, context);
        }
Exemplo n.º 23
0
 public override void OnLoadAsset(XmlReader reader)
 {
     base.OnLoadAsset(reader);
     switch (reader.Name)
     {
     case "Effect":
     {
         TargetType    = reader.GetAttrInt("TargetType", 0);
         IncludeTarget = reader.GetBoolAttribute("IncludeTarget", true);
         Radius        = reader.GetAttrFloat("Radius", 0.0f);
     }
     break;
     }
 }
Exemplo n.º 24
0
        static XshdColor ParseColorAttributes(XmlReader reader)
        {
            XshdColor color = new XshdColor();

            SetPosition(color, reader);
            IXmlLineInfo position = reader as IXmlLineInfo;

            color.Foreground = ParseColor(position, reader.GetAttribute("foreground"));
            color.Background = ParseColor(position, reader.GetAttribute("background"));
            color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle  = ParseFontStyle(reader.GetAttribute("fontStyle"));
            color.Underline  = reader.GetBoolAttribute("underline");
            return(color);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context"></param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            var text = (Text)component;

            text.color    = reader.GetColor32Attribute(AttributeColor);
            text.material = reader.GetMaterialElement(ElementMaterial);

            if (reader.ReadToDescendant(ElementText))
            {
                text.text = reader.ReadElementString();
            }

            //Character
            reader.ReadToDescendant(ElementCharacter);
            var font = reader.GetAttribute(AttributeFont);

            if (font != null)
            {
                text.font = Resources.GetBuiltinResource <Font>(font + ".ttf");
            }

            text.fontStyle       = (FontStyle)reader.GetIntAttribute(AttributeFontStyle);
            text.fontSize        = reader.GetIntAttribute(AttributeFontSize);
            text.lineSpacing     = reader.GetFloatAttribute(AttributeLineSpacing);
            text.supportRichText = reader.GetBoolAttribute(AttributeRichText);
            reader.Skip();

            //Paragraph
            reader.ReadToDescendant(ElementParagraph);
            text.alignment = (TextAnchor)reader.GetIntAttribute(AttributeAlignment);
#if UNITY_4_6_1
            text.horizontalOverflow = (HorizontalWrapMode)reader.GetIntAttribute(AttributeHorizontalOverflow);
            text.verticalOverflow   = (VerticalWrapMode)reader.GetIntAttribute(AttributeVerticalOverflow);
#endif
            text.resizeTextForBestFit = reader.GetBoolAttribute(AttributeBestFit);
            reader.Skip();
        }
Exemplo n.º 26
0
        /// <summary>
        /// 从指定的XML中读取并填充<see cref="Component"/>属性。
        /// </summary>
        /// <param name="component">目标组件</param>
        /// <param name="reader">读取器</param>
        /// <param name="context"></param>
        public override void Deserialize(Component component, XmlReader reader, DeserializationContext context)
        {
            var canvas = (Canvas)component;

            canvas.renderMode = (RenderMode)reader.GetIntAttribute(AttributeRenderMode);
            switch (canvas.renderMode)
            {
            case RenderMode.ScreenSpaceOverlay:
                canvas.pixelPerfect = reader.GetBoolAttribute(AttributePixelPerfect);
                canvas.sortingOrder = reader.GetIntAttribute(AttributeSortOrder);
                break;

            case RenderMode.ScreenSpaceCamera:
                canvas.pixelPerfect = reader.GetBoolAttribute(AttributePixelPerfect);
                if (!string.IsNullOrEmpty(reader.GetAttribute(AttributeRenderCamera)))
                {
                    Debug.LogWarning("Resolving render camera not implement yet.");
                }
                canvas.planeDistance  = reader.GetFloatAttribute(AttributePlaneDistance);
                canvas.sortingLayerID = reader.GetIntAttribute(AttributeSortLayer);
                canvas.sortingOrder   = reader.GetIntAttribute(AttributeOrderInLayer);
                break;

            case RenderMode.WorldSpace:
                if (!string.IsNullOrEmpty(reader.GetAttribute(AttributeEventCamera)))
                {
                    Debug.LogWarning("Resolving event camera not implement yet.");
                }
                canvas.sortingLayerID = reader.GetIntAttribute(AttributeSortLayer);
                canvas.sortingOrder   = reader.GetIntAttribute(AttributeOrderInLayer);
                break;

            default:
                Debug.LogWarning("Resolving " + canvas.renderMode + " not implement yet.");
                break;
            }
        }
Exemplo n.º 27
0
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);
            Expression = reader.GetAttribute(ATTR.expr);
            Labeled    = reader.GetBoolAttribute(ATTR.labeled);

            var symbol = reader.GetAttribute(ATTR.symbol_type);

            PointSymbol = symbol == null ? PointSymbol.Circle : Helpers.ParseEnum(symbol, PointSymbol.Circle);

            var pointSize = reader.GetAttribute(ATTR.point_size);

            PointSize = pointSize == null ? PointSize.normal : Helpers.ParseEnum(pointSize, PointSize.normal);

            reader.Read();
        }
Exemplo n.º 28
0
        private static XshtdColor ParseColorAttributes(XmlReader reader, XshtdSyntaxDefinition syntax)
        {
            var color = new XshtdColor(syntax);

            SetPosition(color, reader);

            var position = reader as IXmlLineInfo;

            color.Foreground = ParseColor(position, reader.GetAttribute("foreground"));
            color.Background = ParseColor(position, reader.GetAttribute("background"));
            color.FontWeight = ParseFontWeight(reader.GetAttribute("fontWeight"));
            color.FontStyle  = ParseFontStyle(reader.GetAttribute("fontStyle"));
            color.Underline  = reader.GetBoolAttribute("underline");

            return(color);
        }
Exemplo n.º 29
0
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);
            reader.ReadStartElement();
            var columns = new List <GridColumn>();

            while (reader.IsStartElement(El.grid_column))
            {
                var name    = reader.GetAttribute(Attr.name);
                var visible = reader.GetBoolAttribute(Attr.visible);
                var width   = reader.GetIntAttribute(Attr.width);
                columns.Add(new GridColumn(name, visible, width));
                reader.Read();
            }
            _columns = ImmutableList.ValueOf(columns);
            reader.ReadEndElement();
        }
Exemplo n.º 30
0
 public override void OnLoadAsset(XmlReader reader)
 {
     base.OnLoadAsset(reader);
     switch (reader.Name)
     {
     case "Effect":
     {
         TargetType  = reader.GetAttrInt("TargetType", 0);
         IncludeSelf = reader.GetBoolAttribute("IncludeSelf", true);
         Modifier    = reader.GetAttrFloat("Modifier", 0.0f);
         StatBase    = reader.GetAttrInt("StatBase", 0);
         FlatValue   = reader.GetAttrInt("FlatValue", 0);
         TargetStat  = reader.GetAttrInt("TargetStat", 0);
     }
     break;
     }
 }
Exemplo n.º 31
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            // Earlier versions always used decoys only
            UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true);
            UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets, false);
            double bias = reader.GetDoubleAttribute(ATTR.bias);

            bool isEmpty = reader.IsEmptyElement;

            // Consume tag
            reader.Read();

            if (!isEmpty)
            {
                // Read calculators
                var calculators = new List<FeatureCalculator>();
                reader.ReadElements(calculators);
                var weights = new double[calculators.Count];
                for (int i = 0; i < calculators.Count; i++)
                {
                    if (calculators[i].Type != PeakFeatureCalculators[i].GetType())
                        throw new InvalidDataException(Resources.LegacyScoringModel_ReadXml_Invalid_legacy_model_);
                    weights[i] = calculators[i].Weight;
                }
                Parameters = new LinearModelParams(weights, bias);

                reader.ReadEndElement();
            }

            DoValidate();
        }
Exemplo n.º 32
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Fragment = reader.GetAttribute(ATTR.cut);
            if (IsFragment)
            {
                Restrict = reader.GetAttribute(ATTR.no_cut);
                Terminus = reader.GetAttribute(ATTR.sense, ToSeqTerminus);
                MinFragmentLength = reader.GetNullableIntAttribute(ATTR.min_length) ??
                    DEFAULT_MIN_FRAGMENT_LENGTH;
            }
            else
            {
                var charges = TextUtil.ParseInts(reader.GetAttribute(ATTR.charges)); // Old version?
                if (charges.Count() > 1)
                    throw new InvalidDataException(Resources.MeasuredIon_ReadXml_Multiple_charge_states_for_custom_ions_are_no_longer_supported_);
                SettingsCustomIon = SettingsCustomIon.Deserialize(reader);
                if (charges.Any())  // Old style - fix it up a little for our revised ideas about custom ion ionization
                {
                    Charge = charges[0];
                    if (string.IsNullOrEmpty(SettingsCustomIon.Formula)) // Adjust the user-supplied masses
                    {
                        SettingsCustomIon = new SettingsCustomIon(SettingsCustomIon.Formula,
                            Math.Round(SettingsCustomIon.MonoisotopicMass + BioMassCalc.MONOISOTOPIC.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision), // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                            Math.Round(SettingsCustomIon.AverageMass + BioMassCalc.AVERAGE.GetMass(BioMassCalc.H), SequenceMassCalc.MassPrecision), // Assume user provided neutral mass.  Round new value easiest XML roundtripping.
                            SettingsCustomIon.Name);
                    }
                }
                else
                {
                    Charge = reader.GetIntAttribute(ATTR.charge);
                }
                IsOptional = reader.GetBoolAttribute(ATTR.optional);
            }
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 33
0
        public void ReadXml(XmlReader reader)
        {
            Pick = reader.GetEnumAttribute(ATTR.pick, PeptidePick.library);
            PeptideCount = reader.GetNullableIntAttribute(ATTR.peptide_count);
            HasDocumentLibrary = reader.GetBoolAttribute(ATTR.document_library);

            _rankIdName = reader.GetAttribute(ATTR.rank_type);

            var list = new List<XmlNamedElement>();

            // Consume tag
            if (reader.IsEmptyElement)
                reader.Read();
            else
            {
                reader.ReadStartElement();
                // Read child elements
                IXmlElementHelper<Library> helperLib;
                IXmlElementHelper<LibrarySpec> helperSpec = null;
                while ((helperLib = reader.FindHelper(LIBRARY_HELPERS)) != null ||
                        (helperSpec = reader.FindHelper(LIBRARY_SPEC_HELPERS)) != null)
                {
                    if (helperLib != null)
                        list.Add(helperLib.Deserialize(reader));
                    else
                        list.Add(helperSpec.Deserialize(reader));

                }
                reader.ReadEndElement();
            }

            var libraries = new Library[list.Count];
            var librarySpecs = new LibrarySpec[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                var library = list[i] as Library;
                if (library != null)
                    libraries[i] = library;
                else
                    librarySpecs[i] = (LibrarySpec) list[i];
            }
            Libraries = libraries;
            LibrarySpecs = librarySpecs;

            DoValidate();
        }
Exemplo n.º 34
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            ColinearWarning = reader.GetBoolAttribute(ATTR.colinear_warning);
            // Earlier versions always used decoys only
            UsesDecoys = reader.GetBoolAttribute(ATTR.uses_decoys, true);
            UsesSecondBest = reader.GetBoolAttribute(ATTR.uses_false_targets);
            double bias = reader.GetDoubleAttribute(ATTR.bias);

            // Consume tag
            reader.Read();

            // Read calculators
            var calculators = new List<FeatureCalculator>();
            reader.ReadElements(calculators);
            var peakFeatureCalculators = new List<IPeakFeatureCalculator>(calculators.Count);
            var weights = new double[calculators.Count];
            for (int i = 0; i < calculators.Count; i++)
            {
                weights[i] = calculators[i].Weight;
                peakFeatureCalculators.Add(PeakFeatureCalculator.GetCalculator(calculators[i].Type));
            }
            SetPeakFeatureCalculators(peakFeatureCalculators);
            Parameters = new LinearModelParams(weights, bias);

            reader.ReadEndElement();

            DoValidate();
        }
Exemplo n.º 35
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            Regex = reader.GetAttribute(ATTR.regex);
            IsIncludeMatch = reader.GetBoolAttribute(ATTR.include);
            IsMatchMod = reader.GetBoolAttribute(ATTR.match_mod_sequence);
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 36
0
        public void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            MaxMissedCleavages = reader.GetIntAttribute(ATTR.max_missed_cleavages);
            ExcludeRaggedEnds = reader.GetBoolAttribute(ATTR.exclude_ragged_ends);
            // Consume tag
            reader.Read();

            Validate();
        }
Exemplo n.º 37
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            string aas = reader.GetAttribute(ATTR.aminoacid);
            if (!string.IsNullOrEmpty(aas))
            {
                AAs = aas;
                // Support v0.1 format.
                if (AAs[0] == '\0') // Not L10N
                    AAs = null;
            }

            Terminus = reader.GetAttribute(ATTR.terminus, ToModTerminus);
            IsVariable = IsExplicit = reader.GetBoolAttribute(ATTR.variable);
            Formula = reader.GetAttribute(ATTR.formula);
            if (reader.GetBoolAttribute(ATTR.label_13C))
                LabelAtoms |= LabelAtoms.C13;
            if (reader.GetBoolAttribute(ATTR.label_15N))
                LabelAtoms |= LabelAtoms.N15;
            if (reader.GetBoolAttribute(ATTR.label_18O))
                LabelAtoms |= LabelAtoms.O18;
            if (reader.GetBoolAttribute(ATTR.label_2H))
                LabelAtoms |= LabelAtoms.H2;
            RelativeRT = reader.GetEnumAttribute(ATTR.relative_rt, RelativeRT.Matching);

            // Allow specific masses always, but they will generate an error,
            // in Validate() if there is already a formula.
            MonoisotopicMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_monoisotopic);
            AverageMass = reader.GetNullableDoubleAttribute(ATTR.massdiff_average);

            if (!IsVariable)
                IsExplicit = reader.GetBoolAttribute(ATTR.explicit_decl);

            UnimodId = reader.GetNullableIntAttribute(ATTR.unimod_id);
            // Backward compatibility with early code that assigned -1 to some custom modifications
            if (UnimodId.HasValue && UnimodId.Value == -1)
                UnimodId = null;

            ShortName = reader.GetAttribute(ATTR.short_name);

            // Consume tag
            reader.Read();

            var listLosses = new List<FragmentLoss>();
            reader.ReadElements(listLosses);
            if (listLosses.Count > 0)
            {
                Losses = listLosses.ToArray();
                reader.ReadEndElement();
            }

            Validate();
        }
Exemplo n.º 38
0
        public override void ReadXml(XmlReader reader)
        {
            // Read tag attributes
            base.ReadXml(reader);
            UseForRetentionTimeFilter = reader.GetBoolAttribute(ATTR.use_for_retention_time_prediction, false);
            AnalyteConcentration = reader.GetNullableDoubleAttribute(ATTR.analyte_concentration);
            SampleType = SampleType.FromName(reader.GetAttribute(ATTR.sample_type));
            // Consume tag
            reader.Read();

            // Check if there is an optimization function element, and read
            // if if there is.
            IXmlElementHelper<OptimizableRegression> helper =
                reader.FindHelper(OPTIMIZATION_HELPERS);
            if (helper != null)
                OptimizationFunction = helper.Deserialize(reader);

            var msDataFilePaths = new List<MsDataFileUri>();
            var fileLoadIds = new List<string>();
            while (reader.IsStartElement(EL.sample_file) ||
                    reader.IsStartElement(EL.replicate_file) ||
                    reader.IsStartElement(EL.chromatogram_file))
            {
                // Note that the file path is actually be a URI that encodes things like lockmass correction as well as filename
                msDataFilePaths.Add(MsDataFileUri.Parse(reader.GetAttribute(ATTR.file_path)));
                string id = reader.GetAttribute(ATTR.id) ?? GetOrdinalSaveId(fileLoadIds.Count);
                fileLoadIds.Add(id);
                reader.Read();
                if (reader.IsStartElement(EL.instrument_info_list))
                {
                    reader.Skip();
                    reader.Read();
                }
            }
            Annotations = SrmDocument.ReadAnnotations(reader);

            MSDataFileInfos = msDataFilePaths.ConvertAll(path => new ChromFileInfo(path));
            _fileLoadIds = fileLoadIds.ToArray();

            // Consume end tag
            reader.ReadEndElement();
        }
Exemplo n.º 39
0
        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();
        }