Search Results

Search found 1976 results on 80 pages for 'helper'.

Page 3/80 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Static / Shared Helper Functions vs Built-In Methods

    - by Nathan
    This is a simple question but a design consideration that I often run across in my day to day development work. Lets say that you have a class that represents some kinds of collection. Public Class ModifiedCustomerOrders Public Property Orders as List(Of ModifiedOrders) End Class Within this class you do all kinds of important work, such as combining many different information sources and, eventually, build the Modified Customer Orders. Now, you have different processes that consume this class, each of which needs a slightly different slice of the ModifiedCustomerOrders items. To enable this, you want to add filtering functionality. How do you go about this? Do you: Add Filtering calls to the ModifiedCustomerOrders class so that you can say: MyOrdersClass.RemoveCanceledOrders() Create a Static / Shared "tooling" class that allows you to call: OrdersFilters.RemoveCanceledOrders(MyOrders) Create an extension method to accomplish the same feat as #2 but with less typing: MyOrders.RemoveCanceledOrders() Create a "Service" method that handles the getting of Orders as appropriate to the calling function, while using one of the previous approaches "under the hood". OrdersService.GetOrdersForProcessA() Others? I tend to prefer the tooling / extension method approaches as they make testing a little bit simpler. Although I dependency inject all my sourcing data into the ModifiedCustomerOrders, having it as part of the class makes it a little bit more complicated to test. Typically, I choose to use extension methods where I am doing parameterless transformations / filters. As they get more complex, I will move it into a static class instead. Thoughts on this approach? How would you approach it?

    Read the article

  • Fluent MVC Route Testing Helper

    - by Nettuce
    static class GetUrlFromController<T> where T : Controller     {         public static string WithAction(Expression<Func<T, ActionResult>> expression)         {             var controllerName = typeof(T).Name.Replace("Controller", string.Empty);             var methodCall = (MethodCallExpression)expression.Body;             var actionName = methodCall.Method.Name;             var routeValueDictionary = new RouteValueDictionary();             for (var i = 0; i < methodCall.Arguments.Count; i++)             {                 routeValueDictionary.Add(methodCall.Method.GetParameters()[i].Name, methodCall.Arguments[i]);             }             var routes = new RouteCollection();             MvcApplication.RegisterRoutes(routes);             return UrlHelper.GenerateUrl(null, actionName, controllerName, routeValueDictionary, routes, ContextMocks.RequestContext, true);         }     } I'm using FluentAssertions too, so you get this: GetUrlFromController<HomeController>.WithAction(x => x.Edit(1)).Should().Be("/Home/Edit/1");

    Read the article

  • helper functions as static functions or procedural functions?

    - by fayer
    i wonder if one should create a helper function in a class as a static function or just have it declared as a procedural function? i tend to think that a static helper function is the right way to go cause then i can see what kind of helper function it is eg. Database::connect(), File::create(). what is best practice?

    Read the article

  • can't install eclipse plugin "m2e connector for build-helper-maven-plugin 0.15.0.201109290002"

    - by dermoritz
    i just tried to move from helios to maven with my gwt 2.4 application. so i began to follow the steps here: http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven but on step 3 - installing the feature "m2e connector for build-helper-maven-plugin" i get an error from Eclipse: Cannot complete the install because one or more required items could not be found. Software being installed: m2e connector for build-helper-maven-plugin 0.15.0.201109290002 (org.sonatype.m2e.buildhelper.feature.feature.group 0.15.0.201109290002) Missing requirement: m2e connector for build-helper-maven-plugin 0.15.0.201109290002 (org.sonatype.m2e.buildhelper 0.15.0.201109290002) requires 'bundle org.eclipse.m2e.jdt [1.1.0,1.2.0)' but it could not be found Cannot satisfy dependency: From: m2e connector for build-helper-maven-plugin 0.15.0.201109290002 (org.sonatype.m2e.buildhelper.feature.feature.group 0.15.0.201109290002) To: org.sonatype.m2e.buildhelper [0.15.0.201109290002] Is there a workaround for that or did I do something wrong?

    Read the article

  • Calling Html.ActionLink in a custom HTML helper

    - by Sylvain
    I am designing a custom HTML helper and I would like to execute Html.ActionLink to provide dynamic URL generation. namespace MagieMVC.Helpers { public static class HtmlHelperExtension { public static string LinkTable(this HtmlHelper helper, List<Method> items) { string result = String.Empty; foreach (Method m in items) { result += String.Format( "<label class=\"label2\">{0}</label>" + System.Web.Mvc.Html.ActionLink(...) + "<br />", m.Category.Name,m.ID, m.Name); } return result; } } } Unfortunately Html.ActionLink is not recognized in this context whatever the namespace I have tried to declare. As a generic question, I would like to know if it is possible to use any existing standard/custom Html helper method when designing a new custom helper. Thanks.

    Read the article

  • Rails: Check output of path helper from console

    - by Thor Thurn
    Rails defines a bunch of magic with named routes that make helpers for your routes. Sometimes, especially with nested routes, it can get a little confusing to keep track of what URL you'll get for a given route helper method call. Is it possible to, using the Ruby console, see what link a given helper function will generate? For example, given a named helper like post_path(post) I want to see what URL is generated.

    Read the article

  • Writing a spec for helper with Ruby on Rails and RSpec

    - by TK
    I have been writing specs for controllers and models, but I have never written a helper spec. I have no idea where I start. I have the following snippet in application_helper.rb def title(page_title) content_for(:title) { page_title } end How should I write a helper spec on the code? Also if there's any open-source Rails app to show good helper testing/specing, do let me know.

    Read the article

  • asp.net webpages content block and helper differences

    - by metanaito
    In asp.net webpages framework what is the difference between using a content block versus a helper? They both seem to be used to output HTML to multiple pages. They both can contain code and both can pass parameters. Are there other differences? When should you use a helper versus a content block? More info: With Content Blocks we create a .cshtml (for example _MakeNote.cshtml) file to hold the content we want to insert into a page. Then we use: @RenderPage("/Shared/_MakeNote.cshtml") to insert the content into a page. We can pass parameters to the content block like this: @RenderPage("/Shared/_MakeNote.cshtml", new { content = "hello from content block" }) It's somewhat like an include file, but I think does not share scope with the parent page. With Helpers we create a .cshtml page in the App_Code folder (for example MyHelpers.cshtml) and place methods in that page which we want to call. The method looks something like this: @helper MakeNote(string content) { <div>@content</div> } The helper is called by using: @MyHelpers.MakeNote("Hello from helper")

    Read the article

  • Unit test helper methods?

    - by Aly
    Hi, I have classes which prviously had massive methods so i subdivided the work of this method into 'helper' methods. These helper methods are declared private to enforce encapsulation - however I want to unit test the big public methods, is it good to unit test the helper methods too as if one of them fail the public method that calls it will also fail - but this way we can identify why it failed. Also in order to test these using a mock object I would need to change their visibility from private to protected, is this desirable?

    Read the article

  • Rails - How to connect Helper to Controller Module

    - by red eye
    I have helper: module BreadcrumbsHelper def breadcrumbs_cache_wrap(key, options, &block) ... end end And i extract part of Controller to module: module ApplicationController::Breadcrumbs def default_breadcrumbs ... end class ApplicationController include ApplicationController::Breadcrumbs ... end Now i want to connect Helper to Controller. I can do it like this: class ApplicationController include ApplicationController::Breadcrumbs helper :breadcrumbs ... end It's working. But can i incapsulate connection to Breadcrumbs Module? module ApplicationController::Breadcrumbs helper :breadcrumbs ... end Unfortunately this code is not working "undefined method `helper'".

    Read the article

  • Does IP helper forward subnet broadcasts?

    - by Eamon
    Hi, I have a device on a VLAN that uses UDP subnet broadcasts to advertise its presence to similar devices. This works fine on a single VLAN, but now I need to allow it to communicate with similar devices on a second VLAN. I thought of using the IP helper command in the router, but I am wondering if that only forwards global broadcasts (255.255.255.255)? My device sends out a subnet broadcast (e.g. 192.168.6.255) Will IP helper change the destination address to the target subnet (e.g. 192.168.7.255)? Eamon

    Read the article

  • CodeIgniter's Scaffolding and Helper Functions Not Working

    - by 01010011
    Hi, I'm following CodeIgniter's tutorial "Create a blog in 20 minutes" and I am having trouble getting the helper, anchor and Scaffolding functions to work. I can't seem to create links on my HTML page using the helper and anchor functions. I put $this->load->helper('url'); $this->load->helper('form'); in the constructor under parent::Controller(); and <p>&lt;?php anchor('blog/comments','Comments'); ?&gt;</p> within the foreach loop as specified in the tutorial. But Im not getting the links to appear. Secondly, I keep getting a 404 Page Not Found error whenever I try to access CodeIgniter's Scaffolding page in my browser, like so: localhost/codeignitor/index.php/blog/scaffolding/mysecretword I can access localhost/codeignitor/index.php/blog just fine. I followed CodeIgnitor's instructions in their "Create a blog in 20 minutes" by storing my database settings in the database.php file; and automatically connecting to the database by inserting "database" in the core array of the autoload.php; and I've added both parent::Controller(); and $this->load->scaffolding('myTableName') to blog's constructor. It still gives me this 404. Any assistance will be appreciated. Thanks in advance?

    Read the article

  • Zend framework controller action helper

    - by guptanikhilchandra
    I am getting fatal error after adding the action helper class. I am trying to load layout corresponding to called layout. Following is my code snippet: First of all i added a helper class under application/controller/helpers: class Zend_Controller_Action_Helper_Layout extends Zend_Controller_Action_Helper_Abstract { public $pluginLoader; public function __construct() { // TODO Auto-generated Constructor $this->pluginLoader = new Zend_Loader_PluginLoader (); } public function preDispatch() { $bootstrap = $this->getActionController()->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $module = $this->getRequest()->getModuleName(); if (isset($config[$module]['resources']['layout']['layout'])) { $layoutScript = $config[$module]['resources']['layout']['layout']; $this->getActionController()->getHelper('layout')->setLayout($layoutScript); } } } Then i added a loader in bootstrap.php: protected function _initLayoutHelper() { $this->bootstrap('frontController'); Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers'); $layout = Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_Layout()); } Following is my application.ini: [production] autoloaderNamespaces.tree = "Tree_" phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.helperDirectory = APPLICATION_PATH "/controllers/helpers" resources.modules[] = "" contact.resources.frontController.defaultControllerName = "index" resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" resources.layout.layout = layout admin.resources.layout.layout = admin admin.resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" resources.view[] = [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 While running this code i am getting following errors: Warning: include(Zend\Controller\Action\Helper\LayoutLoader.php) [function.include]: failed to open stream: No such file or directory in D:\personal\proj\renovate\library\Zend\Loader.php on line 83 Warning: include() [function.include]: Failed opening 'Zend\Controller\Action\Helper\LayoutLoader.php' for inclusion (include_path='D:\personal\proj\renovate\application/../library;D:\personal\proj\renovate\library;.;C:\php5\pear') in D:\personal\proj\renovate\library\Zend\Loader.php on line 83 Fatal error: Class 'Zend_Controller_Action_Helper_LayoutLoader' not found in D:\personal\proj\renovate\application\Bootstrap.php on line 33 Kindly let me know, how can i come out from this issue. I am beginner in Zend Framework. Thanks Nikhil

    Read the article

  • Windows and vmware-unity-helper

    - by user40470
    I'm running VMWare Workstation 7 and I want to use the "vmware-unity-helper.exe" utility. Does this utility work in windows? I've found several articles that say that it does not work with VM Workstation 6.5 but nothing on 7. Thanks.

    Read the article

  • Making "helper" windows in WPF

    - by RandomEngy
    I'm writing an app in WPF and want to make a "helper" window. The window needs to be resizable, with no minimize option and doesn't show in the taskbar. If the app receives focus, it should appear as well, but whether or not it's in front or behind the main window should be retained. When the main window is closed, it should close along with the app. An example is a detached pane in Visual Studio. I've made the helper windows not appear in the taskbar, but can't get the rest of the behaviors I want. If they're their own windows, they don't get focus along with the rest of the app. If I specify a the main window as their owner, the main window can't be on top of the helper window. Anyone know a good way to approach this?

    Read the article

  • Accessing the params hash for year and month rails and using in helper

    - by Matt
    So I took some php code and turned it into a calendar with a helper to make a simple calendar. I got my data from inside the helper: def calendar_maker a = Time.now b = a.month d = a.year h = Time.gm(d,b,1) #first day of month Now I want to try and do it with parameters within my method #from the helper file def calendar_maker(year, month) a = Time.now b = month c = year h = Time.gm(d,b,1) #first day of month #from my html.erb file <%= @month %> and <%= @year %> <%= params["month"] %><br /> <%= params["action"] %><br /> <%= params["year"] %><br /> <%= calendar_maker( @year, @month) %> #from controller file def calendar @month = params[:month] @year = params[:year] end Anyways mistakes were made and not finding documentation anywhere or not looking in the right place. How do I get this to work with my params hash. Thanks for the help.

    Read the article

  • Adjust Title Helper in Ruby on Rails Tutorial 3.2 to deal with & properly

    - by memoht
    I am using the title helper from the 3.2 edition of the Ruby on Rails Tutorial by Michael Hartl and just realized a snag with the & character showing up in the title as &Amp instead. The relevant snippet of code is here Official Sample App 2nd Edition The problem. I have a School model and am using the School name on the Show view as follows: <% provide(:title, @school.name) %> If my School has a & in the name, it is being replaced with &Amp in the browser title. Ryan Bates Railscasts site has a similiar title helper that solves this issue this way but it is using content_for instead of provide. Trying to adjust the Rails Tutorial helper, but having trouble getting it work properly. Works great expect for this issue.

    Read the article

  • using helper methods in a view in rails 3

    - by Frida777
    Hello everyone, there is something that is disturbing me a bit about rails 3. i am trying to upgrade my application from rails 2 to rails 3. i followed all the steps necessary to do and things were working well for me till now except one thing: i have a helper method that is defined differently in different helpers, for example it is defined in the application_helper in one way and the same method defined in a different way in the homepage_helper, and defined differently in another helper, let's say video_helper, in addition to that, it is used in a shared view that is used throughout the application, now if i am in the homepage, i want this function to get called from the homepage_helper and if i am in the video page, the function must be called from the video_helper, based on the concept of convention in rails, this worked perfectly in rails 2 but in rails 3, the function is always called from the last helper, alphabetically ordered, that is in the example, video_helper. How can i fix this? Kindly advice. Appreciate all the help.

    Read the article

  • Custom ASP.Net MVC 2 ModelMetadataProvider for using custom view model attributes

    - by SeanMcAlinden
    There are a number of ways of implementing a pattern for using custom view model attributes, the following is similar to something I’m using at work which works pretty well. The classes I’m going to create are really simple: 1. Abstract base attribute 2. Custom ModelMetadata provider which will derive from the DataAnnotationsModelMetadataProvider   Base Attribute MetadataAttribute using System; using System.Web.Mvc; namespace Mvc2Templates.Attributes {     /// <summary>     /// Base class for custom MetadataAttributes.     /// </summary>     public abstract class MetadataAttribute : Attribute     {         /// <summary>         /// Method for processing custom attribute data.         /// </summary>         /// <param name="modelMetaData">A ModelMetaData instance.</param>         public abstract void Process(ModelMetadata modelMetaData);     } } As you can see, the class simple has one method – Process. Process accepts the ModelMetaData which will allow any derived custom attributes to set properties on the model meta data and add items to its AdditionalValues collection.   Custom Model Metadata Provider For a quick explanation of the Model Metadata and how it fits in to the MVC 2 framework, it is basically a set of properties that are usually set via attributes placed above properties on a view model, for example the ReadOnly and HiddenInput attributes. When EditorForModel, DisplayForModel or any of the other EditorFor/DisplayFor methods are called, the ModelMetadata information is used to determine how to display the properties. All of the information available within the model metadata is also available through ViewData.ModelMetadata. The following class derives from the DataAnnotationsModelMetadataProvider built into the mvc 2 framework. I’ve overridden the CreateMetadata method in order to process any custom attributes that may have been placed above a property in a view model.   CustomModelMetadataProvider using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Mvc2Templates.Attributes; namespace Mvc2Templates.Providers {     public class CustomModelMetadataProvider : DataAnnotationsModelMetadataProvider     {         protected override ModelMetadata CreateMetadata(             IEnumerable<Attribute> attributes,             Type containerType,             Func<object> modelAccessor,             Type modelType,             string propertyName)         {             var modelMetadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName);               attributes.OfType<MetadataAttribute>().ToList().ForEach(x => x.Process(modelMetadata));               return modelMetadata;         }     } } As you can see, once the model metadata is created through the base method, a check for any attributes deriving from our new abstract base attribute MetadataAttribute is made, the Process method is then called on any existing custom attributes with the model meta data for the property passed in.   Hooking it up The last thing you need to do to hook it up is set the new CustomModelMetadataProvider as the current ModelMetadataProvider, this is done within the Global.asax Application_Start method. Global.asax protected void Application_Start()         {             AreaRegistration.RegisterAllAreas();               RegisterRoutes(RouteTable.Routes);               ModelMetadataProviders.Current = new CustomModelMetadataProvider();         }   In my next post, I’m going to demonstrate a cool custom attribute that turns a textbox into an ajax driven AutoComplete text box. Hope this is useful. Kind Regards, Sean McAlinden.

    Read the article

  • Purpose of Adobe PDF Link Helper

    - by user770750
    I have an idea of what this browser add-on does. Adobe PDF Browser Control (AcroPDF.dll) Apparently, if I disable this one, PDFs embedded in a page with the embed or object tag fail to function properly. So, its pretty clear as to its function. However, I can't find anywhere accurate documentation on what this add-on below does. Adobe PDF Link Helper (AcroIEHelperShim.dll) IE9 (with Reader X) seems to work flawlessly with it disabled. PDF's still open within the browser. Only if I uncheck Display PDF in Browser in Readers preferences does that cease. I played around on an XP VM with IE7 and Reader X... no isssues noticed when disabled. Does anyone know the purpose of this add-on? At one time I believed it was necissary for the 'within browser' functionality to work, though that was never verified. Something change?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >