当前位置: 首页>>代码示例>>C#>>正文


C# IController.GetType方法代码示例

本文整理汇总了C#中IController.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IController.GetType方法的具体用法?C# IController.GetType怎么用?C# IController.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IController的用法示例。


在下文中一共展示了IController.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Release

        public void Release(IController controller)
        {
            var types = controller.GetType()
                .GetInterfaces()
                .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IController<,>))
                .Select(i => i.GetGenericArguments())
                .First();

            var controllerAccessor = Kernel.Resolve(
                typeof(ControllerAccessor<,>)
                    .MakeGenericType(
                        types.ElementAt(0),
                        types.ElementAt(1)
                    )
            ) as IControllerAccessor;

            var viewAccessor = Kernel.Resolve(
                typeof(ViewAccessor<>)
                    .MakeGenericType(
                        types.ElementAt(1)
                    )
            ) as IViewAccessor;

            if (controllerAccessor != null && viewAccessor != null)
            {
                var view = controllerAccessor.GetView(controller);
                var viewModel = controllerAccessor.GetViewModel(controller);

                Kernel.ReleaseComponent(view);
                Kernel.ReleaseComponent(viewModel);
            }

            Kernel.ReleaseComponent(controller);
        }
开发者ID:mmorton,项目名称:Flux,代码行数:34,代码来源:MicroKernelControllerLifecycleManager.cs

示例2: ReleaseController

 /// <summary>
 /// Releases the specified controller.
 /// </summary>
 /// <param name="controller">The controller to release.</param>
 public override void ReleaseController(IController controller)
 {
     if (this.IsFromCurrentAssembly(controller.GetType()))
     {
         this.kernel.ReleaseComponent(controller);
     }
     else
     {
         base.ReleaseController(controller);
     }
 }
开发者ID:Brad-Christie,项目名称:sccs-demo,代码行数:15,代码来源:WindsorControllerFactory.cs

示例3: FindResourceStringClassType

        private static Type FindResourceStringClassType(IController controller)
        {
            LocalizationAttribute rcdAttribute = Attribute.GetCustomAttribute(controller.GetType(), typeof(LocalizationAttribute)) as LocalizationAttribute;

            if (rcdAttribute != null)
            {
                return rcdAttribute.ResourceClass;
            }
            else
            {
                return typeof(Labels);
            }
        }
开发者ID:vkoppaka,项目名称:feather,代码行数:13,代码来源:LocalizationHelpers.cs

示例4: ReleaseController

        public void ReleaseController(IController controller)
        {
            //get spring context
            IApplicationContext ctx = ContextRegistry.GetContext();
            if (!ctx.ContainsObject(controller.GetType().Name))
            {
                if (defalutf == null)
                {
                    defalutf = new DefaultControllerFactory();
                }

                defalutf.ReleaseController(controller);
            }
        }
开发者ID:mzh3511,项目名称:CloverTraining,代码行数:14,代码来源:SpringControllerFactory.cs

示例5: FormatLogText

 private static string FormatLogText(
     IController controller, 
     string actionName, 
     string parameterName, 
     Type parameterType)
 {
     return
         string.Format(
             LocalizedTexts.InvalidArgumentOnControllerMethodogTextTemplate,
             parameterName,
             parameterType.Name,
             actionName,
             controller.GetType().Name
         );
 }
开发者ID:TiagoJSM,项目名称:Storytime,代码行数:15,代码来源:InvalidArgumentOnControllerMethodException.cs

示例6: InjectService

 /// <summary>
 /// サービスの依存性を注入
 /// </summary>
 /// <param name="controller"></param>
 private void InjectService(IController controller)
 {
     var controllerType = controller.GetType();
     var fields = controllerType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     foreach (var field in fields)
     {
         // 依存性注入対象の属性取得
         var implAttr = field.GetCustomAttributes(typeof(ImplementAttribute), true);
         if (implAttr != null && implAttr.Length > 0)
         {
             var attr = implAttr[0] as ImplementAttribute;
             if (attr.Debug == false || attr.DebugImplementType == null)
             {
                 // 本番環境用インスタンスの生成
                 var impleInstance = Activator.CreateInstance(attr.ImplementType);
                 field.SetValue(controller, impleInstance);
                 if (log.IsInfoEnabled)
                 {
                     log.Info("Staging instance is created.");
                     if (log.IsDebugEnabled)
                     {
                         log.Debug("Create instance type is " + impleInstance.GetType().Name);
                     }
                 }
             }
             else
             {
                 // デバッグ環境用インスタンスの生成
                 var debugInstance = Activator.CreateInstance(attr.DebugImplementType);
                 field.SetValue(controller, debugInstance);
                 if (log.IsInfoEnabled)
                 {
                     log.Info("Debug instance is created.");
                     if (log.IsDebugEnabled)
                     {
                         log.Debug("Create instance type is " + debugInstance.GetType().Name);
                     }
                 }
             }
         }
     }
 }
开发者ID:KuriharaJun,项目名称:MvcDI,代码行数:46,代码来源:MvcDIControllerFactory.cs

示例7: RegisterController

        /// <summary>
        /// 必须注册Controller
        /// </summary>
        /// <param name="controller">Controller实例</param>
        public void RegisterController(IController controller)
        {
            if (controller != null)
            {
                Type tp = controller.GetType();
                if (tp != null && !Controllers.ContainsKey(tp.FullName) && tp.Name.EndsWith("Controller"))
                {
                    Controllers.Add(tp.FullName, tp);

                    //Add Action
                    MethodInfo[] allMethods = tp.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public);
                    MethodInfo[] actionMethods = Array.FindAll(allMethods, IsValidActionMethod);
                    if (actionMethods != null && actionMethods.Length > 0)
                    {
                        foreach (var m in actionMethods)
                        {
                            string mname = m.Name.ToLower();
                            if (!Action.ContainsKey(mname))
                            {
                                Action.Add(mname, new List<string>());
                            }
                            if (!Action[mname].Contains(tp.FullName))
                            {
                                Action[mname].Add(tp.FullName);
                            }

                            string val = tp.FullName + "." + mname;
                            var nm = Helper.GetNameDesc(m);
                            if (!ActionList.ContainsKey(val))
                            {
                                ActionList.Add(val, nm == null ? new NameDesc(val) : nm);
                            }
                        }
                    }
                }
            }
        }
开发者ID:oysterouy,项目名称:oyster.core,代码行数:41,代码来源:MvcApplication.cs

示例8: FindFolder

        private static Tuple<string, DirectoryInfo> FindFolder(HttpContext context, IController feature, string featureFolder)
        {
            var featureName = Feature.Configuration.Current.NamingConvention(feature.GetType())
                .Value
                .Replace("Controller", "");

            var folderName = featureFolder + "/" + featureName;
            var basePath = new DirectoryInfo(context.Server.MapPath(folderName));

            if (!basePath.Exists)
            {
                var area = GetAreaNameAndNamespace(RouteTable.Routes)
                    .SingleOrDefault(x => feature.GetType().Namespace.StartsWith(x.Item2));

                if (area != null)
                {
                    folderName = "~/Areas/" + area.Item1 + "/Features/" + featureName;
                    basePath = new DirectoryInfo(context.Server.MapPath(folderName));
                }

            }

            return Tuple.Create(folderName, basePath);
        }
开发者ID:Nagelfar,项目名称:FeatureController,代码行数:24,代码来源:FeatureBundles.cs

示例9: SelectActionMethod

		/// <summary>
		/// Selects the action method.
		/// </summary>
		/// <param name="controller">The controller.</param>
		/// <param name="context">The context.</param>
		/// <param name="name">The name.</param>
		/// <param name="actionType">The action type</param>
		/// <returns></returns>
		protected virtual MethodInfo SelectActionMethod(IController controller, IControllerContext context, string name,
		                                                ActionType actionType)
		{
			object action = context.ControllerDescriptor.Actions[name];

			if (actionType == ActionType.Sync)
			{
				MethodInfo methodInfo = action as MethodInfo;

				if (methodInfo != null)
				{
					return methodInfo;
				}

				return controller.GetType().GetMethod(name,
				                                      BindingFlags.Public | BindingFlags.Instance |
				                                      BindingFlags.IgnoreCase);
			}

			AsyncActionPair actionPair = (AsyncActionPair) action;
			
			if (actionPair == null)
			{
				return null;
			}
			
			return actionType == ActionType.AsyncBegin ? actionPair.BeginActionInfo : actionPair.EndActionInfo;
		}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:36,代码来源:DefaultActionSelector.cs

示例10: Match

 public virtual bool Match(IController controller){
     return controller.GetType() == ControllerType;
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:3,代码来源:DynamicActionHandler.cs

示例11: Release

		/// <summary>
		/// Implementors should perform their logic
		/// to release the <see cref="IController"/> instance
		/// and its resources.
		/// </summary>
		/// <param name="controller"></param>
		public virtual void Release(IController controller)
		{
			if (logger.IsDebugEnabled)
			{
				logger.Debug("Controller released: " + controller.GetType());
			}

			controller.Dispose();
		}
开发者ID:candland,项目名称:Castle.MonoRail,代码行数:15,代码来源:AbstractControllerFactory.cs

示例12: getActionMethod

 /// <summary>
 /// Gets the action method.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="controllerContext">The controller context.</param>
 /// <returns></returns>
 /// <remarks></remarks>
 private MethodInfo getActionMethod(IController controller, IControllerContext controllerContext) {
     //NOTE: метод представленный здесь - быстрый но не охватывает всех случаев, например асинхронных и проч, но охватывает основной и как мне кажется нормальный паттерн
     var action = controller.GetType().GetMethod(controllerContext.Action,
                                                 BindingFlags.Instance | BindingFlags.InvokeMethod |
                                                 BindingFlags.Public | BindingFlags.IgnoreCase);
     return action; //null is not error - it means that controller or action is untipical
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:14,代码来源:AuthorizeFilter.cs

示例13: getroles

 /// <summary>
 /// Getroleses the specified controller.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="controllerContext">The controller context.</param>
 /// <returns></returns>
 /// <remarks></remarks>
 private IEnumerable<string> getroles(IController controller, IControllerContext controllerContext) {
     RoleAttribute rolesattribute = null;
     //сначала ищем роли у действия (более глубокий уровень)
     var actionmethod = getActionMethod(controller, controllerContext);
     if (null != actionmethod) {
         rolesattribute =
             actionmethod.GetCustomAttributes(typeof (RoleAttribute), true).OfType<RoleAttribute>().
                 FirstOrDefault();
     }
     // если у действия нет атрибута, ищем у всего контроллера
     if (null == rolesattribute) {
         rolesattribute =
             controller.GetType().GetCustomAttributes(typeof(RoleAttribute), true).OfType<RoleAttribute>().FirstOrDefault();
     }
     //если атрибут найдейн - вернуть список ролей из атрибута
     if(null != rolesattribute) {
         return rolesattribute.Role.split();
     }
     //иначе вернуть пустой список, нет сопоставления ролей
     return new string[]{};
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:28,代码来源:AuthorizeFilter.cs

示例14: GetResponsiveMethods

 /// <summary>
 /// Pick up all methods marked with the ResponsiveAttribute
 /// </summary>
 /// <param name="trType"></param>
 /// <param name="controller"></param>
 /// <returns></returns>
 private List<System.Reflection.MethodInfo> GetResponsiveMethods(ResponsiveEnum trType, IController controller)
 {
     List<MethodInfo> responsiveMethods = new List<MethodInfo>();
     MethodInfo[] methods = controller.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
     foreach(MethodInfo method in methods)
     {
         object[] attributes = method.GetCustomAttributes(typeof(ResponsiveAttribute), true);
         if (attributes.Length != 0)
         {
             ResponsiveAttribute att = (ResponsiveAttribute)attributes[0];
             if (att.RespType == trType)
             {
                 // TODO: Search within method code calls to OnAbortRemoteCall, OnRemoteException, StopTransfer: Cecil?
                 responsiveMethods.Add(method);
             }
         }
     }
     return responsiveMethods;
 }
开发者ID:BackupTheBerlios,项目名称:boxerp-svn,代码行数:25,代码来源:AbstractResponsiveHelper.cs

示例15: GetPageActionId

 private static ProjectBActions GetPageActionId(string key, IController controller, string actionName)
 {
     var value = ProjectBActions.Undefined;
     var methodInfo = controller.GetType()
             .GetMethods()
             .FirstOrDefault(m => m.Name.Equals(actionName, StringComparison.InvariantCultureIgnoreCase));
     if (methodInfo != null) {
         var previousAttribute = methodInfo.GetCustomAttribute(typeof (ActionLogAttribute)) as ActionLogAttribute;
         if (previousAttribute != null) {
             value = previousAttribute.ActionToLog;
         }
     }
     _cachePreviousPageActionIds[key] = value;
     return value;
 }
开发者ID:dnmsk,项目名称:rProject,代码行数:15,代码来源:ActionLogAttribute.cs


注:本文中的IController.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。