/// <summary> /// Initializes the current /// <see cref="Radischevo.Wahha.Web.Mvc.AssemblyResourceViewEngine"/> instance /// using the specified <paramref name="settings"/>. /// </summary> /// <param name="settings">A settings list for the current instance.</param> protected override void Init(IValueSet settings) { Precondition.Require(settings, () => Error.ArgumentNull("settings")); base.Init(settings); Provider.AssemblyName = settings.GetValue <string>("assembly"); Provider.BaseNamespace = settings.GetValue <string>("baseNamespace"); Provider.VirtualPath = settings.GetValue <string>("virtualPath"); HostingEnvironment.RegisterVirtualPathProvider(Provider); }
public static IAssociationLoader <IEnumerable <TAssociation> > Multiple <TAssociation>(MetaAssociation association, IValueSet source) { // Gonna move to DbQueryGenerator MetaType otherType = Configuration.Instance.Factory.CreateMapping(typeof(TAssociation)); StringBuilder builder = new StringBuilder(); builder.Append("SELECT "); foreach (MetaMember member in otherType.Members) { builder.Append('[').Append(member.GetMemberKey()).Append("],"); } builder.Length--; builder.Append(" FROM "); if (!String.IsNullOrEmpty(otherType.Schema)) { builder.Append('[').Append(otherType.Schema).Append("]."); } builder.Append('[').Append(otherType.Table).Append("] WHERE [") .Append(association.OtherKey).Append("]=@").Append(association.OtherKey); ValueDictionary arguments = new ValueDictionary(); arguments.Add(association.OtherKey, source.GetValue <object>(association.ThisKey)); return(new MultipleMappedAssociationLoader <TAssociation>(new DbCommandDescriptor(builder.ToString(), arguments))); }
public static IAssociationLoader <TAssociation> Scalar <TAssociation>(MetaColumn column, IValueSet source) where TAssociation : class { MetaType type = column.DeclaringType; // TODO: Билдер уйдет в DbQueryGenerator. StringBuilder builder = new StringBuilder(); builder.Append("SELECT [") .Append(column.Name) .Append("] FROM "); if (!String.IsNullOrEmpty(type.Schema)) { builder.Append('[').Append(type.Schema).Append("]."); } builder.Append('[').Append(type.Table) .Append("] WHERE "); ValueDictionary arguments = new ValueDictionary(); foreach (MetaMember key in type.Keys) { string memberKey = key.GetMemberKey(); builder.Append('[').Append(memberKey).AppendFormat("] = @{0}", memberKey).Append(" AND "); arguments[memberKey] = source.GetValue <object>(memberKey); } builder.Length -= 5; return(new ScalarMappedAssociationLoader <TAssociation>( new DbCommandDescriptor(builder.ToString(), arguments), column.Binder)); }
public TValue GetValue <TValue>(string key, TValue defaultValue, IFormatProvider provider) { if (Keys.Contains(key, StringComparer.OrdinalIgnoreCase)) { return(_collection.GetValue <TValue>(key, defaultValue, provider)); } return(defaultValue); }
public static CacheProvider Create <TProvider>(IValueSet settings) where TProvider : ICacheProvider { ICacheProvider provider = ServiceLocator.Instance.GetService <TProvider>(); provider.Init(settings); return(new CacheProvider(provider, settings.GetValue <int>("timeout", _timeout, CultureInfo.InvariantCulture))); }
public TValue GetValue <TValue>(string key, TValue defaultValue, IFormatProvider provider) { string mappedKey; if (Map.TryGetValue(key, out mappedKey)) { return(_collection.GetValue <TValue>(mappedKey, defaultValue, provider)); } return(defaultValue); }
public override void SetEngineValues(EngineInputItem inputItem, IValueSet values) { //--- set input values --- if (inputItem == _InputItem) { _Inpath = (string)values.GetValue(0, 0); } else { throw new ArgumentException("Unknown Input Item Id: \"" + inputItem.Id + "\"", "inputItem"); } }
protected virtual IRouteConstraint ProcessConstraint(string type, IValueSet attributes) { if (String.IsNullOrEmpty(type)) { return(null); } switch (type.ToLowerInvariant()) { case "method": HttpMethod method = HttpMethod.None; foreach (string str in attributes.GetValue <string>("verbs", String.Empty) .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { method |= (HttpMethod)Enum.Parse(typeof(HttpMethod), str, true); } return(new HttpMethodConstraint(method)); case "regex": string parameter = attributes.GetValue <string>("parameter"); string pattern = attributes.GetValue <string>("pattern"); string options = attributes.GetValue <string>("options"); RegexOptions rx = RegexOptions.None; if (!String.IsNullOrEmpty(options)) { foreach (string str in options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { rx |= (RegexOptions)Enum.Parse(typeof(RegexOptions), str, true); } } return(new RegexConstraint(parameter, pattern, rx)); } return(null); }
public static CacheProvider Create(Type providerType, IValueSet settings) { Precondition.Require(settings, () => Error.ArgumentNull("settings")); if (!IsProvider(providerType)) { throw Error.IncompatibleCacheProviderType(providerType); } ICacheProvider provider = (ICacheProvider)ServiceLocator.Instance.GetService(providerType); provider.Init(settings); return(new CacheProvider(provider, settings.GetValue <int>("timeout", _timeout, CultureInfo.InvariantCulture))); }
/// <summary> /// Gets the typed value with the specified key. /// </summary> /// <typeparam name="TValue">The type of value.</typeparam> /// <param name="key">The key to find.</param> /// <param name="defaultValue">The default value of the variable.</param> public static TValue GetValue<TValue>(this IValueSet values, string name, TValue defaultValue) { Precondition.Require(values, () => Error.ArgumentNull("values")); return values.GetValue<TValue>(name, defaultValue, CultureInfo.CurrentCulture); }
/// <summary> /// Initializes the current /// <see cref="Radischevo.Wahha.Web.Mvc.AssemblyResourceViewEngine"/> instance /// using the specified <paramref name="settings"/>. /// </summary> /// <param name="settings">A settings list for the current instance.</param> protected override void Init(IValueSet settings) { Precondition.Require(settings, () => Error.ArgumentNull("settings")); base.Init(settings); Provider.AssemblyName = settings.GetValue<string>("assembly"); Provider.BaseNamespace = settings.GetValue<string>("baseNamespace"); Provider.VirtualPath = settings.GetValue<string>("virtualPath"); HostingEnvironment.RegisterVirtualPathProvider(Provider); }
public TValue GetValue <TValue>(string key, TValue defaultValue, IFormatProvider provider) { MarkAccessedKey(key); return(_collection.GetValue <TValue>(key, defaultValue, provider)); }
public virtual void Init(IValueSet settings) { _useCache = settings.GetValue <bool>("useCache", false); }
/// <summary> /// Gets the typed value with the specified key. /// </summary> /// <typeparam name="TValue">The type of value.</typeparam> /// <param name="key">The key to find.</param> /// <param name="provider">An <see cref="IFormatProvider" /> interface implementation that /// supplies culture-specific formatting information.</param> public static TValue GetValue<TValue>(this IValueSet values, string name, IFormatProvider provider) { Precondition.Require(values, () => Error.ArgumentNull("values")); return values.GetValue<TValue>(name, default(TValue), provider); }
protected virtual IRouteConstraint ProcessConstraint(string type, IValueSet attributes) { if (String.IsNullOrEmpty(type)) return null; switch (type.ToLowerInvariant()) { case "method": HttpMethod method = HttpMethod.None; foreach (string str in attributes.GetValue<string>("verbs", String.Empty) .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) method |= (HttpMethod)Enum.Parse(typeof(HttpMethod), str, true); return new HttpMethodConstraint(method); case "regex": string parameter = attributes.GetValue<string>("parameter"); string pattern = attributes.GetValue<string>("pattern"); string options = attributes.GetValue<string>("options"); RegexOptions rx = RegexOptions.None; if(!String.IsNullOrEmpty(options)) { foreach (string str in options.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) rx |= (RegexOptions)Enum.Parse(typeof(RegexOptions), str, true); } return new RegexConstraint(parameter, pattern, rx); } return null; }
public virtual void Init(IValueSet settings) { _useCache = settings.GetValue<bool>("useCache", false); }
public TValue GetValue <TValue>(string key, TValue defaultValue, IFormatProvider provider) { return(_collection.GetValue <TValue>(key, defaultValue, provider)); }