Ejemplo n.º 1
0
        public void check_null_or_empty_should_throw_exception(object arg, InvalidReason expectedReason)
        {
            // Arrange

            // Actions
            Action action = () => Check.ArgNotNullOrEmpty(arg, nameof(arg));

            // Assert
            action.ShouldThrow <ArgumentInvalidException>().And.Reason.Should().HaveFlag(expectedReason);
        }
Ejemplo n.º 2
0
        private void InvalidInvite(InvalidReason reason)
        {
            // Hide loading indicator
            Loading.Fade(0, 200).Start();
            GuildName.Fade(1, 350).Start();

            // Show appropiate error text
            if (reason == InvalidReason.Default)
            {
                GuildName.Text = App.GetString("/Controls/InviteInvalid");
            }
            else if (reason == InvalidReason.MaxUses)
            {
                GuildName.Text = App.GetString("/Controls/InviteMaxUses");
            }
            else if (reason == InvalidReason.Expired)
            {
                GuildName.Text = App.GetString("/Controls/InviteExpired");
            }

            // Make the text red
            GuildName.Foreground = (SolidColorBrush)Application.Current.Resources["dnd"];

            // If there's a user linked to the invite, display a link to them so you can ask them for a link
            if (DisplayedInvite?.Inviter != null && LocalState.Guilds[App.CurrentGuildId].members.ContainsKey(DisplayedInvite?.Inviter.Id))
            {
                ChannelName.Text       = "Ask @" + DisplayedInvite.Inviter.Username + "#" + DisplayedInvite.Inviter.Discriminator + " for a new one";
                ChannelName.Visibility = Visibility.Visible;
            }
            else
            {
                ChannelName.Text       = "";
                ChannelName.Visibility = Visibility.Collapsed;
            }

            // Hide Guild details (there are none)
            MemberCounters.Visibility = Visibility.Collapsed;
            GuildImage.Visibility     = Visibility.Collapsed;

            // Interaction status is invalid
            Status = InviteStatus.Invalid;
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ArgumentInvalidException" /> class.
 /// </summary>
 /// <param name="argName">
 ///     The argument name.
 /// </param>
 /// <param name="reason">
 ///     The reason.
 /// </param>
 public ArgumentInvalidException(string argName, InvalidReason reason)
     : this(argName, reason, null)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ArgumentInvalidException" /> class.
 /// </summary>
 /// <param name="argName">
 ///     The argument name.
 /// </param>
 /// <param name="reason">
 ///     The reason.
 /// </param>
 /// <param name="innerException">
 ///     The inner exception.
 /// </param>
 public ArgumentInvalidException(string argName, InvalidReason reason, Exception innerException)
     : base($"Argument {argName} is invalid. Reason: {reason}", innerException)
 {
     this.Reason = reason;
 }
Ejemplo n.º 5
0
 public CertificateInvalidError(ref ptr <Certificate> Cert = default, InvalidReason Reason = default, @string Detail = default)
 {
     this.Cert   = Cert;
     this.Reason = Reason;
     this.Detail = Detail;
 }
Ejemplo n.º 6
0
 public override void Read(BigEndianStream stream)
 {
     Reason = (InvalidReason)stream.ReadByte();
 }
Ejemplo n.º 7
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "InvalidPackageException" /> class.
 /// </summary>
 /// <param name = "reason">The reason.</param>
 /// <param name = "packagePath">The package path.</param>
 /// <remarks>
 /// </remarks>
 public InvalidPackageException(InvalidReason reason, string packagePath)
     : base(true)
 {
     PackagePath = packagePath;
     Reason = reason;
 }
Ejemplo n.º 8
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InvalidPackageException" /> class.
 /// </summary>
 /// <param name="reason"> The reason. </param>
 /// <param name="packagePath"> The package path. </param>
 /// <remarks>
 /// </remarks>
 public InvalidPackageException(InvalidReason reason, string packagePath) : base(true)
 {
     PackagePath = packagePath;
     Reason      = reason;
 }
Ejemplo n.º 9
0
		private bool SectorsAreValid(List<SectorGroup> sectorgroups, out InvalidReason invalidreason)
		{
			invalidreason = InvalidReason.None;

			// All sectors must have the same geometry
			for (int i = 0; i < sectorgroups.Count - 1; i++)
			{
				if (SectorGroup.GeometryMatches(sectorgroups[i], sectorgroups[i + 1]) == false)
				{
					invalidreason = InvalidReason.PlaneSectorGeometry;
					return false;
				}
			}

			// Sector heights must line up precisely
			for (int i = 0; i < sectorgroups.Count - 1; i++)
			{
				if (sectorgroups[i].CeilingHeight != sectorgroups[i + 1].FloorHeight)
				{
					invalidreason = InvalidReason.PlaneSectorHeights;
					return false;
				}
			}

			// Each sector must have enough lines without specials for the portal specials
			for (int i = 0; i < sectorgroups.Count; i++)
			{
				if (((i == 0 || i == sectorgroups.Count) && sectorgroups[i].FreeLineCount < 2) && sectorgroups[i].FreeLineCount < 4)
				{
					invalidreason = InvalidReason.PlaneFreeLines;
					return false;
				}
			}

			return true;
		}
Ejemplo n.º 10
0
		private bool LinesAreValid(List<Linedef> linedefs, out InvalidReason invalidreason)
		{
			BlockMap<BlockEntry> blockmap = new BlockMap<BlockEntry>(MapSet.CreateArea(General.Map.Map.Vertices), 128);
			invalidreason = InvalidReason.None;

			// Line can't have an action and/or tag
			foreach (Linedef ld in linedefs)
			{
				if (ld.Action != 0 || ld.Tag != 0)
				{
					invalidreason = InvalidReason.WallActionTagUsed;
					return false;
				}

			}

			Linedef ld1 = General.Map.Map.GetSelectedLinedefs(true).First();
			Linedef ld2 = General.Map.Map.GetSelectedLinedefs(true).Last();

			// Make sure the lines are exactly the same length
			if (ld1.Length != ld2.Length)
			{
				invalidreason = InvalidReason.WallLineLength;
				return false;
			}

			// Make sure the angles match. They have to be exactly opposite from each other
			double angle = ld1.Angle + Math.PI;

			if (angle > Math.PI * 2)
				angle -= Math.PI * 2;

			if (Math.Round(ld2.Angle, 5) != Math.Round(angle, 5))
			{
				invalidreason = InvalidReason.WallLineAngles;
				return false;
			}

			// Sector heights between wall portals have to match
			if (ld1.Front.Sector.CeilHeight != ld2.Front.Sector.CeilHeight || ld1.Front.Sector.FloorHeight != ld2.Front.Sector.FloorHeight)
			{
				invalidreason = InvalidReason.WallSectorHeights;
				return false;
			}

			// Check if there's enough space to draw the geometry
			/*
			foreach (Linedef ld in linedefs)
			{
				// Ignore line if it already has a sector at the back
				if (ld.Back != null)
					continue;

				List<Vector2D> points = new List<Vector2D>();

				Vector2D p = ld.Line.GetPerpendicular().GetNormal();
				RectangleF area = MapSet.CreateArea(new List<Linedef>() { ld });
				area = MapSet.IncreaseArea(area, ld.Line.v1 + p * WALLGEOMETRYDEPTH);
				area = MapSet.IncreaseArea(area, ld.Line.v2 + p * WALLGEOMETRYDEPTH);

				blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
				blockmap.AddSectorsSet(General.Map.Map.Sectors);

				points.Add(new Vector2D(ld.Line.v1));
				points.Add(new Vector2D(ld.Line.v2));
				points.Add(new Vector2D(ld.Line.v2 + p * WALLGEOMETRYDEPTH));
				points.Add(new Vector2D(ld.Line.v1 + p * WALLGEOMETRYDEPTH));
				points.Add(new Vector2D(ld.Line.v1));

				foreach (BlockEntry be in blockmap.GetSquareRange(area))
				{
					foreach (Sector s in be.Sectors)
					{
						if (s == ld.Front.Sector)
							continue;

						foreach (Vector2D point in points)
							if (s.Intersect(point))
							{
								invalidreason = InvalidReason.WallNewGeometry;
								return false;
							}
					}

					foreach (Linedef ldo in be.Lines)
					{
						if (ldo == ld)
							continue;

						for (int i = 0; i < points.Count-1; i++)
						{
							Line2D line = new Line2D(points[i], points[i + 1]);

							if (ldo.Line.GetIntersection(line))
							{
								invalidreason = InvalidReason.WallNewGeometry;
								return false;
							}
						}
					}
				}
			}
			*/

			return true;
		}