예제 #1
0
        private static GitStrArrayManaged BuildFrom <T>(T[] input, Func <T, IntPtr> marshaler)
        {
            var pointers = new IntPtr[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                var item = input[i];
                pointers[i] = marshaler(item);
            }

            var toReturn = new GitStrArrayManaged();

            toReturn.Array.Strings = Marshal.AllocHGlobal(checked (IntPtr.Size * input.Length));
            Marshal.Copy(pointers, 0, toReturn.Array.Strings, input.Length);
            toReturn.Array.Count = new UIntPtr((uint)input.Length);

            return(toReturn);
        }
예제 #2
0
        /// <summary>
        /// Create wrapper around <see cref="GitCheckoutOpts"/> from <see cref="CheckoutOptions"/>.
        /// </summary>
        /// <param name="options">Options to create native GitCheckoutOpts structure from.</param>
        /// <param name="paths">Paths to checkout.</param>
        public GitCheckoutOptsWrapper(IConvertableToGitCheckoutOpts options, FilePath[] paths = null)
        {
            Callbacks = options.GenerateCallbacks();

            if (paths != null)
            {
                PathArray = GitStrArrayManaged.BuildFrom(paths);
            }

            Options = new GitCheckoutOpts
            {
                version           = 1,
                checkout_strategy = options.CheckoutStrategy,
                progress_cb       = Callbacks.CheckoutProgressCallback,
                notify_cb         = Callbacks.CheckoutNotifyCallback,
                notify_flags      = options.CheckoutNotifyFlags,
                paths             = PathArray.Array,
            };
        }