Posts

wpf - C#: Cast to Base -

i have datagrid column contains link. file gets opened on click <datagridhyperlinkcolumn binding="{binding path=number}" > <datagridhyperlinkcolumn.elementstyle> <style> <eventsetter event="hyperlink.click" handler="linkclicked"/> </style> </datagridhyperlinkcolumn.elementstyle> </datagridhyperlinkcolumn> i use method public void linkclicked(object sender, routedeventargs e) { var vm = (basepartviewmodel<part>) datacontext; vm.openfile(); } i use code in base viewmodel class. but problem cast not work (basepartviewmodel<part>) datacontext because every implementation different. instance (basepartviewmodel<plug>) datacontext and plug derives part . how make work without implementing method in every derived viewmodel? you factor out openfile method covariant interface , cast interface. interface myinterface<out t> {...

c# - Azure Web Jobs failure - ReadLine() left in -

so created azure web job performs task every 15 mins. runs c# console application. problem on last upload of program left console.readline(); argument in, causing program never finish (used local debugging of course) , web job fail , never run again. can fixed real quick if had source code, source code @ office, forgot upload cloud storage. won't have access till bit later on week. so i'm looking quick fix. can download .exe program last uploaded easily. i'm thinking run program first calls main program , closes after time. tried simple .bat script able open program, couldn't close/kill process due access denied errors (worked locally). other quick suggestions that'll work in web job environment? obviously if see here in few days, i've made corrections source code @ root of issue, others may interested well. :) update: thank everyone! each of these solutions helped me web job running intended. decompiling using reflector useful can add project cloud...

protocol buffers - Apache Apex CLI launch error - protobuf -

i'm trying launch apa file apache apex cli (version 3.4) on hadoop cluster running 2.7.4-snapshot , protobuf v2.6.1 , following error: java.lang.nosuchmethoderror: com.google.protobuf.lazystringlist.getunmodifiableview()lcom/google/protobuf/lazystringlist; @ org.apache.hadoop.yarn.proto.yarnserviceprotos$getapplicationsrequestproto$builder.buildpartial(yarnserviceprotos.java:17322) @ org.apache.hadoop.yarn.proto.yarnserviceprotos$getapplicationsrequestproto$builder.build(yarnserviceprotos.java:17310) @ org.apache.hadoop.yarn.api.protocolrecords.impl.pb.getapplicationsrequestpbimpl.mergelocaltoproto(getapplicationsrequestpbimpl.java:79) @ org.apache.hadoop.yarn.api.protocolrecords.impl.pb.getapplicationsrequestpbimpl.getproto(getapplicationsrequestpbimpl.java:69) @ org.apache.hadoop.yarn.api.impl.pb.client.applicationclientprotocolpbclientimpl.getapplications(applicationclientprotocolpbclientimpl.java:249) any ideas wro...

R Date conversion from factor -

i have factor of date given in number origin 1899-12-30, e.g. dat1 <- factor(42648) if want change date format, i'd do as.date(dat1, origin="1899-12-30") but conversion requires format. doing as.date(as.numeric(as.character(dat1)), origin="1899-12-30") works seems little on top. there shorter way?

java - Does creating multiple "throwaway" objects affect performance -

example: is this public double rounddecimal(double val) { return double.parsedouble(new decimalformat("#,##0.0").format(val)); } double d1 = rounddecimal(val); double d1 = rounddecimal(val); double d1 = rounddecimal(val); // lot more of these... considered bad practice instead of this? public double rounddecimal(double val, decimalformat dformat) { return double.parsedouble(dformat.format(val)); } decimalformat dformat = new decimalformat("#,##0.0"); double d1 = rounddecimal(val, dformat); double d1 = rounddecimal(val, dformat); double d1 = rounddecimal(val, dformat); // lot more of these... the difference of course being instead of creating decimalformat object on , over, create once , resuse it. thoughts garbage collector ensure wouldn't matter, don't understand enough know sure. you looking @ wrong end. “optimized” variant public double rounddecimal(double val, decimalformat dformat) { return double.parsedouble(dfor...

osx - Cannot edit Sharepoint files on my mac. -

i'm using sharepoint on mac. (tried both safari , chrome) editing files online not possible. error: "sorry, document can't opened editing." tried .doc files , .docx files, both did not work. some files, made colleagues can opened, browser messes layout. what do? thanks! jill how file opens determined settings in library. if library not allow file open in browser view , don't have appropriate software in machine won't open. the browser view making mess of document layouts pretty standard ms file types in browser viewers. if have ever wondered why developers tend prefer text files in preference msword , that's 1 of many reasons. there many more factors may causing experiencing impossible work through them in context. able discuss happening site owner or site collection owner , start exploring site settings, list settings, software on machine, formatting of documents not displaying in browser , see if can start eliminating obvious probl...

Is there a way to restrict input to integer/double in this format in c++ -

i trying make simple calculator in c++. in first version, had menu based system , asked input 1 after other easy validate integer. however, realised can user enter question in format enter on real calculator. double first; char choice; double second; cin >> first >> choice >> second; however stuck on how can check because of solution have looked @ follow format, not know how can implement because cin takes in 3 pieces of data. int x; cin >> x; if (!cin) { // not number } you cannot restrict user types @ terminal. best thing can detect input not appropriate, , ask input again. while ( !(cin >> first) ) { cout << "please enter floating point number: " cin.clear(); cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } do same thing other numbers.