Exemplo n.º 1
0
        private AbsolutePathTranslation Calculate()
        {
            if (AncestorSource.Equals(AncestorDestination))
            {
                throw new InvalidOperationException(
                          string.Format(
                              "An attempt was made to calculate the path if a file (\"{0}\") was copied from \"{1}\" to \"{2}\". It is illegal to have the destination and source directories be the same, which is true in this case.",
                              AbsoluteAbsolutePath, AncestorSource, AncestorDestination));
            }
            if (!AbsoluteAbsolutePath.IsDescendantOf(AncestorSource))
            {
                throw new InvalidOperationException(
                          string.Format(
                              "The path \"{2}\" cannot be copied to \"{1}\" because the path isn't under the source path: \"{0}\"",
                              AncestorSource, AncestorDestination, AbsoluteAbsolutePath));
            }
            if (AncestorSource.Equals(AbsoluteAbsolutePath))
            {
                return(new AbsolutePathTranslation(AncestorSource, AncestorDestination, IoService));
            }
            var relativePath = AbsoluteAbsolutePath.RelativeTo(AncestorSource);
            var pathToBeCopiedDestination = AncestorDestination / relativePath;

            return(new AbsolutePathTranslation(AbsoluteAbsolutePath, pathToBeCopiedDestination, IoService));
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = AncestorDestination != null?AncestorDestination.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (AncestorSource != null ? AncestorSource.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (AbsoluteAbsolutePath != null ? AbsoluteAbsolutePath.GetHashCode() : 0);
                return(hashCode);
            }
        }