public static string MakeVersionSafeName(string name, ResourceScope from, ResourceScope to, Type type) { if ((from & ResourceScope.Private) != ResourceScope.None) { to &= ~(ResourceScope.Private | ResourceScope.Assembly); } else if ((from & ResourceScope.Assembly) != ResourceScope.None) { to &= ~ResourceScope.Assembly; } string name2 = (name != null) ? name : string.Empty; switch (from) { case ResourceScope.Machine: break; case ResourceScope.Process: goto IL_8F; default: switch (from) { case ResourceScope.Machine | ResourceScope.Private: break; case ResourceScope.Process | ResourceScope.Private: goto IL_8F; default: switch (from) { case ResourceScope.Machine | ResourceScope.Assembly: goto IL_86; case ResourceScope.Process | ResourceScope.Assembly: goto IL_8F; case ResourceScope.AppDomain | ResourceScope.Assembly: goto IL_98; } throw new ArgumentException("from"); case ResourceScope.AppDomain | ResourceScope.Private: goto IL_98; } break; case ResourceScope.AppDomain: goto IL_98; } IL_86: return(VersioningHelper.ConvertFromMachine(name2, to, type)); IL_8F: return(VersioningHelper.ConvertFromProcess(name2, to, type)); IL_98: return(VersioningHelper.ConvertFromAppDomain(name2, to, type)); }
public static string MakeVersionSafeName(string name, ResourceScope from, ResourceScope to, Type type) { ResourceScope resourceScope1 = from & (ResourceScope.Machine | ResourceScope.Process | ResourceScope.AppDomain | ResourceScope.Library); ResourceScope resourceScope2 = to & (ResourceScope.Machine | ResourceScope.Process | ResourceScope.AppDomain | ResourceScope.Library); if (resourceScope1 > resourceScope2) { throw new ArgumentException(Environment.GetResourceString("Argument_ResourceScopeWrongDirection", (object)resourceScope1, (object)resourceScope2), "from"); } int num1 = (int)VersioningHelper.GetRequirements(to, from); int num2 = 24; if ((num1 & num2) != 0 && type == (Type)null) { throw new ArgumentNullException("type", Environment.GetResourceString("ArgumentNull_TypeRequiredByResourceScope")); } StringBuilder stringBuilder = new StringBuilder(name); char ch = '_'; int num3 = 2; if ((num1 & num3) != 0) { stringBuilder.Append(ch); stringBuilder.Append('p'); stringBuilder.Append(Win32Native.GetCurrentProcessId()); } int num4 = 4; if ((num1 & num4) != 0) { string clrInstanceString = VersioningHelper.GetCLRInstanceString(); stringBuilder.Append(ch); stringBuilder.Append('r'); stringBuilder.Append(clrInstanceString); } int num5 = 1; if ((num1 & num5) != 0) { stringBuilder.Append(ch); stringBuilder.Append("ad"); stringBuilder.Append(AppDomain.CurrentDomain.Id); } int num6 = 16; if ((num1 & num6) != 0) { stringBuilder.Append(ch); stringBuilder.Append(type.Name); } int num7 = 8; if ((num1 & num7) != 0) { stringBuilder.Append(ch); stringBuilder.Append(type.Assembly.FullName); } return(stringBuilder.ToString()); }
private static string ConvertFromAppDomain(string name, ResourceScope to, Type type) { if (to < ResourceScope.AppDomain || to >= ResourceScope.Private) { throw new ArgumentException("to"); } return(VersioningHelper.SafeName(name, false, false)); }
private static string ConvertFromProcess(string name, ResourceScope to, Type type) { if (to < ResourceScope.Process || to >= ResourceScope.Private) { throw new ArgumentException("to"); } bool appdomain = (to & ResourceScope.AppDomain) == ResourceScope.AppDomain; return(VersioningHelper.SafeName(name, false, appdomain)); }
public static string MakeVersionSafeName(string name, ResourceScope from, ResourceScope to, Type type) { ResourceScope resourceScope = from & (ResourceScope.Machine | ResourceScope.Process | ResourceScope.AppDomain | ResourceScope.Library); ResourceScope resourceScope2 = to & (ResourceScope.Machine | ResourceScope.Process | ResourceScope.AppDomain | ResourceScope.Library); if (resourceScope > resourceScope2) { throw new ArgumentException(Environment.GetResourceString("Argument_ResourceScopeWrongDirection", new object[] { resourceScope, resourceScope2 }), "from"); } SxSRequirements requirements = VersioningHelper.GetRequirements(to, from); if ((requirements & (SxSRequirements.AssemblyName | SxSRequirements.TypeName)) != SxSRequirements.None && type == null) { throw new ArgumentNullException("type", Environment.GetResourceString("ArgumentNull_TypeRequiredByResourceScope")); } StringBuilder stringBuilder = new StringBuilder(name); char value = '_'; if ((requirements & SxSRequirements.ProcessID) != SxSRequirements.None) { stringBuilder.Append(value); stringBuilder.Append('p'); stringBuilder.Append(Win32Native.GetCurrentProcessId()); } if ((requirements & SxSRequirements.CLRInstanceID) != SxSRequirements.None) { string clrinstanceString = VersioningHelper.GetCLRInstanceString(); stringBuilder.Append(value); stringBuilder.Append('r'); stringBuilder.Append(clrinstanceString); } if ((requirements & SxSRequirements.AppDomainID) != SxSRequirements.None) { stringBuilder.Append(value); stringBuilder.Append("ad"); stringBuilder.Append(AppDomain.CurrentDomain.Id); } if ((requirements & SxSRequirements.TypeName) != SxSRequirements.None) { stringBuilder.Append(value); stringBuilder.Append(type.Name); } if ((requirements & SxSRequirements.AssemblyName) != SxSRequirements.None) { stringBuilder.Append(value); stringBuilder.Append(type.Assembly.FullName); } return(stringBuilder.ToString()); }
private static string ConvertFromMachine(string name, ResourceScope to, Type type) { switch (to) { case ResourceScope.Machine: return(VersioningHelper.SafeName(name, false, false)); case ResourceScope.Process: return(VersioningHelper.SafeName(name, true, false)); case ResourceScope.AppDomain: return(VersioningHelper.SafeName(name, true, true)); } throw new ArgumentException("to"); }
private static string SafeName(string name, bool process, bool appdomain) { if (process && appdomain) { return(string.Concat(new string[] { name, "_", VersioningHelper.GetProcessId().ToString(), "_", VersioningHelper.GetDomainId().ToString() })); } if (process) { return(name + "_" + VersioningHelper.GetProcessId().ToString()); } if (appdomain) { return(name + "_" + VersioningHelper.GetDomainId().ToString()); } return(name); }
public static string MakeVersionSafeName(string name, ResourceScope from, ResourceScope to) { return(VersioningHelper.MakeVersionSafeName(name, from, to, null)); }
// Token: 0x06005040 RID: 20544 RVA: 0x0011A454 File Offset: 0x00118654 private static string GetCLRInstanceString() { return(VersioningHelper.GetRuntimeId().ToString(CultureInfo.InvariantCulture)); }