public static TypeArgumentSpecification Type(this TypeArgumentSpecification @this, Func<Type, TypeSpecification, TypeSpecification> typeSpecification)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(typeSpecification, "typeSpecification");

            return @this.Combine(ta => typeSpecification(ta, TypeSpecificationBuilder.Any)(ta));
        }
        public static ParameterSpecification Type(this ParameterSpecification @this, Func<ParameterInfo, TypeSpecification, TypeSpecification> typeSpecification)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(typeSpecification, "typeSpecification");

            return @this.Combine(p => typeSpecification(p, TypeSpecificationBuilder.Any)(p.ParameterType));
        }
        public static string GetReferenceVirtualPath(this IVirtualPathProvider virtualPathProvider, string basePath, string referenceName, string hintPath) {
            // Check if hint path is valid
            if (!string.IsNullOrEmpty(hintPath)) {
                if (virtualPathProvider.TryFileExists(virtualPathProvider.Combine(basePath, hintPath)))
                    return hintPath;
            }

            // Fall back to bin directory
            string relativePath = virtualPathProvider.Combine("bin", referenceName + ".dll");
            if (virtualPathProvider.TryFileExists(virtualPathProvider.Combine(basePath, relativePath)))
                return relativePath;

            return null;
        }
        public static TypeSpecification IsEqualTo(this TypeSpecification @this, Type expected)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(expected, "expected");

            return @this.Combine(t => Outcome.FailIf(t != expected, String.Format("Not the expected type: {0}", expected.Name)));
        }
        public static ParameterSpecification Named(this ParameterSpecification @this, string name)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNullOrWhiteSpace(name, "name");

            return @this.Combine(x => Outcome.FailIf(x.Name != name, String.Format("Not named '{0}'.", name)));
        }
示例#6
0
        public static string CombineToAppPath(this IFolder folder, params string[] paths)
        {
            folder.ArgumentNullExceptionByNullOrEmpty("folder");
            folder.Root.ArgumentNullExceptionByNullOrEmpty("folder.Root");

            return PathUtility.PhysicsPathSeparatorCharConvertToVirtualPathSeparatorChar(Path.Combine(folder.Root.RootPath, folder.Combine(paths).TrimStart('/')));
        }
 public static Ani<Rect> BoundingBox(this Ani<Rect> rect1, Ani<Rect> rect2)
 {
     return rect1.Combine(rect2,
                          (r1, r2) => new Rect(
                              new Point(r1.X.Min(r2.X), r1.Y.Min(r2.Y)),
                              new Point(r1.Right.Max(r2.Right), r1.Bottom.Max(r2.Bottom))));
 }
示例#8
0
 public static Uri Combine(this Uri uri1, string[] additions)
 {
     foreach (var addition in additions)
     {
         uri1 = uri1.Combine(addition);
     }
     return uri1;
 }
示例#9
0
		/// <summary>
		/// 	Combines two paths and makes sure the 
		/// 	DIRECTORY resulting from the combination exists
		/// 	by creating it with default permissions if it doesn't.
		/// </summary>
		/// <param name = "input">The path to combine the latter with.</param>
		/// <param name = "path">The latter path.</param>
		/// <returns>The combined path string.</returns>
		public static string CombineAssert(this string input, string path)
		{
			var p = input.Combine(path);

			if (!Directory.Exists(p))
				Directory.CreateDirectory(p);

			return p;
		}
        /// <summary>
        /// Combines the specified <paramref name="password"/> with the specified <paramref name="salt"/>.
        /// </summary>
        /// <param name="self">The salt combiner.</param>
        /// <param name="salt">The salt.</param>
        /// <param name="iterationCount">The iteration count.</param>
        /// <param name="password">The password.</param>
        public static byte[] Combine(this ISaltCombiner self, byte[] salt, int iterationCount, byte[] password)
        {
            Guard.NotNull(self, nameof(self));
            Guard.NotNullOrEmpty(salt, nameof(salt));
            Guard.NotZeroOrNegative(iterationCount, nameof(iterationCount));
            Guard.NotNullOrEmpty(password, nameof(password));

            return self.Combine(salt, iterationCount, BitConverter.ToString(password));
        }
示例#11
0
 public static string Combine(this IFileStorage fileStorage, params string[] paths)
 {
     var path = paths[0];
     for (int i = 1; i < paths.Length; i++)
     {
         path = fileStorage.Combine(path, paths[i]);
     }
     return path;
 }
        public static IOrchardFileSystem GetExtensionFileProvider(
            this IOrchardFileSystem parentFileSystem,
            ExtensionDescriptor extensionDescriptor,
            ILogger logger)
        {
            var subPath = parentFileSystem.Combine(extensionDescriptor.Location, extensionDescriptor.Id);

            return parentFileSystem
                .GetSubPathFileProvider(subPath, logger);
        }
        public static string GetProjectReferenceVirtualPath(this IVirtualPathProvider virtualPathProvider, string projectPath, string referenceName, string hintPath) {

            string basePath = virtualPathProvider.GetDirectoryName(projectPath);
            string virtualPath = virtualPathProvider.GetReferenceVirtualPath(basePath, referenceName, hintPath);

            if (!string.IsNullOrEmpty(virtualPath)) {
                return virtualPathProvider.Combine(basePath, virtualPath);
            }

            return null;
        }
        public static string Combine(this string url, IEnumerable<SearchCriteria> searches, LogicalOperator logical, IEnumerable<SortDescription> sorting, int? pageCount)
        {
            var queries = new List<string>();
            if (pageCount.HasValue)
                queries.Add(GetPagingQueryString(pageCount.Value));
            if (searches != null && searches.Count() > 0)
                queries.Add(searches.ConstructFilterQueryString(logical));
            if (sorting != null && sorting.Count() > 0)
                queries.Add(sorting.ConstructOrderByQueryString());

            return url.Combine(queries);
        }
示例#15
0
        public static SqlQuery Where(this SqlQuery query, ExpandoObject where, char prefix)
        {
            if (null != query && null != where)
            {
                IDictionary<string, object> dic = where;
                StringBuilder sql = query.Text;
                FilterCriteriaList criterias = new FilterCriteriaList(prefix);
                foreach (KeyValuePair<string, object> kvp in dic)
                {
                    criterias.Add(kvp.Key, null, ConditionOperator.Equals, kvp.Value);
                }

                query.Combine(criterias.ToQuery());
            }
            return query;
        }
        public static MethodSpecification GenericArgument(this MethodSpecification @this, Func<MethodInfo, TypeArgumentSpecification, TypeArgumentSpecification> argumentSpecification)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(argumentSpecification, "argumentSpecification");

            return @this.Combine(m =>
            {
                var argSpec = argumentSpecification(m, TypeArgumentSpecificationBuilder.Any);
                var outcomes = m.GetGenericArguments().Select(x => argSpec(x));
                return outcomes
                    .TryFirst(x => x.WasSuccessful)
                    .ValueOrDefault(() => outcomes.Combine());
            });
        }
 public static MethodSpecification HasGenericArguments(this MethodSpecification @this, int count)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(m.GetGenericArguments().Length != count, String.Format("Did not have {0} generic argument(s).", count)));
 }
 public static MethodSpecification IsClosedGeneric(this MethodSpecification @this)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(m.IsGenericMethodDefinition, "Was not closed generic."));
 }
 public static MethodSpecification IsPublic(this MethodSpecification @this)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(!m.IsPublic, "Was not public."));
 }
示例#20
0
		/// <summary>
		/// Sets a GetDirectoryName default behavior.
		/// </summary>
		/// <param name="path">Substitute to set.</param>
		public static void SetCombineDefaultBehavior(this IPath path)
		{
			path.Combine(Arg.Any<string[]>()).ReturnsForAnyArgs(args =>
			{
				var elements = args.Arg<string[]>(); 
				return Combine(elements);
			});
		}
 public static MethodSpecification HasParameters(this MethodSpecification @this, int count)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(m.GetParameters().Length != count, String.Format("Did not have {0} parameter(s).", count)));
 }
示例#22
0
 /// <summary>
 /// Combines buffers together as a single image.
 /// </summary>
 /// <param name="source">Source buffer.</param>
 /// <param name="other">Other buffer to combine to <paramref name="source"/> buffer.</param>
 /// <returns>Combined buffers.</returns>
 public static byte[] Combine(this byte[] source, byte[] other)
 {
     return source.Combine(0, source.Length, other, 0, other.Length);
 }
 public static ParameterSpecification AtIndex(this ParameterSpecification @this, int index)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(p => Outcome.FailIf(p.Position != index, "Not at correct index"));
 }
        public static MethodSpecification Parameter(this MethodSpecification @this, Func<MethodInfo, ParameterSpecification, ParameterSpecification> parameterSpecification)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(parameterSpecification, "parameterSpecification");

            return @this.Combine(m =>
            {
                var parameterSpec = parameterSpecification(m, ParameterSpecificationBuilder.Any);
                var outcomes = m.GetParameters().Select(x => parameterSpec(x));
                return outcomes
                    .TryFirst(x => x.WasSuccessful)
                    .ValueOrDefault(() => outcomes.Combine());
            });
        }
示例#25
0
 public static Ani<Rect> WithTopLeft(this Ani<Size> size, Ani<Point> point)
 {
     return size.Combine(point, (s, p) => new Rect(p, s));
 }
        public static MethodSpecification Returns(this MethodSpecification @this, Func<MethodInfo, TypeSpecification, TypeSpecification> returnSpecification)
        {
            Guard.NotNull(@this, "this");
            Guard.NotNull(returnSpecification, "returnSpecification");

            return @this.Combine(m =>
            {
                var returnSpec = returnSpecification(m, TypeSpecificationBuilder.Any);
                return returnSpec(m.ReturnType);
            });
        }
示例#27
0
 public static IIdResolver RegisterTestSkills(this IIdResolver idResolver)
 {
     return idResolver.Combine(new IdResolutionContext(Skills));
 }
 public static MethodSpecification IsNotExtensionMethod(this MethodSpecification @this)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(m.GetParameters().TryElementAt(0).Select(x => x.IsDefined(typeof(ExtensionAttribute), true)).ValueOrDefault(), "Should not be an extension method."));
 }
示例#29
0
		internal static bool IsGitRepository (this FilePath path)
		{
			// Maybe check if it has a HEAD file? But this check should be enough.
			var newPath = path.Combine (".git");
			return Directory.Exists (newPath) && Directory.Exists (newPath.Combine ("objects")) && Directory.Exists (newPath.Combine ("refs"));
		}
 public static MethodSpecification Named(this MethodSpecification @this, string name)
 {
     Guard.NotNull(@this, "this");
     return @this.Combine(m => Outcome.FailIf(m.Name != name, String.Format("Was not named '{0}'.", name)));
 }