Example #1
0
        public static MvcHtmlString GenerateCanonicalUrls(this HtmlHelper html, string part = "")
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            html.AppendCanonicalUrlParts(part);
            return(MvcHtmlString.Create(pageHeadBuilder.GenerateCanonicalUrls()));
        }
Example #2
0
        public static MvcHtmlString GenerateMetaKeywords(this HtmlHelper html, string part = "")
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            html.AppendMetaKeywordParts(part);
            return(MvcHtmlString.Create(html.Encode(pageHeadBuilder.GenerateMetaKeywords())));
        }
Example #3
0
        /// <summary>
        /// 重写拦截层
        /// </summary>
        /// <param name="actionContext"></param>
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            IUnityContainer           unityContainer           = new IocHelper("AuthorizationApi").GetUnityContainer();
            IAuthorizationApplication authorizationApplication = unityContainer.Resolve <IAuthorizationApplication>();

            bool flag        = authorizationApplication.DoAuthorization(actionContext);
            var  resultModel = authorizationApplication.TokenResult;

            if (flag)
            {
                IsAuthorized(actionContext);
                return;
            }
            ResponseBaseViewModel <string> responseView = new ResponseBaseViewModel <string>();

            responseView.Flag = new ResponseCodeViewModel()
            {
                Code        = (int)resultModel.Code,
                Message     = "",
                MojoryToken = resultModel.Token
            };

            actionContext.Response = new HttpResponseMessage
            {
                Content = new StringContent(Json.Encode(responseView), Encoding.UTF8, "application/json")
            };
        }
Example #4
0
        protected virtual void LoadFrom(string physicalPath, Func <IList <string>, bool> funcHasRole = null)
        {
            var    webHelper = IocHelper.Resolve <IWebHelper>();
            string filePath  = webHelper.MapPath(physicalPath);
            var    context   = IocHelper.Resolve <HttpContextBase>();
            string content   = File.ReadAllText(filePath);

            if (!string.IsNullOrEmpty(content))
            {
                using (var sr = new StringReader(content))
                {
                    using (var xr = XmlReader.Create(sr,
                                                     new XmlReaderSettings
                    {
                        CloseInput = true,
                        IgnoreWhitespace = true,
                        IgnoreComments = true,
                        IgnoreProcessingInstructions = true
                    }))
                    {
                        var doc = new XmlDocument();
                        doc.Load(xr);

                        if ((doc.DocumentElement != null) && doc.HasChildNodes)
                        {
                            XmlNode xmlRootNode = doc.DocumentElement.FirstChild;
                            Iterate(RootNode, xmlRootNode, funcHasRole);
                        }
                    }
                }
            }
        }
Example #5
0
        protected void SetEntityCreation(IEntityCreation entity)
        {
            //The IAppSession should be registered for web and service app on the startup
            var appSession = IocHelper.Resolve <IAppSession>();

            entity.CreationDate   = DateTime.Now;
            entity.CreationUserId = appSession.CurrentUserId;
        }
Example #6
0
 public AbpNHibernateInterceptor()
 {
     _abpSession =
         new Lazy <IAbpSession>(
             () => IocManager.Instance.IocContainer.Kernel.HasComponent(typeof(IAbpSession))
                 ? IocHelper.Resolve <IAbpSession>()
                 : NullAbpSession.Instance
             );
 }
Example #7
0
        public static MvcHtmlString GenerateTitle(this HtmlHelper html, bool addDefaultTitle, string part = "")
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            if (!string.IsNullOrEmpty(part))
            {
                pageHeadBuilder.AddTitleParts(part);
            }
            return(MvcHtmlString.Create(html.Encode(pageHeadBuilder.GenerateTitle(addDefaultTitle))));
        }
Example #8
0
        public virtual string GenerateTitle(bool addDefaultTitle)
        {
            var specificTitle = string.Join(PageTitleSeparator, _titleParts.AsEnumerable().Reverse().ToArray());

            if (addDefaultTitle && string.IsNullOrWhiteSpace(specificTitle))
            {
                return(IocHelper.Resolve <IResourceService>().GetResourceString("home"));
            }
            return(specificTitle);
        }
Example #9
0
        static void Main(string[] args)
        {
            IocHelper.Register <ClassA, IClassA>();
            //IocHelper.Register(new ClassB());

            IocHelper.RegisterAssembly(Assembly.GetExecutingAssembly());

            IClassA ca = IocHelper.Resolve <IClassA>();
            ClassB  cb = IocHelper.Resolve <ClassB>();
        }
        public ConfigReaderTest()
        {
            Arguments prms = new Arguments();

            prms.Add("applicationName", "SERVICE - A");
            prms.Add("refreshTimerIntervalInMs", 10000);
            prms.Add("connectionString", "Deneme");

            _configurationReader = IocHelper.Resolve <IConfigurationReader>(prms);
        }
Example #11
0
        internal TDbContext GetOrCreateDbContext <TDbContext>() where TDbContext : DbContext
        {
            DbContext dbContext;

            if (!_activeDbContexts.TryGetValue(typeof(TDbContext), out dbContext))
            {
                _activeDbContexts[typeof(TDbContext)] = dbContext = IocHelper.Resolve <TDbContext>();
            }

            return((TDbContext)dbContext);
        }
Example #12
0
 public static IAttachmentHandler GetAttachmentHandler()
 {
     if (IocHelper.IsRegistered(typeof(IAttachmentHandler)))
     {
         var hander = IocHelper.Resolve <IAttachmentHandler>();
         return(hander);
     }
     else
     {
         return(new DefaultAttachmentHandler());
     }
 }
Example #13
0
        public virtual ActionResult Social()
        {
            var socialSetting = IocHelper.Resolve <SocialSetting>();
            var model         = new SocialModel()
            {
                FacebookLink   = socialSetting.FacebookLink,
                GooglePlusLink = socialSetting.GooglePlusLink,
                TwitterLink    = socialSetting.TwitterLink,
                YoutubeLink    = socialSetting.YoutubeLink
            };

            return(PartialView(model));
        }
Example #14
0
        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DtoMapper.Map();
            InitializeIocContainer.Initialize();
            var permissionManager = IocHelper.Resolve <IPermissionManager>();

            permissionManager.Initialize();
        }
Example #15
0
        static void Main(string[] args)
        {
            Arguments prms = new Arguments();

            prms.Add("applicationName", "SERVICE - A");
            prms.Add("refreshTimerIntervalInMs", 10000);
            prms.Add("connectionString", "Deneme");

            IConfigurationReader configurationReader = IocHelper.Resolve <IConfigurationReader>(prms);


            var val = configurationReader.GetValue <int>("MaxItemCount");

            Console.ReadKey();
        }
        public IActionResult Config()
        {
            Arguments prms = new Arguments();

            prms.Add("applicationName", "SERVICE - A");
            prms.Add("refreshTimerIntervalInMs", 10000);
            prms.Add("connectionString", "Deneme");

            IConfigurationReader configurationReader = IocHelper.Resolve <IConfigurationReader>(prms);

            ConfigModel model = new ConfigModel();

            model.Configs = IocHelper.Resolve <IConfigProvider>().GetByApplication("SERVICE - A");

            return(View(model));
        }
Example #17
0
        public ResponseBaseViewModel <string> MojoryLoginOut()
        {
            string          token          = this.GetToken();
            IUnityContainer unityContainer = new IocHelper("MojoryLoginOutApi").GetUnityContainer();
            ICustomerLoginOutApplication customerLoginOutApplication = unityContainer.Resolve <ICustomerLoginOutApplication>();

            customerLoginOutApplication.MojoryLoginOut(token);
            ResponseBaseViewModel <string> v = new ResponseBaseViewModel <string>
            {
                Flag = new ResponseCodeViewModel()
                {
                    Code = 0, Message = "success", MojoryToken = ""
                }
            };

            return(v);
        }
Example #18
0
 public override void OnAuthorization(HttpActionContext actionContext)
 {
     base.OnAuthorization(actionContext);
     if (Permissions != null)
     {
         if (_permissionCheckerManager == null)
         {
             _permissionCheckerManager = IocHelper.Resolve <IPermissionCheckerManager>();
         }
         foreach (var permission in Permissions)
         {
             if (!_permissionCheckerManager.IsGranted(permission))
             {
                 throw new UnAuthorizationException("You don't have sufficient rights for this permission. PermissionName : " + permission);
             }
         }
     }
 }
Example #19
0
 static LogHelper()
 {
     Logger = IocHelper.Resolve <ILogger>();
 }
Example #20
0
        public static void AddHeadCustomParts(this HtmlHelper html, string part)
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            pageHeadBuilder.AddHeadCustomParts(part);
        }
Example #21
0
 /// <summary>
 /// Initializes the system.
 /// </summary>
 public virtual void Initialize()
 {
     IocManager.Instance.IocContainer.Install(FromAssembly.This());
     _applicationManager = IocHelper.Resolve <AbpApplicationManager>();
     _applicationManager.Initialize();
 }
Example #22
0
        public static MvcHtmlString GenerateHeadCustom(this HtmlHelper html)
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            return(MvcHtmlString.Create(pageHeadBuilder.GenerateHeadCustom()));
        }
Example #23
0
 static SettingHelper()
 {
     SettingManager = IocHelper.Resolve <ISettingManager>();
 }
Example #24
0
        public static void AppendMetaKeywordParts(this HtmlHelper html, string part)
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            pageHeadBuilder.AppendMetaKeywordParts(part);
        }
Example #25
0
        public static void AddMetaDescriptionParts(this HtmlHelper html, string part)
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            pageHeadBuilder.AddMetaDescriptionParts(part);
        }
Example #26
0
        public static void AppendCanonicalUrlParts(this HtmlHelper html, string part)
        {
            var pageHeadBuilder = IocHelper.Resolve <IPageHeadBuilder>();

            pageHeadBuilder.AppendCanonicalUrlParts(part);
        }
Example #27
0
 public BaseApiController()
 {
     _appSession = IocHelper.Resolve <IAppSession>();
 }
Example #28
0
 /// <summary>
 /// Registers a localization source.
 /// </summary>
 /// <typeparam name="T">Type of the localization source.</typeparam>
 public static void RegisterSource <T>() where T : ILocalizationSource
 {
     LocalizationSourceManager.RegisterSource(IocHelper.Resolve <T>());
 }
Example #29
0
 static LocalizationHelper()
 {
     LocalizationSourceManager = IocHelper.Resolve <ILocalizationSourceManager>();
 }
Example #30
0
 static LogHelper()
 {
     Logger = IocManager.Instance.IocContainer.Kernel.HasComponent(typeof(ILogger))
         ? IocHelper.Resolve <ILogger>()
         : NullLogger.Instance;
 }