예제 #1
0
        protected sealed override bool run()
        {
            var sourceFileName = SourceFileName.GetValue();
            var destFileName   = DestFileName.GetValue();

            File.Move(sourceFileName, destFileName);

            return(true);
        }
예제 #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputXmlSource">The xmlsource to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(XmlSource inputXmlSource)
        {
            if (SourceFileName.GetString() != inputXmlSource.SourceFileName.GetString())
            {
                return(false);
            }
            if (SourceFilePath.GetString() != inputXmlSource.SourceFilePath.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
예제 #3
0
        protected sealed override bool run()
        {
            var sourceFileName = SourceFileName.GetValue();
            var destFileName   = DestFileName.GetValue();

            if (Overwrite == null)
            {
                File.Copy(sourceFileName, destFileName);
            }
            else
            {
                File.Copy(sourceFileName, destFileName, Overwrite.Check());
            }

            return(true);
        }
예제 #4
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hash = 17;
         // Suitable nullity checks etc, of course :)
         hash = hash * 23 + Width.GetHashCode();
         hash = hash * 23 + Height.GetHashCode();
         hash = hash * 23 + ColorCount.GetHashCode();
         hash = hash * 23 + ReservedByte.GetHashCode();
         hash = hash * 23 + Planes.GetHashCode();
         hash = hash * 23 + BitCount.GetHashCode();
         hash = hash * 23 + SizeInBytes.GetHashCode();
         hash = hash * 23 + FileOffset.GetHashCode();
         hash = hash * 23 + (SourceFileName == null ? 1 : SourceFileName.GetHashCode());
         hash = hash * 23 + SourceIndex.GetHashCode();
         return(hash);
     }
 }
예제 #5
0
        //  public HowLeakyDataType Type { get; set; }

        internal bool ContainsSearchTerm(string search)
        {
            if (!String.IsNullOrEmpty(CodeName) && CodeName.ToLower().Contains(search))
            {
                return(true);
            }
            if (!String.IsNullOrEmpty(LabelTitle) && LabelTitle.ToLower().Contains(search))
            {
                return(true);
            }
            if (!String.IsNullOrEmpty(SourceFileName) && SourceFileName.ToLower().Contains(search))
            {
                return(true);
            }
            if (!String.IsNullOrEmpty(Description) && Description.ToLower().Contains(search))
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Adds the item to ParentProjectItem
        /// </summary>
        public override void Execute()
        {
            if (ExcludeCondition)
            {
                return;
            }
            if (!AdditionalCondition)
            {
            }

            DTE     dte     = (DTE)this.GetService(typeof(DTE));
            Project project = this.GetTargetProject(dte);

            if (SourceFileName.Contains(";"))
            {
                string   evaluatedDeploymentPath = EvaluateParameterAsString(dte, DeploymentPath);
                char[]   sep      = new char[] { ';' };
                string[] allFiles = SourceFileName.Split(sep);
                foreach (string file in allFiles)
                {
                    string fullFileName = file;
                    fullFileName = fullFileName.Trim();
                    if (!string.IsNullOrEmpty(fullFileName))
                    {
                        string sourceFilePath = fullFileName;
                        AddFileInternal(dte, project, sourceFilePath, "", evaluatedDeploymentPath);
                    }
                }
            }
            else
            {
                string evaluatedTargetFileName = EvaluateParameterAsString(dte, TargetFileName);
                string evaluatedSourceFileName = EvaluateParameterAsString(dte, SourceFileName);
                string evaluatedDeploymentPath = EvaluateParameterAsString(dte, DeploymentPath);

                AddFileInternal(dte, project, evaluatedSourceFileName, evaluatedTargetFileName, evaluatedDeploymentPath);
            }
        }
예제 #7
0
 public override string GetFileName()
 {
     return(SourceFileName.Insert(SourceFileName.LastIndexOf('_'), suffix));
 }
예제 #8
0
        private void FileMerge()
        {
            string        strSourceDFDFileName  = null;                //存放源文件夹中DFD文件的路径
            List <string> ListSourceDFXFileName = new List <string>(); //定义一个链表存放源文件DFX路径和名称

            //因为文件夹下面只有一层子文件,所以考虑不使用递归遍历
            //从源文件夹的路径实例化一个文件夹
            DirectoryInfo TheSourceFloder = new DirectoryInfo(SourceFolderPath);
            bool          SourceDFDFileExistFlag;

            //遍历源文件夹下的所有子文件夹
            foreach (DirectoryInfo dir in TheSourceFloder.GetDirectories())
            {
                SourceDFDFileExistFlag = false;
                ListSourceDFXFileName.Clear();

                //在目标文件夹下新建文件
                if (dir.Name == "新建文件夹")
                {
                    continue;
                }

                FileStream fs = new FileStream(ObjectFolderPath + @"\" + dir.Name + ".DFQ", FileMode.Create, FileAccess.Write);


                //实例化源文件夹中的每一个子文件夹
                DirectoryInfo TheSubFolder = new DirectoryInfo(SourceFolderPath + @"\" + dir.Name);


                //实例化一个对象用于写文件
                StreamWriter TheWriteDFQFile = new StreamWriter(fs, System.Text.Encoding.Default);

                //得到某个源子文件夹中的DFX文件
                foreach (FileInfo SourceFileName in TheSubFolder.GetFiles("*.DFX"))
                {
                    //得到文件的路径
                    ListSourceDFXFileName.Add(SourceFolderPath + @"\" + dir.Name + @"\" + SourceFileName.ToString());
                }

                strSourceDFDFileName = null;
                //如果还没有拿到DFD文件的路径,去找到;如果拿到了,不再寻找
                if (SourceDFDFileExistFlag == false)
                {
                    foreach (FileInfo SourceFileName in TheSubFolder.GetFiles("*.DFD"))
                    {
                        //得到文件的路径
                        strSourceDFDFileName   = SourceFolderPath + @"\" + dir.Name + @"\" + SourceFileName.ToString();
                        SourceDFDFileExistFlag = true;
                    }

                    //先写入DFD文件
                    if (strSourceDFDFileName != null)
                    {
                        //原来是gb2312
                        StreamReader TheReadDFDFile = new StreamReader(strSourceDFDFileName, System.Text.Encoding.Default);
                        string       TheDFDFileTxt  = TheReadDFDFile.ReadToEnd();
                        TheReadDFDFile.Close();

                        TheWriteDFQFile.Write(TheDFDFileTxt);
                    }
                }


                //遍历链表中的每一个DFX文件
                foreach (string SourceFileName in ListSourceDFXFileName)
                {
                    //实例化一个对象用于读取文件
                    StreamReader TheReadDFXFile = new StreamReader(SourceFileName, System.Text.Encoding.Default);
                    string       TheDFXFileTxt  = TheReadDFXFile.ReadToEnd();
                    TheReadDFXFile.Close();

                    //写入新文件
                    TheWriteDFQFile.Write(TheDFXFileTxt);
                }

                TheWriteDFQFile.Flush();  //为了保护硬盘?
                TheWriteDFQFile.Close();
                fs.Close();

                //List<string> lstr = new List<string>();
                //File.ReadAllLines(ObjectFileName, Encoding.GetEncoding("gb2312")).ToList<string>().ForEach(str =>
                //{
                //    if (string.Empty.CompareTo(str.Trim()) != 0)
                //        lstr.Add(str);
                //});
                //File.WriteAllLines(ObjectFileName, lstr.ToArray<string>());


                //原来是UTF-8
                //目标文件路径及名称
                string ObjectFileName = ObjectFolderPath + @"\" + dir.Name + ".DFQ";
                string tempStr        = File.ReadAllText(ObjectFileName, System.Text.Encoding.Default);//读取文档
                //tempStr = Regex.Replace(tempStr, @"(\s)+", "\r\n\r\n");//替换为两个个换行,可以自己输入
                //tempStr = Regex.Replace(tempStr, "\r\n\r\n", "");//替换为两个换行,可以自己输入
                for (int i = 0; i <= 50; i++)
                {
                    tempStr = Regex.Replace(tempStr, "\r\n\r\n", "\r\n");                 //替换为两个换行,可以自己输入
                }
                File.WriteAllText(ObjectFileName, tempStr, System.Text.Encoding.Default); //写入文档
            }//结束文件夹的遍历
        }