Posts

c# - How to use properties to expose a private array as read-only? -

what following code do? class myclass { private int[] myprivates; public int[] getmyprivates { { return myprivates; } } protected int[] setmyprivates { set { myprivates = value; } } } is there better way of protecting array myprivates ? possible make reat-only? you replace getters , setters property way: class myclass { public int[] myvalues { get; protected set; } public myclass() { myvalues = new [] {1, 2, 3, 4, 5}; } public void foo { foreach (int in myvalues) { trace.writeline(i.tostring()); } } } myotherclass { myclass myclass; // ... void bar { // can access myclass values in read outside of myclass, // because of public property, not in write because // of protected setter. foreach (int in myclass.myvalues) { trace.writeline(i.tostring()); } } } you can add pretty protection level less 1 o...

c# - Display right datamember in the datagridview by using Bindinglist -

goal: display encapsulate field player problem: want display datamember_id , _name , _bust in class mainform using bindinglist was suppose use syntax [] above encapsulate field? class mainform datagridviewplayers.autogeneratecolumns=true; datagridviewplayers.autosizecolumnsmode=datagridviewautosizecolumnsmode.fill; bindingsourceplayers.clear(); bindingsourceplayers.datasource = _mygamemanager.players; class gamemanager: public bindinglist<player> players { { (int = 0; < _myplayergui_list.count; i++) { _player.add(new player(_myplayergui_list[i].player)); } return _player; } } using system; using system.collections.generic; using system.linq; using system.text; using cardgameclasslibrary; namespace cardgamelib { public class player { private int _id; private string _name; private hand _myhand; ...

NHibernate sub-collection using QueryOver -

i have simple classes: public class order { public int id {get;set;} public ilist<name> names{get;set;} } public class name { public int id {get;set;} public int langid {get;set;} public string localname {get;set;} } the quesetion how query subcollection of order have order.names.localname (something this): ilist<order> orders = repository.getbyproductlocalname("laptop"); i use new nh3 feature queryover, not using linq (i'v found solutions in of them uses linq). all need declare alias variable names collection , can use in clause... string localname = "laptop"; name namesalias = null; return session.queryover<order>() .joinalias(x => x.names, () => namesalias) .where(() => namesalias.localname == localname) .transformusing(transformers.distinctrootentity) .list<order>();

JavaScript syntax to find dates within last three years -

what proper syntax see if given date falls within 3 years todays date? need 3 years not take year of todays date , subtract 3 may not 3 full years ago. in other words if mid way through year. need go mid way through year 3 years ago. basically have records have dates attached them , want display them if between today , 3 years ago. thanks date objects can subtracted give difference in milliseconds: var = new date; var = new date(2008, 10, 7); if ((now - then) < 1000 * 60 * 60 * 24 * 365 * 3) 1000 * 60 * 60 * 24 * 365 * 3 3 years in milliseconds, discounting leap years , leap seconds.

c# - Problem with credential chaining sequence in Windows and .NET -

problem summary when run in batch mode, user identity lost (like cliffhanger) not until last moment. problem details i have powershell script running on winxpsp3 runs script block (via invoke-command) on remote machine particular test user (via -session parameter) in background (via -asjob parameter). session created this: new-pssession -computername $myserver -credential $mycredential the script block performs number of actions, culminating in running nunit test framework. c# code under test records "mytestuser" username (via environment.username ) credentials provided powershell received far. further confirmed process explorer: examining properties of nunit-console running batch tests shows owned mytestuser. the test includes accessing sql server 2008 r2 database; connection string set via new sqlconnection(connectionstring) call. connection string set windows authentication , uses form: data source=<my_db_server_name>;initial catalog=<my_db_name...

Would be possible for Compiz to work on Windows? -

i don't think work is. more like, windows internal architecture allows third party sw integrate in between? read compiz, believe creates own window, , somehow mixes graphics system x own. still has catch events exit button , on. does windows allow this? let 3rd program scan input of window? , more, catching output of gui , replace it? does windows allow this? let 3rd program scan input of window? , more, catching output of gui , replace it? thanks. it possible. see windowblinds example. note windows "officially" not support this, applications windowblinds use api hooking, subclassing etc. perform deeds.

iphone - Finding and returning the distance between two coordinates -

i'm sort of newbie--please don't hate. the method compiles, i'm not sure how retrieve float value (i.e. distance between 2 points) method returns (or should return rather). -(float)finddistancebetween:(coordinate *)a and:(coordinate *)b { //distance formula: //sqrt( (x2 - x1)^2 + (y2 - y1)^2 ) float resultdistance; resultdistance = sqrt( pow((b.latitude - a.latitude), 2) + pow((b.longitude - a.longitude), 2)); return resultdistance; } //somewhere else... float thedistancebetween; //below incorrect: thedistancebetween = [finddistancebetween: location1 and: location2]; thanks is finddistancebetween:and: defined in @implementation block? code should like // in .h file @interface myclass : nsobject // declaration of method - (float)finddistanceinbetween:(coordinate *)a and:(coordinate *)b; @end // in .m file @implementation myclass // definition of method - (float)finddistancebetween:(coordinate *)a and:(coord...