public void FixedSrcBuilder_ThrowsException_when_not_full()
        {
            bool caught = false;

            try
            {
                var b1 = new VA.ShapeSheet.Streams.SrcStreamArrayBuilder(1);
                var s1 = b1.ToStreamArray();
            }
            catch (System.ArgumentException e)
            {
                caught = true;
            }

            if (!caught)
            {
                Assert.Fail("Did not catch expected exception");
            }

            var b2     = new VA.ShapeSheet.Streams.SidSrcStreamArrayBuilder(1);
            var src    = new Src((short)0, (short)0, (short)0);
            var sidsrc = new SidSrc((short)0, src);

            b2.Add(sidsrc);
            var s2 = b2.ToStreamArray();
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Src != null ? Src.GetHashCode() : 0) * 397) ^ (Dst != null ? Dst.GetHashCode() : 0));
     }
 }
        public void Add(Src src, string value)
        {
            _check_for_src();
            var item = new WriteRecord(new SidSrc(-1, src), value);

            this._items.Add(item);
        }
Beispiel #4
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "img";
            output.TagMode = TagMode.SelfClosing;
            HttpClient httpClient = new HttpClient();
            string     fileUrl    = "";

            if (Src.StartsWith("http") || FallbackUrl.StartsWith("https"))
            {
                var webUrl = new Uri(Src);
                httpClient.BaseAddress = new Uri($"{webUrl.Scheme}://{webUrl.Host}");
                Src = webUrl.LocalPath;
            }
            else
            {
                var baseUrl = httpContextAccessor.HttpContext.Request.GetDisplayUrl();
                httpClient.BaseAddress = new Uri(baseUrl);
            }
            using (HttpResponseMessage response = await httpClient.GetAsync(Src))
            {
                if (response.IsSuccessStatusCode)
                {
                    output.Attributes.SetAttribute("src", Src);
                }
                else
                {
                    output.Attributes.SetAttribute("src", FallbackUrl);
                }
            }
        }
Beispiel #5
0
 public SidSrc(
     short shapeid,
     Src src)
 {
     this.ShapeID = shapeid;
     this.Src     = src;
 }
Beispiel #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CompressionLevel != 0)
            {
                hash ^= CompressionLevel.GetHashCode();
            }
            hash ^= ciphers_.GetHashCode();
            if (Key.Length != 0)
            {
                hash ^= Key.GetHashCode();
            }
            if (Src.Length != 0)
            {
                hash ^= Src.GetHashCode();
            }
            if (Dest.Length != 0)
            {
                hash ^= Dest.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #7
0
        protected virtual AssertPair <TSrc, TDst> InternalShouldBeEqual <TType>(Expression <Func <TSrc, TType> > srcExp, Expression <Func <TSrc, TType> > srcAlias, Expression <Func <TDst, TType> > dstExp, Expression <Func <TDst, TType> > dstAlias)
        {
            var srcProp = Src.GetExpressionValue <TSrc, TType>(srcExp);
            var dstProp = Dst.GetExpressionValue <TDst, TType>(dstExp);

            var srcPropAlias = Src.GetExpressionValue <TSrc, TType>(srcAlias);
            var dstPropAlias = Dst.GetExpressionValue <TDst, TType>(dstAlias);

            var isValid = object.Equals(srcProp.Value, dstProp.Value);

            if (srcProp.Value is byte[] && dstProp.Value is byte[])
            {
                isValid = (srcProp.Value as byte[]).SequenceEqual((dstProp.Value as byte[]));
            }

            InvokeOnPropertyValidated(this, new OnPropertyValidatedEventArgs
            {
                Result = new PropertyValidationResult
                {
                    Tag     = this.Tag,
                    Src     = srcPropAlias,
                    Dst     = dstPropAlias,
                    IsValid = isValid
                }
            });

            return(this);
        }
Beispiel #8
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Src != null ? Src.GetHashCode() : 0) * 397) ^ (int)Instruction);
     }
 }
Beispiel #9
0
        /// <summary>Advisor main loop</summary>
        private async Task AdvisorMain(CancellationToken thread_stop)
        {
            Log.Write(ELogLevel.Info, "Advisor Activated");

            // One-time update the data we don't expect to change
            await Src.BuildCache(RebuildStaticData);

            RebuildStaticData = false;

            // Start a loop
            var issue = 0;

            for (; !thread_stop.IsCancellationRequested;)
            {
                // If a new search is needed and not yet started, search now
                if (m_trade_routes_issue_current != m_trade_routes_issue && issue != m_trade_routes_issue)
                {
                    // Find trade routes
                    issue = m_trade_routes_issue;
                    await FindTradeRoutes(m_settings_snapshot, issue);

                    continue;
                }

                // If up to date, go to sleep
                using (thread_stop.Register(() => m_find_trade_routes.Set()))
                    m_find_trade_routes.WaitOne(TimeSpan.FromSeconds(0.5));
            }

            Log.Write(ELogLevel.Info, "Advisor Deactivated");
        }
        // Move settings to global for current attribute only
        private void toGlobal_Click(object sender, EventArgs e)
        {
            Src other = (Src)cbSource.SelectedIndex == Src.Global ? Src.Message : Src.Global;

            AddOneRule(other);
            SetButtonEnables();
        }
        // Add a new rule to either msg or global
        private void AddOneRule(Src n)
        {
            ccSR attr = (ccSR)cbAttribute.SelectedIndex;

            // Make sure the user filled it in
            if (ruleSpecified(attr))
            {
                // Get the new rule
                SubstitutionRule sr = GetSubstitutionRule(attr);
                if (Subs[(int)n] == null)
                {
                    // Create a whole new substitution with one rule
                    Subs[(int)n]         = GetNewSubstitution();
                    Subs[(int)n].SubRule = new SubstitutionRule[] { sr };
                }
                else
                {
                    // Delete the rule if it exists
                    List <SubstitutionRule> r = new List <SubstitutionRule>();
                    foreach (SubstitutionRule t in Subs[(int)n].SubRule)
                    {
                        if (t.Type != attr.ToString())
                        {
                            r.Add(t);
                        }
                    }
                    // Add the new rule to the list and turn it back to an array
                    r.Add(sr);
                    Subs[(int)n].SubRule = r.ToArray();
                }
            }
        }
        // Move settings to the global for all attributes
        private void toGlobalAll_Click(object sender, EventArgs e)
        {
            Src other = (Src)cbSource.SelectedIndex == Src.Global ? Src.Message : Src.Global;

            Subs[(int)other] = GetCurrentSubstitution();
            SetButtonEnables();
        }
 /// <summary>
 /// Get the hash code for this script.
 /// </summary>
 /// <remarks>The integrity hash will still be unique to the file, even moreso than the address. If the same file gets loaded with SRI hashes from two different sources they'll still be labeled the same file.</remarks>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Src != null ? Src.GetHashCode() : 0) * 397) ^ (Integrity != null ? Integrity.GetHashCode() : 0));
     }
 }
Beispiel #14
0
 public static void Map(Src src, Dest dest)
 {
     dest.Name     = src.Name;
     dest.DateTime = src.DateTime;
     dest.Float    = src.Float;
     dest.Number   = src.Number;
 }
Beispiel #15
0
        private string GetFullPath()
        {
            const string TildeSlash   = "~/";
            string       relativePath = Src.Remove(0, TildeSlash.Length);

            return(Path.GetFullPath(relativePath, basePath: HostingEnvironment.WebRootPath));
        }
Beispiel #16
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Size != 0D)
            {
                hash ^= Size.GetHashCode();
            }
            if (Src.Length != 0)
            {
                hash ^= Src.GetHashCode();
            }
            if (Shape.Length != 0)
            {
                hash ^= Shape.GetHashCode();
            }
            if (Label.Length != 0)
            {
                hash ^= Label.GetHashCode();
            }
            if (CustomLabel.Length != 0)
            {
                hash ^= CustomLabel.GetHashCode();
            }
            if (Zoom.Length != 0)
            {
                hash ^= Zoom.GetHashCode();
            }
            return(hash);
        }
Beispiel #17
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            output.TagMode = TagMode.StartTagAndEndTag;

            string styleValue = "";

            if (output.Attributes.ContainsName("style"))
            {
                styleValue += $"{output.Attributes["style"].Value};";
            }

            if (Colour.IsSet())
            {
                styleValue += $"background-color:{Colour};";
            }

            string url = "";

            if (UseDefault)
            {
                if (Engine.Settings.Media.NoImage.IsSet())
                {
                    url = Engine.Settings.Media.NoImage;
                }
                else
                {
                    url = MediaObject.NoImageUrl;
                }
            }

            if (Fallback.IsSet())
            {
                url = Fallback;
            }

            if (Src.IsSet())
            {
                url = Src;
            }

            if (url.IsSet())
            {
                styleValue += $"background-image:url({url});";
            }

            output.Attributes.SetAttribute("style", styleValue);

            if (output.Attributes.ContainsName("class"))
            {
                output.Attributes.SetAttribute("class", $"{output.Attributes["class"].Value} hood-image");
            }
            else
            {
                output.Attributes.SetAttribute("class", $"hood-image");
            }

            output.PreContent.SetHtmlContent($"<img src='{url}' alt='{Alt}' />");
        }
Beispiel #18
0
 /// <summary>
 /// Equals
 /// </summary>
 /// <param name="item">Other item</param>
 /// <returns>Result</returns>
 public bool Equals(ScriptReferenceMeta item)
 {
     if (item == null)
     {
         return(false);
     }
     return(Src.Equals(item.Src) && DebugSrc.Equals(item.DebugSrc));
 }
Beispiel #19
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Returns HashCode</returns>
 public override int GetHashCode()
 {
     return(String.Format("{0}|{1}|{2}|",
                          Name?.GetHashCode() ?? 0,
                          Src?.GetHashCode() ?? 0,
                          Overwrite.GetHashCode()
                          ).GetHashCode());
 }
        public override int GetHashCode()
        {
            int hash = 13;

            hash = (hash * 7) + Src.GetHashCode();
            hash = (hash * 7) + Dest.GetHashCode();
            return(hash);
        }
Beispiel #21
0
        public void SetResult(Src src, CellValueLiteral result)
        {
            if (this._resultRecords == null)
            {
                this._resultRecords = new WriteCache <Src>();
            }

            this._resultRecords.Add(src, result.Value);
        }
        public void TestEx6WithInvalidPropertyName()
        {
            Dst dst = new Dst();
            Src src = new Src();

            bool res = Ficha1.SetPropertyFromField(dst, "NonExistingProperty", src, "item");

            Assert.That(res, Is.EqualTo(false));
        }
Beispiel #23
0
 public SidSrc(
     short shapeid,
     short section,
     short row,
     short cell)
 {
     this.ShapeID = shapeid;
     this.Src     = new Src(section, row, cell);
 }
Beispiel #24
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "script";
            var url = string.Concat(AppWebInfoHelper.CssDomain, Src.TrimStart('~'), "?v=",
                                    Version ? AppInfoHelper.AppVersion : string.Empty);

            output.Attributes.SetAttribute("src", url);
            output.Attributes.SetAttribute("beforeload", BeforLoad);
        }
Beispiel #25
0
        void Num()
        {
            int la0, la1;
            int dot = 0;

            // Line 181: ([.])?
            la0 = Src.LA0;
            if (la0 == '.')
            {
                dot = Src.MatchAny();
            }
            Src.MatchRange('0', '9');
            // Line 182: ([0-9])*
            for (;;)
            {
                la0 = Src.LA0;
                if (la0 >= '0' && la0 <= '9')
                {
                    Src.Skip();
                }
                else
                {
                    break;
                }
            }
            // Line 183: (&{dot == 0} [.] [0-9] ([0-9])*)?
            la0 = Src.LA0;
            if (la0 == '.')
            {
                if (dot == 0)
                {
                    la1 = Src.LA(1);
                    if (la1 >= '0' && la1 <= '9')
                    {
                        Src.Skip();
                        Src.Skip();
                        // Line 183: ([0-9])*
                        for (;;)
                        {
                            la0 = Src.LA0;
                            if (la0 >= '0' && la0 <= '9')
                            {
                                Src.Skip();
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
                        #line 184 "Grammars.ecs"
            _tok.Value = double.Parse(Src.CharSource.Slice(_tok.StartIndex, Src.InputPosition - _tok.StartIndex).ToString());
                        #line default
        }
Beispiel #26
0
        public IActionResult Index() //gonutsnonuts page
        {
            CreateSquirrelViewModel viewModel = new CreateSquirrelViewModel()
            {
                Image = Src.GetPhoto()
            };

            viewModel.Name = RandomThing.RandomName();
            return(View(viewModel));
        }
Beispiel #27
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Action.GetHashCode();
         hashCode = (hashCode * 397) ^ (Src != null ? Src.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Dest != null ? Dest.GetHashCode() : 0);
         return(hashCode);
     }
 }
Beispiel #28
0
 /// <summary>
 /// Serves as the default hash function.
 /// </summary>
 /// <returns>
 /// A hash code for the current object.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Src != null ? Src.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FocalPoint != null ? FocalPoint.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Crops != null ? Crops.GetHashCode() : 0);
         return(hashCode);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = 63;
         hash ^= hash * Src.GetHashCode();
         hash ^= hash * Dest.GetHashCode();
         return(hash);
     }
 }
Beispiel #30
0
        /// <summary>
        /// Determines value equality.
        /// </summary>
        /// <param name="other">The other object to compare against.</param>
        /// <returns>True if the objects are equal.</returns>
        protected virtual bool IsEqual(DefaultPath <V, E> other)
        {
            bool result = Src.Equals(other.Src) &&
                          Dst.Equals(other.Dst) &&
                          edges.SequenceEqual(other.edges) &&
                          // TODO: This is clunky, is there a better way?
                          (other.Cost?.Equals(Cost) ?? Cost is null);

            return(result);
        }
Beispiel #31
0
        public Entity.Caller GetCallerWithSrc(Src pSrc)
        {
            var callers = GetCallers();
            if (!callers.Any()) return null;

            return callers.FirstOrDefault(x => x.Src == (int)pSrc);
        }