Esempio n. 1
0
 public object Resolve(Castle.MicroKernel.Context.CreationContext context,
                       ISubDependencyResolver contextHandlerResolver,
                       Castle.Core.ComponentModel model,
                       Castle.Core.DependencyModel dependency)
 {
     //resolve your connectionstring here
 }
 public bool CanResolve(
     Castle.MicroKernel.Context.CreationContext context,
     ISubDependencyResolver contextHandlerResolver,
     Castle.Core.ComponentModel model,
     Castle.Core.DependencyModel dependency)
 {
     return(dependency.TargetType == typeof(StringConfiguration));
 }
Esempio n. 3
0
 public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
 {
     if (HttpContext.Current != null && (bool)initialized.GetValue(null))
     {
         return(webRequestScopeAccessor.GetScope(context));
     }
     return(secondaryScopeAccessor.GetScope(context));
 }
Esempio n. 4
0
        protected override object CreateInstance(Castle.MicroKernel.Context.CreationContext context, Castle.Core.ConstructorCandidate constructor, object[] arguments)
        {
            var component = base.CreateInstance(context, constructor, arguments);

            AssignViewModel(component, arguments);

            return(component);
        }
Esempio n. 5
0
 public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
 {
     if (HttpContext.Current != null && PerWebRequestLifestyleModuleUtils.IsInitialized)
     {
         return(webRequestScopeAccessor.GetScope(context));
     }
     return(secondaryScopeAccessor.GetScope(context));
 }
Esempio n. 6
0
    public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
    {
        int key = GetContextKey(context);

        if (!Cache.ContainsKey(key))
        {
            Cache.Add(key, new DefaultLifetimeScope());
        }
        return(Cache[key]);
    }
Esempio n. 7
0
    private int GetContextKey(Castle.MicroKernel.Context.CreationContext context)
    {
        int hash = 0;

        foreach (var value in context.AdditionalArguments.Values)
        {
            hash = HashCode.CombineHashCode(hash, value.GetHashCode());
        }
        return(hash);
    }
        public object Resolve(
            Castle.MicroKernel.Context.CreationContext context,
            ISubDependencyResolver contextHandlerResolver,
            Castle.Core.ComponentModel model,
            Castle.Core.DependencyModel dependency)
        {
            var configuration = ConfigurationServiceClient.Instance.GetSetting(dependency.DependencyKey);

            return(new StringConfiguration()
            {
                Value = configuration,
            });
        }
Esempio n. 9
0
            public override object Create(Castle.MicroKernel.Context.CreationContext context, Burden burden)
            {
                Console.WriteLine(burden);

                //return null;
                if (Enable)
                {
                    //burden.SetRootInstance(f);
                    return(base.Create(context, burden));
                }
                else
                {
                    return(null);
                }
            }
Esempio n. 10
0
        public override object Resolve(Castle.MicroKernel.Context.CreationContext context, Castle.MicroKernel.IReleasePolicy releasePolicy)
        {
            var param = context.AdditionalArguments["model"];

            if (this._instances.Keys.Contains(param))
            {
                return(this._instances[param]);
            }

            var instanceVm = base.Resolve(context, releasePolicy);

            if (instanceVm is IDataEntityVm) // only IDataEntityVm VMs are bound per entity... other constructors are not
            {
                var instance = instanceVm as IDataEntityVm;
                this._instances.TryAdd(param, instance); //no need for concurrency check
            }
            return(instanceVm);
        }
Esempio n. 11
0
 public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
 {
     return(new DefaultLifetimeScope());
 }
Esempio n. 12
0
 public object Resolve(Castle.MicroKernel.Context.CreationContext context, ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, Castle.Core.DependencyModel dependency)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 protected override object Instantiate(Castle.MicroKernel.Context.CreationContext context)
 {
     return(context.AdditionalArguments.Contains(Key)
                ? context.AdditionalArguments[Key]
                : base.Instantiate(context));
 }
 public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
 {
     return(GetHttpModule().GetScope());
 }
Esempio n. 15
0
 public ILifetimeScope GetScope(Castle.MicroKernel.Context.CreationContext context)
 {
     return(accessors.Select(a => a.GetScope(context)).FirstOrDefault(s => s != null));
 }