Exemple #1
0
        public bool Equals(GLCmdClearValueArrayItem other)
        {
            if (!Attachment.Equals(other.Attachment))
            {
                return(false);
            }

            if (!Color.Equals(other.Color))
            {
                return(false);
            }

            switch (this.Attachment.AttachmentType)
            {
            case GLClearAttachmentType.COLOR_FLOAT:
                return(this.Value.Color.Float32.Equals(other.Value.Color.Float32));

            case GLClearAttachmentType.COLOR_INT:
                return(this.Value.Color.Int32.Equals(other.Value.Color.Int32));

            case GLClearAttachmentType.COLOR_UINT:
                return(this.Value.Color.Uint32.Equals(other.Value.Color.Uint32));

            case GLClearAttachmentType.DEPTH_STENCIL:
                return(this.Value.DepthStencil.Equals(other.Value.DepthStencil));

            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public void Equals_ShouldBeTrue_WhenOther_IsSelf_Object()
        {
            // Arrange
            var attachment = new Attachment("C:\\file");
            // Act
            var result = attachment.Equals((object)attachment);

            // Assert
            result.Should().Be(true);
        }
Exemple #3
0
        public void Equals_ShouldBeFalse_WhenOther_IsNull_Object()
        {
            // Arrange
            var attachment = new Attachment("C:\\file");
            // Act
            var result = attachment.Equals((object)null);

            // Assert
            result.Should().Be(false);
        }
Exemple #4
0
        public void Equals_ShouldBeFalse_WhenOther_IsOtherType_Object()
        {
            // Arrange
            var attachment = new Attachment("C:\\file");
            var other      = new object();
            // Act
            var result = attachment.Equals(other);

            // Assert
            result.Should().Be(false);
        }
Exemple #5
0
        public void Equals_ShouldBeTrue_WhenOtherObject_HasSamePath()
        {
            // Arrange
            const string path       = "C:\\Program Files\\Some\\File 22.txt";
            var          attachment = new Attachment(path);
            var          other      = new Attachment(path);
            // Act
            var result = attachment.Equals((object)other);

            // Assert
            result.Should().Be(true);
        }
Exemple #6
0
        public void Equals_ShouldBeTrue_WhenOther_HasLowercasePath()
        {
            // Arrange
            const string path       = "C:\\Program Files\\Some\\File 22.txt";
            var          attachment = new Attachment(path);
            var          other      = new Attachment(path.ToLowerInvariant());
            // Act
            var result = attachment.Equals(other);

            // Assert
            result.Should().Be(true);
        }
Exemple #7
0
        public void Equals_ShouldBeFalse_WhenOtherObject_HasDifferentPath()
        {
            // Arrange
            const string path       = "C:\\Program Files\\Some\\File 22.txt";
            const string otherPath  = "C:\\Program Files\\Some\\File 11.txt";
            var          attachment = new Attachment(path);
            var          other      = new Attachment(otherPath);
            // Act
            var result = attachment.Equals((object)other);

            // Assert
            result.Should().Be(false);
        }
Exemple #8
0
        /// <summary>
        /// Sends the mail.
        /// </summary>
        /// <param name="recievers">The recievers.</param>
        /// <param name="cc">The cc.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="body">The body.</param>
        /// <param name="IsAttachment">if set to <c>true</c> [is attachment].</param>
        /// <param name="AttachmentPath">The attachment path.</param>
        /// <param name="serverpath">The serverpath.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool SendMail(string recievers, string cc, string subject, string body, bool IsAttachment, string AttachmentPath, string serverpath)
        {
            var fromEmail    = ConfigurationManager.AppSettings["FromEmail"];
            var fromPassword = ConfigurationManager.AppSettings["FromPassword"];
            var host         = ConfigurationManager.AppSettings["smtpHost"];

            var smtp = new SmtpClient
            {
                Host                  = host,
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromEmail, fromPassword)
            };

            try
            {
                if (recievers.EndsWith(","))
                {
                    recievers = recievers.Remove(recievers.Length - 1);
                }
                using (var mail = new MailMessage(fromEmail, recievers))
                {
                    if (IsAttachment)
                    {
                        foreach (var Attachment in AttachmentPath.Split(','))
                        {
                            if (Attachment.Equals(string.Empty))
                            {
                                continue;
                            }
                            var attachment = new Attachment(serverpath + Attachment);
                            ContentDisposition disposition = attachment.ContentDisposition;
                            disposition.CreationDate     = File.GetCreationTime(serverpath + Attachment);
                            disposition.ModificationDate = File.GetLastWriteTime(serverpath + Attachment);
                            disposition.ReadDate         = File.GetLastAccessTime(serverpath + Attachment);

                            string currentFile = Attachment.Contains("_")
                                                     ? Attachment.Substring(Attachment.LastIndexOf("_") + 1)
                                                     : Attachment.Substring(Attachment.LastIndexOf(@"/") + 1);

                            disposition.FileName        = currentFile;
                            disposition.Size            = new FileInfo(serverpath + Attachment).Length;
                            disposition.DispositionType = DispositionTypeNames.Attachment;
                            mail.Attachments.Add(attachment);
                        }
                    }
                    if (!String.IsNullOrEmpty(cc))
                    {
                        mail.CC.Add(cc);
                    }

                    mail.IsBodyHtml = true;
                    mail.Subject    = subject;
                    mail.Body       = body;
                    ServicePointManager.ServerCertificateValidationCallback =
                        delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); };
                    smtp.Send(mail);
                }
                return(true);
            }
            catch (Exception ex)
            {
                WriteEventLog(ex.Message);
                return(false);
            }
            finally
            {
                smtp = null;
            }
        }