BadScript 2
Loading...
Searching...
No Matches
ParameterModel.cs
Go to the documentation of this file.
1using System;
2
4
5public readonly struct ParameterModel : IEquatable<ParameterModel>
6{
7 public readonly bool IsContext;
8 public readonly string? Name;
9 public readonly string? Description;
10 public readonly string? Type;
11 public readonly string? CsharpType;
12 public readonly bool IsNullable;
13 public readonly bool HasDefaultValue;
14 public readonly string? DefaultValue;
15 public readonly bool IsRestArgs;
16
17 public ParameterModel(bool isContext,
18 bool hasDefaultValue = false,
19 string? defaultValue = null,
20 string? name = null,
21 string? description = null,
22 string? type = null,
23 string? csharpType = null,
24 bool isNullable = false,
25 bool isRestArgs = false)
26 {
27 IsContext = isContext;
28 HasDefaultValue = hasDefaultValue;
29 DefaultValue = defaultValue;
30 Name = name;
31 Description = description;
32 Type = type;
33 CsharpType = csharpType;
34 IsNullable = isNullable;
35 IsRestArgs = isRestArgs;
36 }
37
38 public bool Equals(ParameterModel other)
39 {
40 return IsContext == other.IsContext &&
41 Name == other.Name &&
42 Description == other.Description &&
43 Type == other.Type &&
44 CsharpType == other.CsharpType &&
45 IsNullable == other.IsNullable &&
46 HasDefaultValue == other.HasDefaultValue &&
47 DefaultValue == other.DefaultValue &&
48 IsRestArgs == other.IsRestArgs;
49 }
50
51 public override bool Equals(object? obj)
52 {
53 return obj is ParameterModel other && Equals(other);
54 }
55
56 public override int GetHashCode()
57 {
58 unchecked
59 {
60 int hashCode = IsContext.GetHashCode();
61 hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
62 hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
63 hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
64 hashCode = (hashCode * 397) ^ (CsharpType != null ? CsharpType.GetHashCode() : 0);
65 hashCode = (hashCode * 397) ^ IsNullable.GetHashCode();
66 hashCode = (hashCode * 397) ^ HasDefaultValue.GetHashCode();
67 hashCode = (hashCode * 397) ^ (DefaultValue != null ? DefaultValue.GetHashCode() : 0);
68 hashCode = (hashCode * 397) ^ IsRestArgs.GetHashCode();
69
70 return hashCode;
71 }
72 }
73
74 public static bool operator ==(ParameterModel left, ParameterModel right)
75 {
76 return left.Equals(right);
77 }
78
79 public static bool operator !=(ParameterModel left, ParameterModel right)
80 {
81 return !left.Equals(right);
82 }
83}
static bool operator!=(ParameterModel left, ParameterModel right)
ParameterModel(bool isContext, bool hasDefaultValue=false, string? defaultValue=null, string? name=null, string? description=null, string? type=null, string? csharpType=null, bool isNullable=false, bool isRestArgs=false)
static bool operator==(ParameterModel left, ParameterModel right)