Wednesday, 27 October 2010

Visual Studio - "File Lock" pri buildanju - Rešitev !

Pri buildanju vseh projektov se velikorat pojavi napaka, da je "File Lock" ( access denied ) ali kaj podobne -- predvsem je to Shell ( pbrt4.exe ) ... rešitev je ta, da v Pre-Build event projekta ( ki jezi  ! ) kopiramo naslednjo kodo :

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

to je to :)

Tuesday, 26 October 2010

"OnŽeVe" Import

Vse kar je potrebno da "OnŽeVe" import lahko uporabimo in da dela tako kot mora je. Na objektu v katerem smo definirali akcije, ki se lahko izvedejo dodamo attribut [ImportAction(ModuleName = "Modul za katerega uporabljamo import")] in v konstruktorju, brez argumentov, objetka navedemo in registraramo akcije.

Primer:
[ImportAction(ModuleName = "oni novi modul")]
public class noviModulAkcije
{
public novimodulAkcije()
{
ImportList.AddAction("Ime akcije", "natančen opis kako akcija deluje",
MetodaKiSeIzvedeObKlicu);
}
public void MetodaKiSeIzvedeObKlicu()
{
}
}

VS Tips'N'Tricks - "Run to cursor"

"Run to cursor" nam omogoča, da v času debugiranja kreiramo začasen break-point. 
V delu kode, kjer želimo, da se program ustavi iz menija izberemo "Run to cursor" in aplikacije se izvede do točke, ki smo jo določili.

To je hitrejši način kot pa premikanje po kodi s tipkama F10 / F11 in lovimo "pravi trenutek".

Monday, 25 October 2010

LINQ-Tips'n'Tricks #1

V prvi "seriji" tips'n'tricks bom predstavil t.i. "Generation operators" - kot pove ime so namenjeni generiranju določenih sekvenc ( številk, objektov, ... ).

RANGE in REPEAT

1. Generiranje zaporednih številk ( 10,11,12,13,14,...,20)
var numbers = Enumerable.Range(10, 20);
2. Generiranje naključnih številk
Random rand = new Random();
var randomSeq = Enumerable.Repeat(0, N).Select(i => rand.Next());
3. Ponavljanje "stringa" za X krat
var str = Enumerable.Repeat("Yes ",5); //Izpiše "Yes Yes Yes Yes Yes"
4. Kreiranje X "praznih" objektov.
var objArray = Enumerable.Repeat(0,5).Select(x => Contact.NewEntity() ).ToArray();

40 Hour Work Week @ Microsoft

Zanimivo ter predvsem poučno branje :)

40 Hour Work Week

Citat :
In my experience, a 40 hour work week is a benchmark of the most effective teams.
  • They have work-life balance.

  • They have buffer to respond to opportunity and to deal with crunches.
  • They have processes in place, they invest in their learning and growth, and they move up the stack instead of always solving the basics.
    Instead of perpetual fire-fighting, they are more deliberate about planning and strategy and they anticipate their customers and the market (through empathy and staying connected to customers.)
  • They learn and respond and can turn on a dime. They have a dashboard, they know the score, and they can change their approach.

Friday, 22 October 2010

Extension methods

V prihodnjih dneh ( tednih :) ) bova z Mitjem pripravila PBRT4_Extensions knjižnico ( spremenile se bodo tudi druge knjižnice oz. se bo PBRT4_Library ločila na več manjših dll-jev - a o tem drugič ).

Z uporabo extension metod je koda bolj "bralna" in lažje sledljiva.

Primer

if(!ReferenceEquals( myObj, null ) -- zelo nepregledno ( hitro spregledaš ! na začetku )

Alternativa preko ExtensionMethods if ( myObj.IsNotNull() ) -- bolj pregledno

Wednesday, 20 October 2010