Setting values ​​at compile time in Visual Studio (C #)?

I am currently working with C # and developing several Silverlight applications that use sharepoint web services as data sources.

Sharepoint administrators decided that in order to β€œsegregate” users, they had to create the same sharepoint list several times and provide users from each branch with access to the corresponding list for this branch.

This poses a small problem, because I have to install guid for sharepoint lists for each branch and compile 5 different versions of the same application.

In the end, I decided to create a ListProperties class and pass the name of the current branch to the method so that it returns the right guid.

So, now I set the variable (branch) to " BRANCH-A ", compiles and renames the application to "AppBranchA.xap". Then do the same for each branch.

Is there a way to pass a string at compile time and have a variable (and hopefully the application name too) automatically change?

I am ready to listen to other ways to manage multiple assemblies at once.

thank,

+5
source share
3 answers

One way to get close to this is to use a conditional compilation symbol to control which value is GUIDused to set specific branching properties. for instance

class ListProperties {

#if BRANCH-A
  public static readonly GUID BranchGuid = "Guid #1";
#endif

#if BRANCH-B
  public static readonly GUID BranchGuid = "Guid #2";
#endif

}

.

- . .

+2

, VS 2010

config , . .

+3

, .

#if BRANCH_A
 readonly Guid myId = new Guid("some guid");
#endif

#if BRANCH_B
 readonly Guid myId = new Guid("some other guid");
#endif

- , ( ). , .

+2
source

All Articles