Пример #1
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            switch (context.UsageMode)
            {
            case LicenseUsageMode.Runtime:
            {
                System.Diagnostics.Trace.TraceWarning("在运行时执行License检查");
            }
            break;

            case LicenseUsageMode.Designtime:
            {
                System.Diagnostics.Trace.TraceWarning("在设计时或编译时执行License检查");
            }
            break;

            default:
                break;
            }
            var savedKey = context.GetSavedLicenseKey(type, null);

            System.Diagnostics.Trace.TraceWarning("LicenseSavedKey::" + savedKey);
            if (string.IsNullOrEmpty(savedKey))
            {
                var key = "MyKey";
                context.SetSavedLicenseKey(type, key);
                savedKey = key;
            }
            return(new MyLicense(savedKey));
        }
Пример #2
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            MyLicense license = null;

            string cpuid = GetCpuID();

            cpuid = DESLicense.Encrypt(cpuid);//加密

            if (context != null)
            {
                if (context.UsageMode == LicenseUsageMode.Runtime)
                {
                    String savedLicenseKey = context.GetSavedLicenseKey(type, null);
                    if (cpuid.Equals(savedLicenseKey))
                    {
                        return(new MyLicense(this, cpuid));
                    }
                }
                if (license != null)
                {
                    return(license);
                }

                // 打开License文件 'MyLicense.dat'
                if (Validation(cpuid))
                {
                    license = new MyLicense(this, cpuid);
                }
                if (license != null)
                {
                    context.SetSavedLicenseKey(type, cpuid);
                }
            }

            if (license == null)
            {
                //System.Windows.Forms.MessageBox.Show("!!!尚未注册!!!");
                throw new LicenseException(type, instance, "Your license is invalid");;
                //return new MyLicense(this,"no");
            }

            return(license);
        }
Пример #3
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            IocompLicense iocompLicense = null;
            string        text          = null;
            RegistryKey   registryKey   = null;
            Type          type2         = type;

            registryKey = Registry.LocalMachine.OpenSubKey("Software\\Iocomp\\.Net Licenses V3");
            if (registryKey == null)
            {
                registryKey = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Iocomp\\.Net Licenses V3");
            }
            do
            {
                if (!(type2 != typeof(Component)) && !(type2.Name == "OPCData"))
                {
                    break;
                }
                if (IocompLicenseProvider.m_DynamicLicenseKeys != null)
                {
                    int num = 0;
                    while (num < IocompLicenseProvider.m_DynamicLicenseKeys.Count)
                    {
                        if (!((IocompLicenseProvider.m_DynamicLicenseKeys[num] as DynamicLicenseKey).Type == type))
                        {
                            num++;
                            continue;
                        }
                        text = (IocompLicenseProvider.m_DynamicLicenseKeys[num] as DynamicLicenseKey).KeyString;
                        break;
                    }
                }
                if (text == null && registryKey != null)
                {
                    text = (string)registryKey.GetValue(type2.FullName);
                }
                try
                {
                    if (text == null)
                    {
                        text = this.GetSavedLicenseKeySpecial(type2, null);
                    }
                }
                catch (Exception)
                {
                    text          = null;
                    iocompLicense = null;
                }
                if (text != null && this.LicenseKeyValid(type, text))
                {
                    iocompLicense = new IocompLicense(this, text);
                    break;
                }
                type2 = type2.BaseType;
            }while (!(type2 == (Type)null) && !(type2 != typeof(object)));
            if (iocompLicense == null)
            {
                if (DateTime.Now > IocompLicenseProvider.m_LastEvalPopUpDateTime + new TimeSpan(0, 10, 0))
                {
                    if (IocompLicenseProvider.m_Timer == null)
                    {
                        IocompLicenseProvider.m_Timer          = new Timer();
                        IocompLicenseProvider.m_Timer.Interval = 200;
                        IocompLicenseProvider.m_Timer.Tick    += this.m_Timer_Tick;
                        IocompLicenseProvider.m_Timer.Enabled  = false;
                    }
                    IocompLicenseProvider.m_LastEvalPopUpDateTime = DateTime.Now;
                }
                iocompLicense = new IocompLicense(this, "Evaluation");
            }
            if (context != null && iocompLicense != null)
            {
                context.SetSavedLicenseKey(type, iocompLicense.LicenseKey);
            }
            return(iocompLicense);
        }
Пример #4
0
        public override License GetLicense(LicenseContext context, Type type,
                                           object instance, bool allowExceptions)
        {
            // Step 1: locate the license key
            string licenseKey = null;

            switch (context.UsageMode)
            {
            case LicenseUsageMode.Designtime:
                licenseKey = GetDesignTimeLicenseKey(type);
                context.SetSavedLicenseKey(type, licenseKey);
                break;

            case LicenseUsageMode.Runtime:
                licenseKey = context.GetSavedLicenseKey(type, null);
                break;
            }
            if (licenseKey == null)
            {
                if (allowExceptions)
                {
                    throw new LicenseException(type, instance,
                                               "No appropriate license key was located.");
                }
                else
                {
                    return(null);
                }
            }


            // Step 2: validate the license key
            bool isValid = IsLicenseKeyValid(type, licenseKey);

            if (!isValid)
            {
                if (allowExceptions)
                {
                    throw new LicenseException(type, instance,
                                               "License key is not valid.");
                }
                else
                {
                    return(null);
                }
            }


            // Step 3: grant a license
            License license = CreateLicense(type, licenseKey);

            if (license == null)
            {
                if (allowExceptions)
                {
                    throw new LicenseException(type, instance,
                                               "license could not be created.");
                }
                else
                {
                    return(null);
                }
            }

            return(license);
        }
Пример #5
0
        public override License GetLicense(LicenseContext licenseContext_0, Type type_0, object object_0, bool bool_0)
        {
            License aELicense;

            if (licenseContext_0 == null)
            {
                throw new LicenseException(type_0, object_0, "License context is null.");
            }
            string savedLicenseKey = licenseContext_0.GetSavedLicenseKey(type_0, null);

            if ((savedLicenseKey == null ? true : !this.IsKeyValid(type_0, savedLicenseKey)))
            {
                switch (licenseContext_0.UsageMode)
                {
                case LicenseUsageMode.Runtime:
                {
                    savedLicenseKey =
                        this.GetLicenseFromFile(string.Concat(Application.StartupPath, "\\licences.lic"),
                                                type_0.FullName);
                    if (savedLicenseKey == null || !this.IsKeyValid(type_0, savedLicenseKey))
                    {
                        aELicense = null;
                        break;
                    }
                    else
                    {
                        licenseContext_0.SetSavedLicenseKey(type_0, savedLicenseKey);
                        aELicense = new AELicense("Runtime");
                        break;
                    }
                }

                case LicenseUsageMode.Designtime:
                {
                    ITypeResolutionService service =
                        (ITypeResolutionService)licenseContext_0.GetService(typeof(ITypeResolutionService));
                    if (service != null)
                    {
                        if (service.GetPathOfAssembly(type_0.Assembly.GetName()) == null)
                        {
                            string fullyQualifiedName = type_0.Module.FullyQualifiedName;
                        }
                        savedLicenseKey = "受限许可";
                    }
                    aELicense = new AELicense(savedLicenseKey);
                    break;
                }

                default:
                {
                    aELicense = null;
                    break;
                }
                }
            }
            else
            {
                aELicense = new AELicense(savedLicenseKey);
            }
            return(aELicense);
        }
Пример #6
0
        public void SetSavedLicenseKey_Invoke_Nop()
        {
            var context = new LicenseContext();

            context.SetSavedLicenseKey(null, null);
        }
Пример #7
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            ChartLicense chartLicense = null;

            if (context != null)
            {
                if (context.UsageMode == LicenseUsageMode.Designtime)
                {
                    chartLicense = new ChartLicense(this, "Dundas Chart. Design-Time License");
                }
                if (chartLicense == null)
                {
                    string savedLicenseKey = context.GetSavedLicenseKey(type, null);
                    if (savedLicenseKey != null && this.IsKeyValid(savedLicenseKey, type))
                    {
                        chartLicense = new ChartLicense(this, savedLicenseKey);
                    }
                }
                if (chartLicense == null)
                {
                    string text = null;
                    if (context != null)
                    {
                        ITypeResolutionService typeResolutionService = (ITypeResolutionService)context.GetService(typeof(ITypeResolutionService));
                        if (typeResolutionService != null)
                        {
                            text = typeResolutionService.GetPathOfAssembly(type.Assembly.GetName());
                        }
                    }
                    if (text == null)
                    {
                        text = type.Module.FullyQualifiedName;
                    }
                    string directoryName = Path.GetDirectoryName(text);
                    string path          = directoryName + "\\" + type.FullName + ".lic";
                    bool   flag          = File.Exists(path);
                    if (!flag)
                    {
                        string path2 = directoryName + "\\__AssemblyInfo__.ini";
                        if (File.Exists(path2))
                        {
                            string       text2        = null;
                            Stream       stream       = new FileStream(path2, FileMode.Open, FileAccess.Read, FileShare.Read);
                            StreamReader streamReader = new StreamReader(stream);
                            do
                            {
                                text2 = streamReader.ReadLine();
                                text2 = text2.ToUpper(CultureInfo.InvariantCulture);
                                if (text2 != null && text2.StartsWith("URL=", StringComparison.Ordinal))
                                {
                                    directoryName = text2.Substring(4);
                                    if (directoryName.StartsWith("FILE:///", StringComparison.Ordinal))
                                    {
                                        directoryName = directoryName.Substring(8);
                                    }
                                    directoryName = directoryName.Replace('/', '\\');
                                    int num = directoryName.LastIndexOf('\\');
                                    if (num >= 0)
                                    {
                                        directoryName = directoryName.Substring(0, num);
                                    }
                                    path  = directoryName + "\\" + type.FullName + ".lic";
                                    flag  = File.Exists(path);
                                    text2 = null;
                                }
                            }while (text2 != null);
                            streamReader.Close();
                        }
                    }
                    if (flag)
                    {
                        Stream       stream2       = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                        StreamReader streamReader2 = new StreamReader(stream2);
                        string       key           = streamReader2.ReadLine();
                        streamReader2.Close();
                        if (this.IsKeyValid(key, type))
                        {
                            chartLicense = new ChartLicense(this, key);
                        }
                    }
                    if (chartLicense != null)
                    {
                        context.SetSavedLicenseKey(type, chartLicense.LicenseKey);
                    }
                }
            }
            return(chartLicense);
        }
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            int num2;

            string[] textArray1;
            string   text1 = "\nEnvironment info:\n";

            text1 = text1 + "version: " + DiagramView.VersionName + "\n";
            if (Assembly.GetEntryAssembly() != null)
            {
                text1 = text1 + "entry: ";
                try
                {
                    text1 = text1 + Assembly.GetEntryAssembly().FullName;
                }
                catch (SecurityException)
                {
                    text1 = text1 + "?fn?";
                }
                object obj1 = null;
                try
                {
                    obj1 = Assembly.GetEntryAssembly().EntryPoint;
                }
                catch (SecurityException)
                {
                    text1 = text1 + "?ep?";
                }
                if (obj1 != null)
                {
                    text1 = text1 + ", has entry point\n";
                }
                else
                {
                    text1 = text1 + ", no entry point\n";
                }
            }
            else
            {
                text1 = text1 + "null entry\n";
            }
            int    num1  = 0;
            string text2 = "";

            try
            {
                try
                {
                    text2 = context.GetSavedLicenseKey(type, null);
                }
                catch (SecurityException exception1)
                {
                    text2 = null;
                    text1 = text1 + "\n" + exception1.ToString();
                }
                if (text2 != null)
                {
                    text1 = text1 + "key: " + text2 + "\n";
                }
                else
                {
                    text1 = text1 + "null key\n";
                }
                if ((text2 != null) && (text2.Length != 0))
                {
                    goto Label_01AF;
                }
                try
                {
                    Assembly[] assemblyArray1 = AppDomain.CurrentDomain.GetAssemblies();
                    Assembly[] assemblyArray2 = assemblyArray1;
                    for (num2 = 0; num2 < assemblyArray2.Length; num2++)
                    {
                        Assembly assembly1 = assemblyArray2[num2];
                        text1 = text1 + assembly1.FullName + "\n";
                        try
                        {
                            text2 = context.GetSavedLicenseKey(type, assembly1);
                        }
                        catch (SecurityException)
                        {
                            text2 = null;
                        }
                        if ((text2 != null) && (text2.Length > 0))
                        {
                            goto Label_015A;
                        }
                    }
                }
                catch (SecurityException)
                {
                }
Label_015A:
                text1 = text1 + DiagramView.myVersionName + "\n";
                if (DiagramView.myVersionAssembly != null)
                {
                    text1 = text1 + DiagramView.myVersionAssembly.GetName().Name + "\n";
                }
                else
                {
                    text1 = text1 + "null licensed assembly\n";
                }
                if (DiagramView.myVersionName.Length > 0x18)
                {
                    text2 = DiagramView.myVersionName;
                }
Label_01AF:
                if ((text2 != null) && (text2.Length > 0))
                {
                    num1 = this.Dispose(text2, true);
                    if (num1 == 4)
                    {
                        return(new DiagramViewLicense(text2, num1));
                    }
                }
                else
                {
                    text2 = "";
                    RegistryKey key1 = null;
                    try
                    {
                        key1 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Northwoods Software\Go.NET");
                    }
                    catch (SecurityException exception2)
                    {
                        text1 = text1 + "\n" + exception2.ToString();
                    }
                    if (key1 == null)
                    {
                        try
                        {
                            key1 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Northwoods Software\GoDiagram");
                        }
                        catch (SecurityException)
                        {
                        }
                    }
                    if (key1 != null)
                    {
                        string text3 = type.Assembly.GetName().Name;
                        object obj2  = null;
                        try
                        {
                            obj2 = key1.GetValue(text3);
                        }
                        catch (SecurityException)
                        {
                        }
                        if ((obj2 != null) && (obj2 is byte[]))
                        {
                            text2 = Convert.ToBase64String((byte[])obj2);
                        }
                    }
                    num1 = this.Dispose(text2, false);
                    if ((num1 == 0) && (key1 != null))
                    {
                        text2 = "";
                        string text4 = type.Assembly.GetName().Name + " eval";
                        object obj3  = null;
                        try
                        {
                            obj3 = key1.GetValue(text4);
                        }
                        catch (SecurityException)
                        {
                        }
                        if ((obj3 != null) && (obj3 is byte[]))
                        {
                            text2 = Convert.ToBase64String((byte[])obj3);
                        }
                        num1 = this.Dispose(text2, false);
                    }
                    if ((num1 >= 4) && (context.UsageMode == LicenseUsageMode.Designtime))
                    {
                        context.SetSavedLicenseKey(type, text2);
                    }
                    if ((num1 == 4) || (context.UsageMode == LicenseUsageMode.Designtime))
                    {
                        return(new DiagramViewLicense(text2, num1));
                    }
                }
            }
            catch (Exception exception3)
            {
                text1 = text1 + "\n" + exception3.ToString();
            }
            num2 = num1 & 3;
            switch (num2)
            {
            case 1:
            {
                string text7 = (num1 > 4) ? "beta" : "evaluation";
                textArray1 = new string[0x10] {
                    "Built using ", DiagramViewLicenseProvider.GONAME, " for .NET Windows Forms ", this.StringFloat(DiagramView.Version), Environment.NewLine, "Copyright \x00a9 Northwoods Software, 1998-2004.  All Rights Reserved.", Environment.NewLine, "This ", text7, " copy of ", DiagramViewLicenseProvider.GONAME, " is about to expire.", Environment.NewLine, Environment.NewLine, "DO NOT DISTRIBUTE OR DEPLOY THIS SOFTWARE.", Environment.NewLine
                };
                string text8 = string.Concat(textArray1);
                if (num1 < 4)
                {
                    text8 = text8 + Environment.NewLine + "Please purchase a license at www.nwoods.com" + Environment.NewLine;
                }
                if (SystemInformation.UserInteractive)
                {
                    MessageBox.Show(text8, type.Name + " License Check", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    Console.WriteLine(type.Name + " License Check");
                    Console.WriteLine(text8);
                }
                return(new DiagramViewLicense(text8, num1));
            }

            case 2:
            {
                string text5 = (num1 > 4) ? "beta" : "evaluation";
                textArray1 = new string[14] {
                    "Built using ", DiagramViewLicenseProvider.GONAME, " for .NET Windows Forms ", this.StringFloat(DiagramView.Version), Environment.NewLine, "Copyright \x00a9 Northwoods Software, 1998-2004.  All Rights Reserved.", Environment.NewLine, "This software is licensed for a limited ", text5, " period.", Environment.NewLine, Environment.NewLine, "DO NOT DISTRIBUTE OR DEPLOY THIS SOFTWARE.", Environment.NewLine
                };
                string text6 = string.Concat(textArray1);
                if (num1 < 4)
                {
                    text6 = text6 + Environment.NewLine + "Please purchase a license at www.nwoods.com" + Environment.NewLine;
                }
                if (SystemInformation.UserInteractive)
                {
                    if (!DiagramViewLicenseProvider.err)
                    {
                        DiagramViewLicenseProvider.err = true;
                        MessageBox.Show(text6, type.Name + " License Check", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Console.WriteLine(type.Name + " License Check");
                    Console.WriteLine(text6);
                }
                return(new DiagramViewLicense(text6, num1));
            }
            }
            textArray1 = new string[0x1c] {
                "Built using ", DiagramViewLicenseProvider.GONAME, " for .NET Windows Forms ", this.StringFloat(DiagramView.Version), Environment.NewLine, "Copyright \x00a9 Northwoods Software, 1998-2004.  All Rights Reserved.", Environment.NewLine, "The license for this copy of ", DiagramViewLicenseProvider.GONAME, " is invalid or has expired.", Environment.NewLine, Environment.NewLine, "Please purchase a license at www.nwoods.com", Environment.NewLine, "If you have already purchased a ", DiagramViewLicenseProvider.GONAME,
                " development license,", Environment.NewLine, "  have you requested an Unlock Code for your development machine by running the GoDiagram LicenseManager?", Environment.NewLine, "If you have already entered an Unlock Code in the LicenseManager,", Environment.NewLine, "  did you link license objects into your application via the Microsoft license compiler?", Environment.NewLine, "  (Make sure the needed components and correct VERSION are listed in the LICENSES.LICX file,", Environment.NewLine, "   and that the LICENSES.LICX file is part of your EXECUTABLE's project, not in a DLL.)", Environment.NewLine
            };
            string text9 = string.Concat(textArray1);

            text9 = text9 + text1;
            if (SystemInformation.UserInteractive)
            {
                MessageBox.Show(text9, type.Name + " License Check", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                Console.WriteLine(type.Name + " License Check");
                Console.WriteLine(text9);
            }
            if (allowExceptions)
            {
                throw new LicenseException(type, instance, text9);
            }
            return(null);
        }
Пример #9
0
        public override License GetLicense(
            LicenseContext context,
            System.Type type,
            object instance,
            bool allowExceptions)
        {
            if (!x294bd621a33dc533.x0b277e20f7c1b92c)
            {
                goto label_44;
            }
label_43:
            return((License) new xbd7c5470fc89975b());

label_44:
            if (context != null)
            {
                goto label_45;
            }
label_4:
            int customerID;
            x1d91faf71382de33 x1d91faf71382de33;

            do
            {
                if (x294bd621a33dc533.IsDebug)
                {
                    this.WriteDebugMessage("eval");
                }
                x1d91faf71382de33 = new x1d91faf71382de33();
            }while ((uint)customerID + (uint)customerID < 0U);
            if ((customerID & 0) == 0)
            {
                if (((allowExceptions ? 1 : 0) & 0) == 0)
                {
                    if ((customerID & 0) == 0)
                    {
                        if (false)
                        {
                            if ((uint)allowExceptions >= 0U)
                            {
                                goto label_31;
                            }
                            else
                            {
                                goto label_25;
                            }
                        }
                        else
                        {
                            goto label_46;
                        }
                    }
                    else
                    {
                        goto label_29;
                    }
                }
                else
                {
                    goto label_13;
                }
            }
            else
            {
                goto label_9;
            }
label_7:
            if (context.UsageMode == LicenseUsageMode.Designtime)
            {
                if (!this.DoesValidDevelopmentLicenseExist(type.Assembly, (System.IServiceProvider)context, out customerID))
                {
                    if ((uint)allowExceptions > uint.MaxValue)
                    {
                        goto label_20;
                    }
                    else
                    {
                        goto label_4;
                    }
                }
                else
                {
                    string key = customerID.ToString((IFormatProvider)CultureInfo.InvariantCulture) + "|" + this.GenerateLicenseKeyForType(type, customerID);
                    context.SetSavedLicenseKey(type, key);
                    if (!x294bd621a33dc533.IsDebug)
                    {
                        goto label_10;
                    }
                }
            }
            else
            {
                goto label_4;
            }
label_9:
            this.WriteDebugMessage("valid");
label_10:
            return((License) new xbd7c5470fc89975b());

label_13:
            if (!x294bd621a33dc533.x4528b3b385025289)
            {
                if ((uint)allowExceptions - (uint)allowExceptions < 0U)
                {
                    goto label_9;
                }
            }
            else
            {
                goto label_7;
            }
label_15:
            if (this.DoesValidDevelopmentLicenseExist(type.Assembly, (System.IServiceProvider)context, out customerID))
            {
                goto label_27;
            }
            else
            {
                goto label_7;
            }
label_16:
            if (context.UsageMode != LicenseUsageMode.Runtime)
            {
                if ((uint)customerID > uint.MaxValue)
                {
                    goto label_13;
                }
                else
                {
                    goto label_7;
                }
            }
            else
            {
                string savedLicenseKey = this.GetSavedLicenseKey(context, type);
                if (savedLicenseKey != null)
                {
                    if (this.IsTypeKeyValid(savedLicenseKey, type))
                    {
                        if ((uint)allowExceptions > uint.MaxValue)
                        {
                            if (false)
                            {
                                if (true)
                                {
                                    if (true)
                                    {
                                        goto label_35;
                                    }
                                    else
                                    {
                                        goto label_43;
                                    }
                                }
                                else
                                {
                                    goto label_13;
                                }
                            }
                            else
                            {
                                goto label_43;
                            }
                        }
                        else
                        {
                            goto label_31;
                        }
                    }
                    else
                    {
                        goto label_13;
                    }
                }
                else
                {
                    goto label_29;
                }
            }
label_20:
            string message;

            message += "Press OK to read more.";
            string assemblyProductName;

            x294bd621a33dc533.ShowMessage(message, assemblyProductName);
            if ((uint)customerID <= uint.MaxValue)
            {
                Process.Start("http://www.divelements.co.uk/net/support/kb/licensing.aspx");
                x294bd621a33dc533.x4528b3b385025289 = true;
                goto label_7;
            }
label_22:
            string[] strArray = new string[5] {
                "Warning: Although your development license for ", assemblyProductName, " is valid, it has not been embedded into your application by Visual Studio. This means that on a machine without ", null, null
            };
            if (((allowExceptions ? 1 : 0) & 0) == 0)
            {
                strArray[3] = assemblyProductName;
                strArray[4] = " installed, the license will not be found. Normally, opening at least one form designer will ensure the licenses.licx file in your project is created and updated correctly. If you continue to see this message, ensure the following lines are present in the file.";
                message     = string.Concat(strArray) + Environment.NewLine + Environment.NewLine + this.GetLicenseFileLines(type);
                if (true)
                {
                    message = message + Environment.NewLine + Environment.NewLine;
                    goto label_20;
                }
                else
                {
                    goto label_35;
                }
            }
            else if ((uint)allowExceptions + (uint)customerID >= 0U)
            {
                goto label_37;
            }
label_25:
            if ((uint)allowExceptions - (uint)customerID >= 0U)
            {
                goto label_27;
            }
label_26:
            this.WriteDebugMessage("devok,notembedded");
            goto label_28;
label_27:
            if (x294bd621a33dc533.IsDebug)
            {
                goto label_26;
            }
label_28:
            assemblyProductName = x294bd621a33dc533.GetAssemblyProductName(type.Assembly);
            if (true)
            {
                goto label_22;
            }
            else
            {
                goto label_46;
            }
label_29:
            if ((uint)allowExceptions >= 0U)
            {
                goto label_13;
            }
            else
            {
                goto label_15;
            }
label_31:
            if (x294bd621a33dc533.IsDebug)
            {
                this.WriteDebugMessage("valid");
            }
            return((License) new xbd7c5470fc89975b());

label_35:
            if (x294bd621a33dc533.IsDebug)
            {
                this.WriteDebugMessage("licreq," + context.UsageMode.ToString());
                if ((customerID | (int)byte.MaxValue) == 0)
                {
                    goto label_13;
                }
            }
            else
            {
                goto label_16;
            }
label_37:
            if ((uint)customerID - (uint)customerID < 0U)
            {
                goto label_35;
            }
            else
            {
                goto label_16;
            }
label_45:
            this.GetLicenseFileLines(type);
            goto label_35;
label_46:
            return((License)x1d91faf71382de33);
        }
        /// <include file='doc\LicFileLicenseProvider.uex' path='docs/doc[@for="LicFileLicenseProvider.GetLicense"]/*' />
        /// <devdoc>
        ///    <para>Gets a license for the instance of the component and determines if it is valid.</para>
        /// </devdoc>
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            ProcCountLicense lic = null;

            Debug.Assert(context != null, "No context provided!");
            //if no context is provided, do nothing
            if (context != null)
            {
                //if this control is in runtime mode
                if (context.UsageMode == LicenseUsageMode.Runtime)
                {
                    //retreive the stored license key
                    string key = context.GetSavedLicenseKey(type, null);

                    //check if the stored license key is null
                    // and call IsKeyValid to make sure its valid
                    if (key != null && IsKeyValid(key, type))
                    {
                        //if the key is valid create a new license
                        lic = new ProcCountLicense(this, key);
                    }
                }

                //if we're in design mode or
                //a suitable license key wasn't found in
                //the runtime context.
                //attempt to look for a .LIC file
                if (lic == null)
                {
                    //build up the path where the .LIC file
                    //should be
                    string modulePath = null;

                    // try and locate the file for the assembly
                    if (context != null)
                    {
                        ITypeResolutionService resolver = (ITypeResolutionService)context.GetService(typeof(ITypeResolutionService));
                        if (resolver != null)
                        {
                            modulePath = resolver.GetPathOfAssembly(type.Assembly.GetName());
                        }
                    }


                    if (modulePath == null)
                    {
                        modulePath = type.Module.FullyQualifiedName;
                    }

                    //get the path from the file location
                    string moduleDir = Path.GetDirectoryName(modulePath);

                    //build the path of the .LIC file
                    string licenseFile = moduleDir + "\\" + type.FullName + ".lic";

                    Debug.WriteLine("Path of license file: " + licenseFile);

                    //if the .LIC file exists, dig into it
                    if (File.Exists(licenseFile))
                    {
                        //crack the file and get the first line
                        Stream       licStream = new FileStream(licenseFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                        StreamReader sr        = new StreamReader(licStream);
                        string       s         = sr.ReadLine();
                        sr.Close();

                        Debug.WriteLine("Contents of license file: " + s);

                        //check if the key is valid
                        if (IsKeyValid(s, type))
                        {
                            //valid key so create a new License
                            lic = new ProcCountLicense(this, s);
                        }
                    }

                    //if we managed to create a license, stuff it into the context
                    if (lic != null)
                    {
                        context.SetSavedLicenseKey(type, lic.LicenseKey);
                    }
                }
            }
            return(lic);
        }