/// <summary>
        /// Determines whether the specified <paramref name="unitOfWork"/> can be disposed.
        /// </summary>
        /// <param name="unitOfWork">The unit of work.</param>
        /// <returns>
        /// <c>true</c> if no <see cref="AmbientExists"/>; otherwise:
        /// <c>true</c> if the <see cref="AmbientUnitOfWorkDecorator.IsDisposable"/> and <paramref name="unitOfWork.Parent"/> is null; otherwise <c>false</c>
        /// </returns>
        /// <remarks></remarks>
        public virtual Boolean CanDisposeUnitOfWork(UnitOfWorkBase unitOfWork)
        {
            if (AmbientExists)
            {
                // Save the current disposable state of the ambient unit of work locally since further execution may affect it.
                var ambientIsDisposable = Ambient.IsDisposable;

                if (Ambient.Equals(unitOfWork))
                {
                    if (ambientIsDisposable)
                    {
                        AmbientUnitsOfWork.Pop();
                    }
                    else
                    {
                        Ambient.Decrement();
                    }
                }

                if ((unitOfWork.Status == TransactionStatus.Committed || unitOfWork.Status == TransactionStatus.Aborted) ||
                    (ambientIsDisposable && unitOfWork.Parent == null))
                {
                    return(true);
                }

                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Determines whether the specified <see cref="MaterialPalette"/> is equal to the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </summary>
        /// <param name='other'>
        /// The <see cref="MaterialPalette"/> to compare with the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="MaterialPalette"/> is equal to the current
        /// <see cref="UFLT.Records.MaterialPalette"/>; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(MaterialPalette other)
        {
            // Check color fields
            if (!Ambient.Equals(other.Ambient))
            {
                return(false);
            }
            if (!Diffuse.Equals(other.Diffuse))
            {
                return(false);
            }
            if (!Specular.Equals(other.Specular))
            {
                return(false);
            }
            if (!Emissive.Equals(other.Emissive))
            {
                return(false);
            }

            if (Mathf.Approximately(Shininess, other.Shininess))
            {
                return(false);
            }
            if (Mathf.Approximately(Alpha, other.Alpha))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
 public bool Equals(Material other)
 {
     return(Color.Equals(other.Color) &&
            Ambient.Equals(other.Ambient) &&
            Diffuse.Equals(other.Diffuse) &&
            Specular.Equals(other.Specular) &&
            Shininess.Equals(other.Shininess));
 }
 /// <summary>
 /// Determines whether the specified <paramref name="unitOfWork"/> can be committed.
 /// </summary>
 /// <param name="unitOfWork">The unit of work.</param>
 /// <returns><c>true</c> if the specified unit of work can be committed; otherwise, <c>false</c>.</returns>
 /// <remarks>
 /// <para>
 /// Group 1 (if the <paramref name="unitOfWork"/> is <c>not</c> part of a <see cref="CompositeUnitOfWork"/>)
 ///     <paramref name="unitOfWork"/>.Parent is NULL
 ///         <c>true</c> if the <paramref name="unitOfWork"/> does not belong to a <see cref="CompositeUnitOfWork"/>; otherwise <c>false</c>
 ///     AmbientExists -
 ///         <c>true</c> if an ambient exists within a given scope; otherwise <c>false</c>
 ///         (ie. per-thread <see cref="PerThreadAmbientContextManager"/> or per-request <see cref="PerRequestAmbientContextManager"/>)
 ///     Ambient.IsCommittable
 ///         true if there is only a single active session on the ambient context; otherwise, false
 /// </para>
 /// <para>
 /// Group 2 (if the <paramref name="unitOfWork"/> belongs to a <see cref="CompositeUnitOfWork"/> - ie. has a parent)
 ///     Ambient.UnitOfWork.IsCommitting
 ///         <c>true</c> if the ambient unit of work is currently being committed; otherwise <c>false</c>
 /// </para>
 /// </remarks>
 public virtual Boolean CanCommitUnitOfWork(UnitOfWorkBase unitOfWork)
 {
     return((unitOfWork.Parent == null &&
             (AmbientExists &&
              Ambient.Equals(unitOfWork) &&
              Ambient.IsCommittable)) ||
            Ambient.UnitOfWork.Status == TransactionStatus.Active);
 }
Example #5
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Lighting other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     VertexNormalsEpsilon == other.VertexNormalsEpsilon ||
                     VertexNormalsEpsilon != null &&
                     VertexNormalsEpsilon.Equals(other.VertexNormalsEpsilon)
                     ) &&
                 (
                     FaceNormalsEpsilon == other.FaceNormalsEpsilon ||
                     FaceNormalsEpsilon != null &&
                     FaceNormalsEpsilon.Equals(other.FaceNormalsEpsilon)
                 ) &&
                 (
                     Ambient == other.Ambient ||
                     Ambient != null &&
                     Ambient.Equals(other.Ambient)
                 ) &&
                 (
                     Diffuse == other.Diffuse ||
                     Diffuse != null &&
                     Diffuse.Equals(other.Diffuse)
                 ) &&
                 (
                     Specular == other.Specular ||
                     Specular != null &&
                     Specular.Equals(other.Specular)
                 ) &&
                 (
                     Roughness == other.Roughness ||
                     Roughness != null &&
                     Roughness.Equals(other.Roughness)
                 ) &&
                 (
                     Fresnel == other.Fresnel ||
                     Fresnel != null &&
                     Fresnel.Equals(other.Fresnel)
                 ));
        }
 /// <summary>
 /// Test to see if this material is equal to another.
 /// </summary>
 /// <param name="other">The material to test against.</param>
 /// <returns>True if the object is equal to this one. False, otherwise.</returns>
 public bool Equals(MeshStandardMaterial other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Roughness.Equals(other.Roughness) &&
            Metalness.Equals(other.Metalness) &&
            Ambient.Equals(other.Ambient) &&
            Color.Equals(other.Color) &&
            Emissive.Equals(other.Emissive) &&
            Map == other.Map &&
            BumpMap == other.BumpMap &&
            AlphaMap == other.AlphaMap &&
            EnvironmentMap == other.EnvironmentMap);
 }
Example #7
0
        public bool Equals([AllowNull] Lighting other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Ambient == other.Ambient && Ambient != null && other.Ambient != null && Ambient.Equals(other.Ambient)) &&
                   (Diffuse == other.Diffuse && Diffuse != null && other.Diffuse != null && Diffuse.Equals(other.Diffuse)) &&
                   (Specular == other.Specular && Specular != null && other.Specular != null && Specular.Equals(other.Specular)) &&
                   (Roughness == other.Roughness && Roughness != null && other.Roughness != null && Roughness.Equals(other.Roughness)) &&
                   (Fresnel == other.Fresnel && Fresnel != null && other.Fresnel != null && Fresnel.Equals(other.Fresnel)));
        }
Example #8
0
 protected bool Equals(Material other)
 {
     return(Equals(Pattern, other.Pattern) && Ambient.Equals(other.Ambient) && Diffuse.Equals(other.Diffuse) && Specular.Equals(other.Specular) && Shininess == other.Shininess && Reflective.Equals(other.Reflective));
 }