using System; namespace Codice.CM.Common { [Serializable] public class ObjectInfo { public long FIdOwner; public SEID Owner; public override bool Equals(object obj) { if (!(obj is ObjectInfo)) return false; if (Owner == null) return true; return Owner.Equals(((ObjectInfo)obj).Owner); } public override int GetHashCode() { return base.GetHashCode(); } } [Serializable] public class RepositoryServerInfo : ObjectInfo { public string ServerName; public override bool Equals(object obj) { if (!(obj is RepositoryServerInfo)) { return false; } RepositoryServerInfo repObj = obj as RepositoryServerInfo; if (ServerLocator.Get().AreSameServer(ServerName, repObj.ServerName)) { return false; } return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } } [Serializable] public class RepositoryInfo : ObjectInfo { public long Id = -1; public string Name; public Guid GUID; private string mServer; public RepositoryInfo(long repId, string name, string server, Guid guid) : this(repId, name, server, guid, null) { } public RepositoryInfo( long repId, string name, string server, Guid guid, SEID owner) { this.Id = repId; this.Name = name; this.GUID = guid; if (!ServerLocator.Get().IsSameServer(server)) this.mServer = server; this.Owner = owner; } public string Server { get { if ((mServer != null) && (mServer != string.Empty)) { return mServer; } return ServerLocator.Get().GetDefaultServer(); } } public void SetExplicitServer(string serverName) { // Only set the value when the client calls directly to // the repository server, and it returns the mServer field to null. // Needs to set it manually. if (mServer == null || mServer == string.Empty) { if (serverName == null) { mServer = Server; } else mServer = serverName; } } public string GetInternalServerName() { return mServer; } public override bool Equals(object obj) { if (this == obj) return true; RepositoryInfo objInfo = obj as RepositoryInfo; if (objInfo != null) { return objInfo.GUID == this.GUID; } else { return false; } } public override int GetHashCode() { return GUID.GetHashCode(); } public override string ToString() { return this.Name + " (" + this.Server + ")"; } private RepositoryInfo() { } public RepositoryInfo CreateExplicitClone() { RepositoryInfo result = new RepositoryInfo(); result.Id = this.Id; result.Name = this.Name; result.mServer = this.Server; result.Owner = this.Owner; result.GUID = this.GUID; return result; } public RepositorySpec GetRepSpec() { RepositorySpec result = new RepositorySpec(); result.Name = Name; result.Server = Server; return result; } } } namespace Codice.Common.InRep { [Serializable] public class ObjectInRepInfo : ObjectInfo { public long RepId = -1; public long Id = -1; public ObjectInRepInfo() { } public ObjectInRepInfo(long id) { Id = id; } public override bool Equals(object obj) { if (!(obj is ObjectInRepInfo)) { return false; } ObjectInRepInfo repObj = obj as ObjectInRepInfo; if (RepId != repObj.RepId) { return false; } if (Id != repObj.Id) { return false; } return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } } }