当前位置: 首页>>代码示例>>C#>>正文


C# this.Copy方法代码示例

本文整理汇总了C#中this.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# this.Copy方法的具体用法?C# this.Copy怎么用?C# this.Copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.Copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Copy

 internal static void Copy(this IFileSystem fileSystem, string source, string destination)
 {
     // if copying a file
     if (File.Exists(source))
     {
         fileSystem.WriteFile(destination, File.ReadAllText(source));
         return;
     }
     
     // if copying a directory
     if (fileSystem.DirectoryExists(destination))
     {
         fileSystem.DeleteDirectory(destination);
     }
     fileSystem.CreateDirectory(destination);
 
     // Copy dirs recursively
     foreach (var child in Directory.GetDirectories(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p => Path.GetDirectoryName(p)))
     {
         fileSystem.Copy(Path.Combine(source, child), Path.Combine(destination, child));
     }
     // Copy files
     foreach (var childFile in Directory.GetFiles(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p=>Path.GetFileName(p)))
     {
         fileSystem.Copy(Path.Combine(source, childFile), 
                         Path.Combine(destination, childFile));
     }
    
 }
开发者ID:devigned,项目名称:autorest,代码行数:29,代码来源:TestExtensions.cs

示例2: Divide

        /// <summary>
        /// Divide the specified Rectangle into two component rectangles
        /// </summary>
        /// <param name="amount">Amount to move away from the given edge</param>
        /// <param name="fromEdge">The edge to create the slice from.</param>
        public static Tuple<RectangleF, RectangleF> Divide(this RectangleF This, float amount, RectEdge fromEdge)
        {
            var delta = default(float);

            switch (fromEdge) {
            case RectEdge.Left:
                delta = Math.Max(This.Width, amount);
                return Tuple.Create(
                    This.Copy(Width: delta),
                    This.Copy(X: This.Left + delta, Width: This.Width - delta));
            case RectEdge.Top:
                delta = Math.Max(This.Height, amount);
                return Tuple.Create(
                    This.Copy(Height: amount),
                    This.Copy(Y: This.Top + delta, Height: This.Height - delta));
            case RectEdge.Right:
                delta = Math.Max(This.Width, amount);
                return Tuple.Create(
                    This.Copy(X: This.Right - delta, Width: delta),
                    This.Copy(Width: This.Width - delta));
            case RectEdge.Bottom:
                delta = Math.Max(This.Height, amount);
                return Tuple.Create(
                    This.Copy(Y: This.Bottom - delta, Height: delta),
                    This.Copy(Height: This.Height - delta));
            default:
                throw new ArgumentException("edge");
            }
        }
开发者ID:hogjosh,项目名称:splat,代码行数:34,代码来源:RectangleExtensions.cs

示例3: ExtendWithContextMenu

        public static void ExtendWithContextMenu(this TextEditor rtb)
        {
            ContextMenu ctx = new ContextMenu();

            MenuItem cut = new MenuItem();
            cut.Header = "Cut";
            cut.Click += (sender, e) => rtb.Cut();

            MenuItem copy = new MenuItem();
            copy.Header = "Copy";
            copy.Click += (sender, e) => rtb.Copy();

            MenuItem paste = new MenuItem();
            paste.Header = "Paste";
            paste.Click += (sender, e) => rtb.Paste();

            ctx.Items.Add(cut);
            ctx.Items.Add(copy);
            ctx.Items.Add(paste);

            rtb.ContextMenu = ctx;

            ctx.Opened +=
                (sender, e) =>
                {
                    bool noSelectedText = string.IsNullOrEmpty(rtb.SelectedText);

                    cut.IsEnabled = !noSelectedText;
                    copy.IsEnabled = !noSelectedText;

                    bool noClipboardText = string.IsNullOrEmpty(Clipboard.GetText());

                    paste.IsEnabled = !noClipboardText;
                };
        }
开发者ID:furesoft,项目名称:IntegratedJS,代码行数:35,代码来源:Extensions.cs

示例4: Clamp

		/// <summary>
		/// 	Creates a copy of the texture, set to clamped.
		/// </summary>
		/// <param name="extends">Extends.</param>
		public static Texture2D Clamp(this Texture2D extends)
		{
			Texture2D output = extends.Copy();
			output.wrapMode = TextureWrapMode.Clamp;

			return output;
		}
开发者ID:JustJessTV,项目名称:GitMergeTest,代码行数:11,代码来源:Texture2DExtensions.cs

示例5: Repeat

		/// <summary>
		/// 	Creates a copy of the texture, set to repeat.
		/// </summary>
		/// <param name="extends">Extends.</param>
		public static Texture2D Repeat(this Texture2D extends)
		{
			Texture2D output = extends.Copy();
			output.wrapMode = TextureWrapMode.Repeat;

			return output;
		}
开发者ID:JustJessTV,项目名称:GitMergeTest,代码行数:11,代码来源:Texture2DExtensions.cs

示例6: GetSub

        public static OpenCvSharp.IplImage GetSub(this OpenCvSharp.IplImage ipl, OpenCvSharp.CvRect subRect)
        {
            if (ipl == null)
                throw new ArgumentNullException("ipl", "ipl is null.");

            var boundingRect = new CvRect(0, 0, ipl.Width, ipl.Height);

            if (!boundingRect.Contains(subRect))
                throw new InvalidOperationException("subRect is outside of ipl");

            try
            {
                ipl.SetROI(subRect);

                OpenCvSharp.IplImage sub = new IplImage(
                    ipl.GetSize(),
                    ipl.Depth,
                    ipl.NChannels);

                ipl.Copy(sub);
                return sub;
            }
            finally
            {
                ipl.ResetROI();
            }
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:27,代码来源:Extensions.cs

示例7: CopyRecursive

        public static bool CopyRecursive(this GLib.File source, GLib.File target, GLib.FileCopyFlags flags, GLib.Cancellable cancellable, GLib.FileProgressCallback callback)
        {
            bool result = true;

            GLib.FileType ft = source.QueryFileType (GLib.FileQueryInfoFlags.None, cancellable);

            if (ft != GLib.FileType.Directory) {
                Hyena.Log.DebugFormat ("Copying \"{0}\" to \"{1}\"", source.Path, target.Path);
                return source.Copy (target, flags, cancellable, callback);
            }

            if (!target.Exists) {
                Hyena.Log.DebugFormat ("Creating directory: \"{0}\"", target.Path);
                result = result && target.MakeDirectoryWithParents (cancellable);
            }

            GLib.FileEnumerator fe = source.EnumerateChildren ("standard::name", GLib.FileQueryInfoFlags.None, cancellable);
            GLib.FileInfo fi = fe.NextFile ();
            while (fi != null) {
                GLib.File source_file = GLib.FileFactory.NewForPath (Path.Combine (source.Path, fi.Name));
                GLib.File target_file = GLib.FileFactory.NewForPath (Path.Combine (target.Path, fi.Name));
                result = result && source_file.CopyRecursive(target_file, flags, cancellable, callback);
                fi = fe.NextFile ();
            }
            fe.Close (cancellable);
            return result;
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:27,代码来源:FileExtensions.cs

示例8: CopyToClipboard

 public static void CopyToClipboard(this RichTextBox richTextBox)
 {
     var textSelection = richTextBox.Selection;
     var start = textSelection.Start;
     var textPointer = textSelection.End;
     richTextBox.SelectAll();
     richTextBox.Copy();
     richTextBox.Selection.Select(start, textPointer);
 }
开发者ID:nagyist,项目名称:PlatformInstaller,代码行数:9,代码来源:WpfExtensions.cs

示例9: ScrubNulls

 /// <summary>
 /// Make sure that DBNull.Value is converted to null, so that we treat DBNull and null the same
 /// on the backend
 /// </summary>
 /// <param name="values"></param>
 /// <returns></returns>
 public static Dictionary<string, object> ScrubNulls(this Dictionary<string, object> values)
 {
     var fields = values.Where(kv => kv.Value == DBNull.Value).Select(kv => kv.Key);
     if (!fields.Any())
         return values;
     var res = values.Copy();
     fields.Each(f => res[f] = null);
     return res;
 }
开发者ID:badjer,项目名称:Lasy,代码行数:15,代码来源:DictionaryExtensions.cs

示例10: Clone

        public static PSVariableProperty Clone(this PSVariableProperty source)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            var clone = (PSVariableProperty)source.Copy();
            clone.Set_instance(null);
            clone.Set__variable(source.Get__variable().Clone());
            return clone;
        }
开发者ID:urasandesu,项目名称:Pontine,代码行数:10,代码来源:PSVariablePropertyMixin.cs

示例11: ToInt16

        public static Int16 ToInt16(this Byte[] source, Endianess endianess, Int32 startIndex = 0)
        {
            var bytes = source.Copy(startIndex, NumberHelpers.Int16ByteCount);

            if (NumberHelpers.Endianess != endianess)
            {
                bytes.Swap();
            }

            return bytes.ToInt16();
        }
开发者ID:ehouarn-perret,项目名称:EhouarnPerret.CSharp.Utilities,代码行数:11,代码来源:NumberExtensions.cs

示例12: CopyModified

        public static FontDescription CopyModified(this FontDescription font, double? scale = null, Pango.Weight? weight = null)
        {
            font = font.Copy ();

            if (scale.HasValue)
                Scale (font, scale.Value);

            if (weight.HasValue)
                font.Weight = weight.Value;

            return font;
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:12,代码来源:FontService.cs

示例13: SaveToFile

        public static void SaveToFile(this Stream self, string fileName)
        {
            if (self == null)
                throw new ArgumentNullException("self");
            if (fileName == null)
                throw new ArgumentNullException("fileName");

            using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                self.Copy(fs);
                fs.Flush();
                fs.Close();
            }
        }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:14,代码来源:StreamExtensions.cs

示例14: SubImage

        public static OpenCvSharp.IplImage SubImage(
            this OpenCvSharp.IplImage whole,
            OpenCvSharp.CvRect region)
        {
            whole.SetROI(region);

            OpenCvSharp.IplImage part =
                new OpenCvSharp.IplImage(new OpenCvSharp.CvSize(region.Width, region.Height),
                                         whole.Depth, whole.NChannels);

            whole.Copy(part);

            whole.ResetROI();

            return part;
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:16,代码来源:Util.cs

示例15: Print

        public static void Print(this Body body, Part part = null)
        {
            body = body.Copy();

            if (body.PieceCount > 1) {
                ICollection<Body> bodies = body.SeparatePieces();
                Debug.Assert(bodies.Count == body.PieceCount);
                bodies.Print();
                return;
            }

            try {
                DesignBody.Create(part ?? MainPart, GetDebugString(body), body);
            }
            catch { }
        }
开发者ID:bcourter,项目名称:SpaceClaim-AddIns,代码行数:16,代码来源:DebugExtensions.cs


注:本文中的this.Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。