コード例 #1
0
        static public ResultBuffer checklicensefile_net(ResultBuffer args)
        {
            if (args == null)
            {
                throw new ArgumentException("No arguments provided.");
            }

            Array argsArray = null;

            argsArray = args.AsArray();

            if (argsArray.Length == 0)
            {
                throw new ArgumentException("No arguments provided.");
            }

            string rsaPublicKey = (string)((TypedValue)argsArray.GetValue(0)).Value;
            string pathToFile   = (string)((TypedValue)argsArray.GetValue(1)).Value;

            var license = new LicenseKey().LoadFromFile(pathToFile).HasValidSignature(rsaPublicKey);

            if (license != null && license.MaxNoOfMachines > 0)
            {
                // check the machine code too only if node-locking is enabled.
                if (!Helpers.IsOnRightMachinePI(license, false, false))
                {
                    return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32), -1)));
                }
            }

            var result = license.IsValid() ? 1 : -1;

            return(new ResultBuffer(new TypedValue(Convert.ToInt32(LispDataType.Int32), result)));
        }