public RegexConstraint(string parameterName, string pattern, RegexOptions options) { Precondition.Defined(parameterName, () => Error.ArgumentNull("parameterName")); _parameterName = parameterName; _pattern = new Regex(NormalizePattern(pattern), options); }
public static string CheckBox(this HtmlControlHelper helper, string name, object value, bool isChecked, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (attributes == null) { attributes = new ValueDictionary(); } if (helper.DataSource.Keys.Any(k => k.Equals(name, StringComparison.OrdinalIgnoreCase)) || helper.DataSource.Keys.Any()) { isChecked = helper.DataSource.GetValue <bool>(name); } if (isChecked) { attributes["checked"] = "checked"; } else { attributes.Remove("checked"); } return(InputBuilder(helper, "checkbox", name, value, attributes)); }
public static string RadioButton(this HtmlControlHelper helper, string name, object value, bool isChecked, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (attributes == null) { attributes = new ValueDictionary(); } if (helper.DataSource.Keys.Any(k => k.Equals(name, StringComparison.OrdinalIgnoreCase))) { string providedValue = Convert.ToString(value, CultureInfo.InvariantCulture); string actualValue = helper.DataSource.GetValue <string>(name); isChecked = (!String.IsNullOrEmpty(actualValue) && String.Equals(providedValue, actualValue, StringComparison.OrdinalIgnoreCase)); } if (isChecked) { attributes["checked"] = "checked"; } else { attributes.Remove("checked"); } return(InputBuilder(helper, "radio", name, value, attributes)); }
protected virtual bool IsAssemblyResource(string virtualPath, out string resourceName) { Precondition.Defined(virtualPath, () => Error.ArgumentNull("virtualPath")); virtualPath = VirtualPathUtility.ToAppRelative(virtualPath); resourceName = null; if (!virtualPath.StartsWith(VirtualPath, StringComparison.InvariantCultureIgnoreCase)) { return(false); } if (Assembly != null) { string[] resources = Assembly.GetManifestResourceNames(); resourceName = ConstructAssemblyResourceName(virtualPath); if (resources != null && resources.Contains(resourceName, StringComparer.InvariantCultureIgnoreCase)) { return(true); } } resourceName = null; return(false); }
/// <summary> /// Initializes a new instance of the /// <see cref="CommonDbDataProvider"/> class. /// </summary> /// <param name="connectionString">The database connection string.</param> protected CommonDbDataProvider(string connectionString) { Precondition.Defined(connectionString, () => Error.ConnectionStringNotInitialized()); _connection = CreateConnection(connectionString); }
protected RouteConstraintDefinition(string parameterName) { Precondition.Defined(parameterName, () => Error.ArgumentNull("parameterName")); _parameterName = parameterName; }
public virtual T Get <T>(string key, CacheItemSelector <T> selector, DateTime expiration, IEnumerable <string> tags) { Precondition.Defined(key, () => Error.ArgumentNull("key")); Precondition.Require(selector, () => Error.ArgumentNull("selector")); Precondition.Require(!_disposed, () => Error.ObjectDisposed("entries")); _entriesLock.EnterUpgradeableReadLock(); try { CacheEntry entry; if (!TryGetEntryAndValidate(key, out entry)) { _entriesLock.EnterWriteLock(); try { if (!TryGetEntryAndValidate(key, out entry)) { _entries[key] = entry = new CacheEntry(key, selector(), expiration, CreateEntryTags(tags)); } } finally { _entriesLock.ExitWriteLock(); } } return(Converter.ChangeType <T>(entry.Value)); } finally { _entriesLock.ExitUpgradeableReadLock(); } }
public void Add(string name, IDbDataProviderFactory item) { Precondition.Defined(name, () => Error.ArgumentNull("name")); Precondition.Require(item, () => Error.ArgumentNull("item")); _collection[name] = item; _default = null; }
/// <summary> /// Renders the specified view against the current context. /// </summary> /// <param name="viewName">The name of the view to render.</param> /// <param name="model">The model object supplied to the view.</param> /// <param name="viewData">The view data supplied to the view.</param> public void Include(string viewName, object model, ViewDataDictionary viewData) { Precondition.Defined(viewName, () => Error.ArgumentNull("viewName")); ComponentController component = new ComponentController(); component.RenderView(_context, viewName, model, viewData); }
protected virtual IController CreateController( RequestContext context, string controllerName) { Precondition.Require(context, () => Error.ArgumentNull("context")); Precondition.Defined(controllerName, () => Error.InvalidArgument("controllerName")); return(GetControllerInstance(context, GetControllerType(controllerName))); }
public HtmlElementBuilder(string tagName, object attributes, string content) { Precondition.Defined(tagName, () => Error.ArgumentNull("tagName")); _name = tagName; _attributes = new HtmlAttributeDictionary(attributes); _content = content; }
public ApplyCultureAttribute(string parameterName) { Precondition.Defined(parameterName, () => Error.ArgumentNull("parameterName")); _parameterName = parameterName; _source = "Header"; }
public CacheTag(string value, long version) { Precondition.Defined(value, () => Error.ArgumentNull("value")); _value = value; _version = version; }
public void Merge(string key, object value, bool replaceExisting) { Precondition.Defined(key, () => Error.ArgumentNull("key")); if (!_values.ContainsKey(key) || replaceExisting) { _values[key] = value; } }
public DirectiveExpression(string directiveName) : base(TemplateExpressionType.Directive) { Precondition.Defined(directiveName, () => Error.ArgumentNull("directiveName")); _name = directiveName; _attributes = new ParsedAttributeCollection(); }
public DbParameterDescriptor(string name, ParameterDirection direction, object value) { Precondition.Defined(name, () => Error.ArgumentNull("name")); _name = name; _direction = direction; _value = value; }
/// <summary> /// Initializes a new instance of the <see cref="Radischevo.Wahha.Web.Hosting.AssemblyResourceVirtualFile" /> class. /// </summary> /// <param name="virtualPath">The virtual path to the resource represented by this instance.</param> /// <param name="assembly">The <see cref="System.Reflection.Assembly"/> containing /// the resource represented by this instance.</param> /// <param name="resourcePath">The path to the embedded resource in the <paramref name="assembly" />.</param> /// <exception cref="System.ArgumentNullException" /> public AssemblyResourceVirtualFile(string virtualPath, Assembly assembly, string resourcePath) : base(virtualPath) { Precondition.Require(assembly, () => Error.ArgumentNull("assembly")); Precondition.Defined(resourcePath, () => Error.ArgumentNull("resourcePath")); _assembly = assembly; _resourcePath = resourcePath; }
public WebFormRoutingHandler(string virtualPath, bool validateAccessRights, IBuildManager buildManager) : base() { Precondition.Defined(virtualPath, () => Error.ArgumentNull("virtualPath")); _virtualPath = virtualPath; _validateAccessRights = validateAccessRights; _buildManager = buildManager; }
public CacheEntry(string key, object value, DateTime expiration, IEnumerable <CacheTag> tags) { Precondition.Defined(key, () => Error.ArgumentNull("key")); _key = key; _hashCode = _key.GetHashCode(); _value = value; _tags = tags ?? Enumerable.Empty <CacheTag>(); _expires = expiration; }
public override bool InvokeAction(ControllerContext context, string actionName, IDictionary <string, object> values) { Precondition.Require(context, () => Error.ArgumentNull("context")); Precondition.Defined(actionName, () => Error.ArgumentNull("actionName")); IAsyncResult result = BeginInvokeAction(context, actionName, null, null, values); return(EndInvokeAction(result)); }
public StringReplacementRule(StringReplacementMode mode, string pattern, string replacement) { Precondition.Defined(pattern, () => Error.ArgumentNull("pattern")); _mode = mode; _pattern = pattern; _replacement = replacement; _options = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline; }
public static string TextArea(this HtmlControlHelper helper, string name, string value, int rows, int columns, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (helper.DataSource.Keys.Any(k => k.Equals(name, StringComparison.OrdinalIgnoreCase))) { value = helper.DataSource.GetValue <string>(name); } return(TextAreaBuilder(helper, name, value, rows, columns, attributes)); }
public ParsedTemplate ParseFile(string fileName) { Precondition.Defined(fileName, () => Error.ArgumentNull("fileName")); using (StreamReader reader = new StreamReader( ConstructPhysicalPath(fileName, out _virtualPath))) { return(Parse(reader)); } }
protected BuildManagerCompiledView(string viewPath, IBuildManager buildManager, IViewActivator activator) { Precondition.Defined(viewPath, () => Error.ArgumentNull("viewPath")); Precondition.Require(buildManager, () => Error.ArgumentNull("buildManager")); Precondition.Require(activator, () => Error.ArgumentNull("activator")); _viewPath = viewPath; _buildManager = buildManager; _activator = activator; }
public RouteDefinition(string name, Route route) { Precondition.Defined(name, () => Error.ArgumentNull("name")); Precondition.Require(route, () => Error.ArgumentNull("route")); _name = name; _route = route; _url = route.Url; _defaults = CreateDefaults(route.Defaults); _constraints = new List <RouteConstraintDefinition>(); }
public static string TextBox(this HtmlControlHelper helper, string name, object value, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (helper.DataSource.Keys.Any(c => String.Equals(c, name, StringComparison.InvariantCultureIgnoreCase))) { value = helper.DataSource.GetValue <object>(name); } return(InputBuilder(helper, "text", name, value, attributes)); }
public static string Hidden(this HtmlControlHelper helper, string name, object value, IDictionary <string, object> attributes) { Precondition.Defined(name, () => Error.ArgumentNull("name")); if (helper.DataSource.Keys.Any(k => k.Equals(name, StringComparison.OrdinalIgnoreCase))) { value = helper.DataSource.GetValue <object>(name); } return(InputBuilder(helper, "hidden", name, value, attributes)); }
public virtual bool InvokeAction(ControllerContext context, string actionName, IDictionary <string, object> values) { Precondition.Require(context, () => Error.ArgumentNull("context")); Precondition.Defined(actionName, () => Error.ArgumentNull("actionName")); ControllerDescriptor controller = GetControllerDescriptor(context); ActionDescriptor currentAction = FindAction(context, controller, actionName); if (currentAction == null) { return(false); } ActionFilterInfo filters = GetFilters(context, currentAction); try { context.Parameters.Merge(values); context.Parameters.Merge(GetParameterValues(context, currentAction)); AuthorizationContext authContext = InvokeAuthorizationFilters( context, currentAction, filters.AuthorizationFilters); if (authContext.Cancel) { InvokeActionResult(context, authContext.Result ?? EmptyResult.Instance); } else { if (context.Controller.ValidateRequest) { ValidateRequest(context.Context.Request); } ActionExecutedContext resultContext = InvokeActionFilters( context, currentAction, filters.ActionFilters); InvokeActionResultFilters(context, filters.ResultFilters, resultContext.Result); } } catch (Exception ex) { ExceptionContext exceptionContext = InvokeExceptionFilters(context, ex, filters.ExceptionFilters); if (!exceptionContext.Handled) { throw; } InvokeActionResult(context, exceptionContext.Result); } return(true); }
public HtmlElementRule(HtmlElementRule parent, string name, HtmlElementOptions flags) { Precondition.Defined(name, () => Error.ArgumentNull("name")); _name = name; _options = flags; _children = new HtmlElementRuleCollection(); _attributes = new HtmlAttributeRuleCollection(); _parent = parent; }
public StaticFileResult(string path, string fileName, string contentType, Encoding contentEncoding) : base() { Precondition.Defined(path, () => Error.ArgumentNull("path")); _path = path; _contentEncoding = contentEncoding; base.ContentType = contentType; base.FileName = fileName; }