Daily Archives

Articles indexed Saturday May 29 2010

Page 26/76 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Single Responsibility Principle usage how can i call sub method correctly?

    - by Phsika
    i try to learn SOLID prencibles. i writed two type of code style. which one is : 1)Single Responsibility Principle_2.cs : if you look main program all instance generated from interface 1)Single Responsibility Principle_3.cs : if you look main program all instance genareted from normal class My question: which one is correct usage? which one can i prefer? namespace Single_Responsibility_Principle_2 { class Program { static void Main(string[] args) { IReportManager raporcu = new ReportManager(); IReport wordraporu = new WordRaporu(); raporcu.RaporHazirla(wordraporu, "data"); Console.ReadKey(); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } } Second 0ne all instance genareted from normal class namespace Single_Responsibility_Principle_3 { class Program { static void Main(string[] args) { WordRaporu word = new WordRaporu(); ReportManager manager = new ReportManager(); manager.RaporHazirla(word,"test"); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } }

    Read the article

  • drawRect is not executing

    - by coure06
    I have ClockViewController.h and ClockViewController.m inherited from UIViewController. Also 2 other files ClockView.h and ClockView.m inherited from UIView. In Interface builder i have selected Class "ClockView" for the clock, but my drawRect is not executing. I am calling it via setNeedsDisplay from a timer function. even the timer function is not calling.

    Read the article

  • How to convert WinXP + Apps on RAID0 to use just one of the two RAID disks?

    - by chris5gd
    I have two 150GB SATA drives in hardware RAID 0, on which I have my C: (Win XP) and D: (installed apps). I'm migrating to Windows 7, but I want to keep my XP system until I've got it all running smoothly. So I want to: break the RAID move C: and D: to one of the drives (there's enough room) use the other drive for Win 7 boot into one or the other Clearly I can't move C: and D: after breaking the RAID, so I'm assuming I need to image the two partitions first, then break the RAID and restore the images to one of the drives. So my questions are: Is this possible? If so, what would be a good (free) imaging/restore tool? How do I ensure that the drive will boot after restoring the images? What sort of gotchas should I look out for? If there's a better solution than this, I'd be grateful for suggestions. Thanks!

    Read the article

  • How do I implement repository pattern and unit of work when dealing with multiple data stores?

    - by Jason
    I have a unique situation where I am building a DDD based system that needs to access both Active Directory and a SQL database as persistence. Initially this wasnt a problem because our design was setup where we had a unit of work that looked like this: public interface IUnitOfWork { void BeginTransaction() void Commit() } and our repositories looked like this: public interface IRepository<T> { T GetByID() void Save(T entity) void Delete(T entity) } In this setup our load and save would handle the mapping between both data stores because we wrote it ourselves. The unit of work would handle transactions and would contain the Linq To SQL data context that the repositories would use for persistence. The active directory part was handled by a domain service implemented in infrastructure and consumed by the repositories in each Save() method. Save() was responsible with interacting with the data context to do all the database operations. Now we are trying to adapt it to entity framework and take advantage of POCO. Ideally we would not need the Save() method because the domain objects are being tracked by the object context and we would just need to add a Save() method on the unit of work to have the object context save the changes, and a way to register new objects with the context. The new proposed design looks more like this: public interface IUnitOfWork { void BeginTransaction() void Save() void Commit() } public interface IRepository<T> { T GetByID() void Add(T entity) void Delete(T entity) } This solves the data access problem with entity framework, but does not solve the problem with our active directory integration. Before, it was in the Save() method on the repository, but now it has no home. The unit of work knows nothing other than the entity framework data context. Where should this logic go? I argue this design only works if you only have one data store using entity framework. Any ideas how to best approach this issue? Where should I put this logic?

    Read the article

  • C Builder TForm not allocated or created properly all its controls

    - by ergey
    Hi, I would know how i can check that all the controls on the form is created and initialized. I have form i am showing when user presses the 'update' button. It have only TProgressBar control. The handle is not NULL for this control and at random stages it can or can't set the Position/Max values. When i set TProgressBar-Max value to some integer it remains 0 after. So the question is: 1) How to really create the form and all controls on it (i am currently using just Form-Show() method, which as i can check calls the constructor) 2) How to check that all controls on the form is created and PAINTED (showed) Thanks

    Read the article

  • Const parameter at constructor causes stackoverflow

    - by Luca
    I've found this strange behavior with VS2005 C++ compiler. Here is the situation: I cannot publish the code, but situation is very simple. Here is initial code: it work perfectly class Foo { public: Foo(Bar &bar) { ... } } The constructor implementation stores a reference, setup some members... indeed nothing special. If I change the code in the following way: class Foo { public: Foo(const Bar &bar) { ... } } I've added a const qualifier to the only constructor routine parameter. It compiles correctly, but the compiler outputs a warning saying that the routine Foo::Foo will cause a stackoverflow (even if the execution path doesn't construct any object Foo); effectively this happens. So, why the code without the const parameter works perfectly, while the one with the const qualifier causes a stackoverflow? What can cause this strange behavior?

    Read the article

  • round() for float in C++

    - by Roddy
    I need a simple floating point rounding function, thus: double round(double); round(0.1) = 0 round(-0.1) = 0 round(-0.9) = -1 I can find ceil() and floor() in the math.h - but not round(). Is it present in the standard C++ library under another name, or is it missing??

    Read the article

  • Pylons and Pisa (xhtml2pdf): blank page in IE

    - by Utaal
    I'm using pylons to serve a dynamically generated pdf document for reporting: my approach works in firefox & chrome (it displays the pdf inline if the plugin is available or otherwise downloads it) but IE (7 & 8) only show a blank page and doesn't prompt for download. IE correctly shows PDFs generated by other websites, though. Don't know if it matters but the page is accessed through HTTPS. My controller does the following: renders the source page through mako converts the html to pdf using pisa adds these headers to the response: Content-type: application/pdf and Content-disposition: inline; filename=file.pdf Do you have any suggestion? I seem to be stuck and cannot think of anything else to try.

    Read the article

  • Working with .tlb files

    - by aF
    Hello, I've created a c# com interop dll project that generates both .dll and .tlb files. When I use them on the computer that I built everythig, all works fine. But when I pass it to another computer (with the same windows installed), it doesn't work. I allready made the: Regasm.exe SoundLogDLL.dll /tlb:SoundLogDLL.tlb command, but still doesn't work. I also done the work in all computers in vs2008 before releasing it! Is there anything else that I have to do?

    Read the article

  • Off the shelf Php User Forum

    - by dta
    I have a pre-existing user database on my site. Now, I want to install a PHP-Based Forum on my site which works with already existing user table. Also, I would like it to be as lightweight as possible -- in terms of features as well as bandwidth consumption Please suggest some.. Thanks.

    Read the article

  • iPhone SDK:How do you play video inside a view? Rather than fullscreen.

    - by Jessica
    Hi, I am trying to play video inside a UIView, so my first step was to add a class for that view and start playing a movie in it using this code: - (IBAction)movie:(id)sender{ NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"]; NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; theMovie.scalingMode = MPMovieScalingModeAspectFill; [theMovie play]; } But this just crashes the app when using this method inside it's own class, but is fine elsewhere. Does anyone know how to play video inside a view? and avoid it being full screen?

    Read the article

  • tryin' to enumerate all available Wifi network with J2SE

    - by Rob
    Hi, I'd like to find out a way to enumerate all available wifi networks using Java 6.0 and any third-party API. Unfortunately, I'm not able to find a solution to this problem, all I got is a library that I can't use because I don't have any example. I'll be very pleased if someone could help me. The target platform is Win XP/7. Edit: the library I found is named jwlanscan Rob

    Read the article

  • Apache2 several sites and configuration question

    - by Hellnar
    Hello I want to host several sites from my VPS via apache2 under Debian. For this I removed the default from sites-enabled and added this under /etc/apache/sites-enabled/www.mysite.com : NameVirtualHost *:80 <VirtualHost *:80> ServerName mysite.com ServerAlias www.mysite.com Alias /media/ /home/myuser/mysite/media/ Alias /admin_media/ /home/myuser/django/Django-1.2/django/contrib/admin/media/ WSGIScriptAlias / /home/myuser/mysite/wsgi.py ErrorLog /home/myuser/mysite/logs/error.log CustomLog /home/myuser/mysite/logs/access.log combined </VirtualHost> After that I removed the default symbolic link from sites-enabled/ via: a2dissite default and added the new one: a2ensite www.mysite.com Still, I get this error: Restarting web server: apache2apache2: apr_sockaddr_info_get() failed for myuser apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [Sat May 29 11:41:13 2010] [warn] NameVirtualHost *:80 has no VirtualHosts apache2: apr_sockaddr_info_get() failed for myuser apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [Sat May 29 11:41:13 2010] [warn] NameVirtualHost *:80 has no VirtualHosts . What can be the problem ?

    Read the article

  • postgresql weighted average?

    - by milovanderlinden
    say I have a postgresql table with the following values: id | value ---------- 1 | 4 2 | 8 3 | 100 4 | 5 5 | 7 If I use postgresql to calculate the average, it gives me an average of 24.8 because the high value of 100 has great impact on the calculation. While in fact I would like to find an average somewhere around 6 and eliminate the extreme(s). I am looking for a way to eliminate extremes and want to do this "statistically correct". The extreme's cannot be fixed. I cannot say; If a value is over X, it has to be eliminated. I have been bending my head on the postgresql aggregate functions but cannot put my finger on what is right for me to use. Any suggestions?

    Read the article

  • search algorithm using sentinel

    - by davit-datuashvili
    i am trying to do search algorithm using sentinel which reduce time to 3.87n nanoseconds for example compare to this code int search (int t ){ for (int i=0;i<n;i++) if (x[i]==t) return i; return -1; } it takes 4.06 nanoseconds so i am trying to optimize it here is code public class Search{ public static int search(int a[],int t){ int i; int p=0; int n=a.length; int hold; hold=a[n-1]; a[n-1]=t; for ( i=0;;i++) if (a[i]==t) break; a[n-1]=t; if (i==n){ p= -1; } else{ p= i; } return p; } public static void main(String[]args){ int t=-1; int a[]=new int[]{4,5,2,6,8,7,9}; System.out.println(search(a,t)); } } but is show me that 9 is at position 6 which is correct but if t =1 or something else which is not array it show me position 6 too please help

    Read the article

  • Best way to send mass email to my subscribers ( BCC or PEAR mail queue ? )

    - by xRobot
    I need to send email to my 5000 subscribers. What is the best way to do this ? 1) By using BCC ?: $from_addr = '[email protected]'; $mailing_list = '[email protected]', '[email protected]', '[email protected]; $message_subject = 'this is a test'; `$headers = array ("From" => $from_addr, "Bcc" => $mailing_list, "Subject" => $message_subject); $smtp = Mail::factory("smtp", array ('host' => "smtp.example.com", 'auth' => true, 'username' => "xxx", 'password' => "xxx")); $mail = $smtp->send($email, $headers, $message_body);` . 2) by using PEAR mail queue ?

    Read the article

  • UAC on Win2k8/VIsta x64 - local "Administrator" works but domain account in Administrators group fai

    - by deltanine
    I have come across a strange problem in one of our applications on win2k8/Vista x64 with UAC enabled. It is a process which hosts the UI for our service and runs in the context of the logged on user. When logged in as a domain user who is a member of the "Administrators" group, writing to the registry under HKLM fails due to UAC with access denied. But when logged in as the local "Administrator" account (non-domain) then writing to the registry succeeds. Both accounts are adminstrators - is there a distinction between domain and non-domain accounts with UAC? What gives?

    Read the article

  • parallelizing code using openmp

    - by anubhav
    Hi, The function below contains nested for loops. There are 3 of them. I have given the whole function below for easy understanding. I want to parallelize the code in the innermost for loop as it takes maximum CPU time. Then i can think about outer 2 for loops. I can see dependencies and internal inline functions in the innermost for loop . Can the innermost for loop be rewritten to enable parallelization using openmp pragmas. Please tell how. I am writing just the loop which i am interested in first and then the full function where this loop exists for referance. Interested in parallelizing the loop mentioned below. //* LOOP WHICH I WANT TO PARALLELIZE *// for (y = 0; y < 4; y++) { refptr = PelYline_11 (ref_pic, abs_y++, abs_x, img_height, img_width); LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; } The full function where this loop exists is below for referance. /*! *********************************************************************** * \brief * Setup the fast search for an macroblock *********************************************************************** */ void SetupFastFullPelSearch (short ref, int list) // <-- reference frame parameter, list0 or 1 { short pmv[2]; pel_t orig_blocks[256], *orgptr=orig_blocks, *refptr, *tem; // created pointer tem int offset_x, offset_y, x, y, range_partly_outside, ref_x, ref_y, pos, abs_x, abs_y, bindex, blky; int LineSadBlk0, LineSadBlk1, LineSadBlk2, LineSadBlk3; int max_width, max_height; int img_width, img_height; StorablePicture *ref_picture; pel_t *ref_pic; int** block_sad = BlockSAD[list][ref][7]; int search_range = max_search_range[list][ref]; int max_pos = (2*search_range+1) * (2*search_range+1); int list_offset = ((img->MbaffFrameFlag)&&(img->mb_data[img->current_mb_nr].mb_field))? img->current_mb_nr%2 ? 4 : 2 : 0; int apply_weights = ( (active_pps->weighted_pred_flag && (img->type == P_SLICE || img->type == SP_SLICE)) || (active_pps->weighted_bipred_idc && (img->type == B_SLICE))); ref_picture = listX[list+list_offset][ref]; //===== Use weighted Reference for ME ==== if (apply_weights && input->UseWeightedReferenceME) ref_pic = ref_picture->imgY_11_w; else ref_pic = ref_picture->imgY_11; max_width = ref_picture->size_x - 17; max_height = ref_picture->size_y - 17; img_width = ref_picture->size_x; img_height = ref_picture->size_y; //===== get search center: predictor of 16x16 block ===== SetMotionVectorPredictor (pmv, enc_picture->ref_idx, enc_picture->mv, ref, list, 0, 0, 16, 16); search_center_x[list][ref] = pmv[0] / 4; search_center_y[list][ref] = pmv[1] / 4; if (!input->rdopt) { //--- correct center so that (0,0) vector is inside --- search_center_x[list][ref] = max(-search_range, min(search_range, search_center_x[list][ref])); search_center_y[list][ref] = max(-search_range, min(search_range, search_center_y[list][ref])); } search_center_x[list][ref] += img->opix_x; search_center_y[list][ref] += img->opix_y; offset_x = search_center_x[list][ref]; offset_y = search_center_y[list][ref]; //===== copy original block for fast access ===== for (y = img->opix_y; y < img->opix_y+16; y++) for (x = img->opix_x; x < img->opix_x+16; x++) *orgptr++ = imgY_org [y][x]; //===== check if whole search range is inside image ===== if (offset_x >= search_range && offset_x <= max_width - search_range && offset_y >= search_range && offset_y <= max_height - search_range ) { range_partly_outside = 0; PelYline_11 = FastLine16Y_11; } else { range_partly_outside = 1; } //===== determine position of (0,0)-vector ===== if (!input->rdopt) { ref_x = img->opix_x - offset_x; ref_y = img->opix_y - offset_y; for (pos = 0; pos < max_pos; pos++) { if (ref_x == spiral_search_x[pos] && ref_y == spiral_search_y[pos]) { pos_00[list][ref] = pos; break; } } } //===== loop over search range (spiral search): get blockwise SAD ===== **// =====THIS IS THE PART WHERE NESTED FOR STARTS=====** for (pos = 0; pos < max_pos; pos++) // OUTERMOST FOR LOOP { abs_y = offset_y + spiral_search_y[pos]; abs_x = offset_x + spiral_search_x[pos]; if (range_partly_outside) { if (abs_y >= 0 && abs_y <= max_height && abs_x >= 0 && abs_x <= max_width ) { PelYline_11 = FastLine16Y_11; } else { PelYline_11 = UMVLine16Y_11; } } orgptr = orig_blocks; bindex = 0; for (blky = 0; blky < 4; blky++) // SECOND FOR LOOP { LineSadBlk0 = LineSadBlk1 = LineSadBlk2 = LineSadBlk3 = 0; for (y = 0; y < 4; y++) //INNERMOST FOR LOOP WHICH I WANT TO PARALLELIZE { refptr = PelYline_11 (ref_pic, abs_y++, abs_x, img_height, img_width); LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk0 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk1 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk2 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; LineSadBlk3 += byte_abs [*refptr++ - *orgptr++]; } block_sad[bindex++][pos] = LineSadBlk0; block_sad[bindex++][pos] = LineSadBlk1; block_sad[bindex++][pos] = LineSadBlk2; block_sad[bindex++][pos] = LineSadBlk3; } } //===== combine SAD's for larger block types ===== SetupLargerBlocks (list, ref, max_pos); //===== set flag marking that search setup have been done ===== search_setup_done[list][ref] = 1; } #endif // _FAST_FULL_ME_

    Read the article

  • How to Key-Value-Observe the rotation of a CALayer?

    - by HelloMoon
    I can access the value like this: NSNumber* rotationZ = [myLayer valueForKeyPath:@"transform.rotation.z"]; But for some reason, if I try to KV-observe that key path, I get a compiler error. First, this is how I try to do it: [myLayer addObserver:self forKeyPath:@"transform.rotation.z" options:0 context:nil]; The compiler tells me: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ addObserver: forKeyPath:@"rotation.z" options:0x0 context:0x528890] was sent to an object that is not KVC-compliant for the "rotation" property.' what I don't get is, why I can access that z value by KVC key path, but not add an observer to it. Does this make sense? How else could I observe the z value of that matrix? I don't care about the other values of the matrix. Only the z rotation. Any other way to access and observe it?

    Read the article

  • Detect at runtime which country's App Store my iPhone app was downloaded from?

    - by Mike McMaster
    I have a feature in my iPhone application that, for business reasons, should only be shown/available to customers in the US. If I want to release this app to App Stores outside the US, what's the best way to figure out which country I'm in without relying on user-defined settings such as language and locale? In my mind, the ideal solution is that there's some runtime property that can tell me which App Store country the app was downloaded from, and I can take action accordingly. Looking through the docs and searching the web, I'm not coming up with anything in this department. I don't expect the solution to be 100% foolproof as far as users not being in the country they say they're from, but as close as possible would be nice. I suppose one solution would be to make a separate build for a new product on the App Store and have two versions, one for the US and one for the others, but that doesn't seem ideal. I'm hoping it can be the same product on the App Store to prevent things like fragmentation of user reviews. Thanks in advance!

    Read the article

  • Why do i get E_ACCESSDENIED when reading public shortcuts through Shell32?

    - by corvuscorax
    I'm trying to read the targets of all desktop shortcuts in a C# 4 application. The shortcuts on a windows desktop can come from more that one location, depending on whether the shortcut is created for all users or just the current user. In this specific case I'm trying to read a shortcut from the public desktop, e.g. from C:\Users\Public\Desktop\shortcut.lnk. The code is like this (path is a string contaning the path to the lnk file): var shell = new Shell32.ShellClass(); var folder = shell.NameSpace(Path.GetDirectoryName(path)); var folderItem = folder.ParseName(Path.GetFileName(path)); if (folderItem != null) { var link = (Shell32.ShellLinkObject)folderItem.GetLink; The last line throws an System.UnauthorizedAccessException, indicating that it's not allowed to read the shortcut file's contents. I have tried on shortcut files on the user's private desktop (c:\Users\username\Desktop) and that works fine. So, my questions are: (1) why is my application not allowed to /read/ the shortcut from code, when I can clearly read the contents as a user? (2) is there a way to get around this? Maybe using a special manifest file for the application? And, by the way, my OS is Windows 7, 64-bit. be well -h-

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >