c# - What is this piece of code doing with RegEx -
have been studying sample source code , can't understand part, piece of code doing? regex part...
in parameters used, "code" string, c# source code passing in.
match m = null; if ((m = regex.match(code, "(?ims)^[/']{2}refdll (?<ref>.+?)$")).success) { foreach (string refdll in m.groups["ref"].value.split(new char[] { ';', ',' })) { //2008-06-18 jeffrey, remove redundant \r string mdfyrefdll = refdll.replace("\r", "").replace("\n", ""); //trim ending .dll if exists if (mdfyrefdll.tolower().endswith(".dll")) mdfyrefdll = mdfyrefdll.substring(0, mdfyrefdll.length - 4); string lcrefdll = mdfyrefdll.tolower(); if (lcrefdll == "system.data.linq" || lcrefdll == "system" || lcrefdll == "system.xml.linq" || lcrefdll == "system.core") continue; cp.referencedassemblies.add(mdfyrefdll + ".dll"); } }
i think image addresses what's going on in code posted:

mini c# lab's project description follows:
a handy tool simple short c# code running , testing, can save time on waiting visual studio startup , avoid creating lot of one-time project files.
it seems project missing documentation, it's difficult extrapolate why author of code chose particular way add referenced dlls when there using directive in there already. perhaps did avoid conflicts using statement.
Comments
Post a Comment