reusability

How to reuse / reset an ZipInputStream?

时间秒杀一切 提交于 2019-12-10 16:12:17
问题 I want to reset the ZipInputStream (ie back to the start position) in order to read certain files in order. How do I do that? I am so stucked... ZipEntry entry; ZipInputStream input = new ZipInputStream(fileStream);//item.getInputStream()); int check =0; while(check!=2){ entry = input.getNextEntry(); if(entry.getName().toString().equals("newFile.csv")){ check =1; InputStreamReader inputStreamReader = new InputStreamReader(input); reader = new CSVReader(inputStreamReader); //read files //reset

WPF/MVVM: Re-use a ViewModel in multiple Controller and Separation of Concerns

陌路散爱 提交于 2019-12-10 12:09:49
问题 In my AdministrationController I use a PupilViewModel like: _adminRepo.GetSchoolclassPupilList().ForEach(s => { SchoolclassViewModel sVM = new SchoolclassViewModel(s, _adminRepo); foreach (PupilViewModel pVM in sVM.PupilListViewModel) { pVM.Documents.DeleteDocumentDelegate += new Action<List<Document>>(OnDeleteDocument); pVM.Documents.AddDocumentDelegate += new Action(OnAddDocument); pVM.Documents.OpenDocumentDelegate += new Action<int, string>(OnOpenDocument); } SchoolclassList.Add(sVM); });

JQuery Mobile, one footer fragment for whole site

喜夏-厌秋 提交于 2019-12-09 23:33:43
问题 I'm not asking how to get a fixed footer. I've a structure with both multi-page and single page. I'd like to know how to use only one html fragment for the whole site. I'm really looking for a solution because I'd like to edit the footer in only one place and see the modification in all pages. Thanks. EDIT: I'm developing a mobile application to be wrapped with PhoneGap, so I'm looking for client side solutions. SOLUTION (pushing together the solutions by @maco and adapting them to my case):

How do I add a reusable modal dialog in Angular?

╄→尐↘猪︶ㄣ 提交于 2019-12-09 18:18:44
问题 I'm new to Angular and attempting to implement this solution into my project. It looks painfully easy, however, I'm trying to make this into a re-usable element so that I can call it from anywhere and just pass in the content to be shown (otherwise, what's the point?). So, my specific question is: assuming I already have a controller that's bound to some DOM element and it has a feature that goes and fetches some factory driven $http call and upon the response I wish to notify the user via

How to reuse views (pages) in ASP.NET Core MVC?

。_饼干妹妹 提交于 2019-12-08 21:47:32
Before ASP.NET Core MVC, we would use RazorGenerator to compile views into assemblies, and we would reuse those views in another project, by introducing a custom ViewEngine that would load the view from the assembly instead of file-system. In ASP.NET Core MVC there is this concept of pre-compiled views and it works out of the box for version 2.0 and creates an assembly that by convention has the name of project_name.PrecompiledViews.dll . I have two problems though that I can't find an answer for on Google. First I don't know how to reuse that DLL in another project. Like if I have About

Reusing an instance of NSURLConnection

蓝咒 提交于 2019-12-08 19:51:26
问题 I'm using an instance of NSURLConnection on the iPhone to request data from a server, managed by a delegate as usual. The requests are quite frequent (maybe once every 2 minutes say) and have a common and fixed URL. Rather than seeing the good instance of NSURLConnection being released after each download and then a new one being created: Is there any worth in retaining the first connection and reusing it? (I'd hope so, one good authentication should be worth a thousand.) If so, how do I

Reusable Page_PreRender function in asp.net

耗尽温柔 提交于 2019-12-08 13:34:41
问题 I have a function which sets my linkbutton as the default button for a panel. protected void Page_PreRender(object sender, EventArgs e) { string addClickFunctionScript = @"function addClickFunction(id) { var b = document.getElementById(id); if (b && typeof(b.click) == 'undefined') b.click = function() { var result = true; if (b.onclick) result = b.onclick(); if (typeof(result) == 'undefined' || result) eval(b.getAttribute('href')); } };"; string clickScript = String.Format("addClickFunction('

Images in Imageviews are swapping after scrolling GMGridView up & down in iphone

天涯浪子 提交于 2019-12-08 11:50:11
问题 I have added UIImageView in GMGridView as I want to display the images in grid. After adding imageview in grid all works perfectly. I want to show different image in first row & first column. So I set that image after compairing with index. But when I scroll up & down , it changes the image from first column to 2nd or 3rd column. Also same image is shown in the 6th or 7th row. What going wrong in this? Here is my code - (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:

Symfony2 reusable functions in controllers

ぐ巨炮叔叔 提交于 2019-12-08 08:56:02
问题 After some time without knowing how to do this properly, and avoid duplicating code in several controllers, I searched and again to seek, but can not find a clear answer. One case in particular, need to calculate several statistics data completed of an entity. This calculation will use in 3 different controllers. In two of them, I'll show broken down into different layouts, and on the third, I will use this data to make a global calculation. business logic for each calculation, involves more

How to deal with code duplication in puppet modules?

帅比萌擦擦* 提交于 2019-12-08 03:43:46
问题 I have implemented two puppet modules to setup and configure two components - A & B. The directory structure of the modules folder looks like below: modules modulea manifests init.pp install.pp config.pp service.pp templates 1.properties.erb (This one is also needed by moduleb) 2.properties.erb (This one is also needed by moduleb) moduleb manifests init.pp install.pp config.pp service.pp templates 1.properties.erb (same as in modulea) 2.properties.erb (same as in modulea) 3.properties.erb 4