コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }