예제 #1
0
        public IViewSource GetViewSource(string templateName, IList <IViewSource> parentViewSourceList)
        {
            Invariant.ArgumentNotEmpty(templateName, "templateName");
            Invariant.ArgumentNotNull(parentViewSourceList, "parentViewSourceList");
            templateName = SuffixWithHaml(templateName);
            var fileInfo = CreateFileInfo(templateName);

            if (fileInfo != null && fileInfo.Exists)
            {
                return(new FileViewSource(fileInfo));
            }
            for (var index = 0; index < parentViewSourceList.Count; index++)
            {
                var source = parentViewSourceList[index];
                //search where the current parent template exists
                var parentDirectory = Path.GetDirectoryName(source.Path);
                var combine         = Path.Combine(parentDirectory, templateName);
                if (File.Exists(combine))
                {
                    return(new FileViewSource(new FileInfo(combine)));
                }
            }

            throw new FileNotFoundException(string.Format("Could not find template '{0}'.", templateName));
        }
예제 #2
0
 public void AddReference(string assemblyLocation)
 {
     Invariant.ArgumentNotEmpty(assemblyLocation, "assemblyLocation");
     //TODO: sort this with iron ruby
     if (assemblyLocation.ToLower().EndsWith("mscorlib.dll"))
     {
         return;
     }
     References.Add(assemblyLocation);
 }
        public IDictionary <string, object> BuildAndValidateParameters()
        {
            var parameters = BuildParameters();

            if (!SkipOptionalParameterCheck)
            {
                foreach (var item in parameters)
                {
                    if (!OptionalParameters.Contains(item.Key))
                    {
                        Invariant.ArgumentNotEmpty(item.Value.AsString(), () => "Parameter '{0}' for named query '{1}' may not be null or empty".FormatInvariantCulture(item.Key, Name));
                    }
                }
            }

            return(parameters);
        }
예제 #4
0
        public ViewSource GetViewSource(string templateName, IEnumerable <ViewSource> parentViewSourceList)
        {
            Invariant.ArgumentNotEmpty(templateName, "templateName");
            Invariant.ArgumentNotNull(parentViewSourceList, "parentViewSourceList");

            templateName = SuffixWithHaml(templateName);
            var fileInfo = CreateFileInfo(templateName);

            if (fileInfo != null && fileInfo.Exists)
            {
                return(new FileViewSource(fileInfo));
            }

            //foreach (var source in parentViewSourceList)
            //{
            //    //search where the current parent template exists
            //    var parentDirectory = Path.GetDirectoryName(source.FilePath);
            //    var combine = Path.Combine(parentDirectory, templateName);
            //    if (File.Exists(combine))
            //        return new FileViewSource(new FileInfo(combine));
            //}

            throw new FileNotFoundException(string.Format("Could not find template '{0}'.", templateName));
        }
예제 #5
0
 public void ArgumentNotEmpty_EmptyString_ThrowsArgumentOutOfRangeException()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => Invariant.ArgumentNotEmpty(string.Empty, "param"));
 }
예제 #6
0
 public void ArgumentNotEmpty_NullArgument_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => Invariant.ArgumentNotEmpty(null, "param"));
 }
예제 #7
0
 public void ArgumentNotEmpty_ValidString_DoesNothing()
 {
     Assert.DoesNotThrow(() => Invariant.ArgumentNotEmpty("Test", "param"));
 }
예제 #8
0
        public void AddUsing(string @namespace)
        {
            Invariant.ArgumentNotEmpty(@namespace, "namespace");

            Usings.Add(@namespace);
        }
예제 #9
0
        public bool IsAutoClosingTag(string tag)
        {
            Invariant.ArgumentNotEmpty(tag, "tag");

            return(AutoClosingTags.Contains(tag.ToUpperInvariant()));
        }