/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AllowEmpty != null) { hashCode = hashCode * 59 + AllowEmpty.GetHashCode(); } if (AllowHosts != null) { hashCode = hashCode * 59 + AllowHosts.GetHashCode(); } if (AllowHostsRegexp != null) { hashCode = hashCode * 59 + AllowHostsRegexp.GetHashCode(); } if (FilterMethods != null) { hashCode = hashCode * 59 + FilterMethods.GetHashCode(); } if (ExcludeAgentsRegexp != null) { hashCode = hashCode * 59 + ExcludeAgentsRegexp.GetHashCode(); } return(hashCode); } }
public JObject ToJson() { var result = new JObject(); if (Title.Length > 0) { result.Add(new JProperty("title", Title)); } if (Author.Length > 0) { result.Add(new JProperty("author", Author)); } if (License.Length > 0) { result.Add(new JProperty("license", License)); } var deps = new JObject(); foreach (PackageDependency dep in Dependencies) { deps.Add(dep.ToJson()); } result.Add(new JProperty("dependencies", deps)); if (Sources.Count > 0) { result.Add(new JProperty("sources", new JArray(Sources.ToArray()))); } if (Target.Length > 0 && Target != DefaultTarget) { result.Add(new JProperty("target", Target)); } if (AfterBuild.Length > 0) { result.Add(new JProperty("afterBuild", AfterBuild)); } if (!InsertModuleLoader) { result.Add(new JProperty("insertModuleLoader", false)); } if (SourceExtensions.Length > 0 && SourceExtensions != DefaultSourceExtensions) { result.Add(new JProperty("sourceExtensions", SourceExtensions)); } if (AllowHosts.Count > 0) { result.Add(new JProperty("allowHosts", AllowHosts.ToArray())); } return(result); }
/// <summary> /// Returns true if OrgApacheSlingSecurityImplReferrerFilterProperties instances are equal /// </summary> /// <param name="other">Instance of OrgApacheSlingSecurityImplReferrerFilterProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(OrgApacheSlingSecurityImplReferrerFilterProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AllowEmpty == other.AllowEmpty || AllowEmpty != null && AllowEmpty.Equals(other.AllowEmpty) ) && ( AllowHosts == other.AllowHosts || AllowHosts != null && AllowHosts.Equals(other.AllowHosts) ) && ( AllowHostsRegexp == other.AllowHostsRegexp || AllowHostsRegexp != null && AllowHostsRegexp.Equals(other.AllowHostsRegexp) ) && ( FilterMethods == other.FilterMethods || FilterMethods != null && FilterMethods.Equals(other.FilterMethods) ) && ( ExcludeAgentsRegexp == other.ExcludeAgentsRegexp || ExcludeAgentsRegexp != null && ExcludeAgentsRegexp.Equals(other.ExcludeAgentsRegexp) )); }
private void fromJson(string jsonStr) { JObject json = JObject.Parse(jsonStr); if (json["title"] != null) { Title = (string)json["title"]; } if (json["author"] != null) { Author = (string)json["author"]; } if (json["license"] != null) { License = (string)json["license"]; } if (json["target"] != null) { Target = (string)json["target"]; } if (json["afterBuild"] != null) { AfterBuild = (string)json["afterBuild"]; } if (json["sourceExtensions"] != null) { SourceExtensions = (string)json["sourceExtensions"]; } if (json["insertModuleLoader"] != null) { InsertModuleLoader = (bool)json["insertModuleLoader"]; } if (json["dependencies"] != null) { if (json["dependencies"].Type != JTokenType.Object) { throw new PackageException("Cannot parse \"" + Title + "\" package. The value of the property 'dependencies' must be an object, if exists"); } foreach (JProperty d in json["dependencies"]) { Dependencies.Add(new PackageDependency(d, Title)); } } if (json["allowHosts"] != null) { if (json["allowHosts"].Type != JTokenType.Array) { throw new PackageException("Cannot parse \"" + Title + "\" package. The value of the property 'allowHosts' must be an array, if exists"); } foreach (string h in json["allowHosts"]) { AllowHosts.Add(h); } } if (json["sources"] != null && json["sources"].Type == JTokenType.Array) { foreach (string src in json["sources"]) { Sources.Add(src); } } }