/// <summary>
        /// Initializes a new <see cref="StObjEngineConfiguration"/> from a <see cref="XElement"/>.
        /// </summary>
        /// <param name="e">The xml element.</param>
        public StObjEngineConfiguration(XElement e)
        {
            Throw.CheckNotNullArgument(e);

            // Global options.
            BasePath = (string?)e.Element(xBasePath);
            GeneratedAssemblyName       = (string?)e.Element(xGeneratedAssemblyName);
            TraceDependencySorterInput  = (bool?)e.Element(xTraceDependencySorterInput) ?? false;
            TraceDependencySorterOutput = (bool?)e.Element(xTraceDependencySorterOutput) ?? false;
            RevertOrderingNames         = (bool?)e.Element(xRevertOrderingNames) ?? false;
            InformationalVersion        = (string?)e.Element(xInformationalVersion);
            var sha1 = (string?)e.Element(xBaseSHA1);

            BaseSHA1 = sha1 != null?SHA1Value.Parse(sha1) : SHA1Value.Zero;

            ForceRun            = (bool?)e.Element(xForceRun) ?? false;
            GlobalExcludedTypes = new HashSet <string>(FromXml(e, xGlobalExcludedTypes, xType));

            // BinPaths.
            BinPaths = e.Elements(xBinPaths).Elements(xBinPath).Select(e => new BinPathConfiguration(e)).ToList();

            // Aspects.
            Aspects = new List <IStObjEngineAspectConfiguration>();
            foreach (var a in e.Elements(xAspect))
            {
                string type    = (string)a.AttributeRequired(xType);
                Type?  tAspect = SimpleTypeFinder.WeakResolver(type, true);
                Debug.Assert(tAspect != null);
                IStObjEngineAspectConfiguration aspect = (IStObjEngineAspectConfiguration)Activator.CreateInstance(tAspect, a) !;
                Aspects.Add(aspect);
            }
        }
Exemple #2
0
        public void SHA1_ToString_and_Parse()
        {
            var sha    = SHA1Value.ComputeFileSHA1(GetFilePath());
            var s      = sha.ToString();
            var shaBis = SHA1Value.Parse(s);

            shaBis.Should().Be(sha);
        }
Exemple #3
0
        public void SHA1_CompareTo(string v1, string v2, char cmp)
        {
            var s1 = SHA1Value.Parse(v1);
            var s2 = SHA1Value.Parse(v2);

            switch (cmp)
            {
            case '>': s1.CompareTo(s2).Should().BeGreaterThan(0); break;

            case '<': s1.CompareTo(s2).Should().BeLessThan(0); break;

            default:  s1.CompareTo(s2).Should().Be(0); break;
            }
        }
Exemple #4
0
        private IAsyncAction loadImageUriAndHash()
        {
            return(Run(async token =>
            {
                var loadPageUri = default(Uri);
                if (this.failToken != null)
                {
                    loadPageUri = new Uri(this.PageUri, $"?{this.failToken}");
                }
                else
                {
                    loadPageUri = this.PageUri;
                }
                var doc = await Client.Current.HttpClient.GetDocumentAsync(loadPageUri);

                this.imageUri = new Uri(doc.GetElementbyId("img").GetAttributeValue("src", "").DeEntitize());
                var originalNode = doc.GetElementbyId("i7").Element("a");
                if (originalNode == null)
                {
                    this.originalImageUri = null;
                }
                else
                {
                    this.originalImageUri = new Uri(originalNode.GetAttributeValue("href", "").DeEntitize());
                }
                var hashNode = doc.GetElementbyId("i6").Element("a");
                this.ImageHash = SHA1Value.Parse(hashMatcher.Match(hashNode.GetAttributeValue("href", "").DeEntitize()).Groups[1].Value);
                var loadFail = doc.GetElementbyId("loadfail").GetAttributeValue("onclick", "").DeEntitize();
                var oft = this.failToken;
                var nft = failTokenMatcher.Match(loadFail).Groups[1].Value;
                if (oft == null)
                {
                    this.failToken = $"nl={nft}";
                }
                else
                {
                    this.failToken = $"{oft}&nl={nft}";
                }
            }));
        }