Ejemplo n.º 1
0
        public void Resolve()
        {
            if (Compiler.Settings.Unsafe && module.PredefinedTypes.SecurityAction.Define())
            {
                //
                // Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)]
                // when -unsafe option was specified
                //
                Location loc = Location.Null;

                MemberAccess system_security_permissions = new MemberAccess(new MemberAccess(
                                                                                new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc);

                var req_min = (ConstSpec)module.PredefinedTypes.SecurityAction.GetField("RequestMinimum", module.PredefinedTypes.SecurityAction.TypeSpec, loc);

                Arguments pos = new Arguments(1);
                pos.Add(new Argument(req_min.GetConstant(null)));

                Arguments named = new Arguments(1);
                named.Add(new NamedArgument("SkipVerification", loc, new BoolLiteral(true, loc)));

                GlobalAttribute g = new GlobalAttribute(new NamespaceEntry(module, null, null, null), "assembly",
                                                        new MemberAccess(system_security_permissions, "SecurityPermissionAttribute"),
                                                        new Arguments[] { pos, named }, loc, false);
                g.AttachTo(module, module);
                var ctor = g.Resolve();
                //if (ctor != null) {
                //    g.ExtractSecurityPermissionSet (ctor, ref declarative_security);
                //}
            }

            if (module.OptAttributes == null)
            {
                return;
            }

            // Ensure that we only have GlobalAttributes, since the Search isn't safe with other types.
            if (!module.OptAttributes.CheckTargets())
            {
                return;
            }

            cls_attribute = module.ResolveAssemblyAttribute(module.PredefinedAttributes.CLSCompliant);

            if (cls_attribute != null)
            {
                is_cls_compliant = cls_attribute.GetClsCompliantAttributeValue();
            }

            if (added_modules != null && Compiler.Settings.VerifyClsCompliance && is_cls_compliant)
            {
                foreach (var m in added_modules)
                {
                    if (!m.IsCLSCompliant)
                    {
                        Report.Error(3013,
                                     "Added modules must be marked with the CLSCompliant attribute to match the assembly",
                                     m.Name);
                    }
                }
            }

            Attribute a = module.ResolveAssemblyAttribute(module.PredefinedAttributes.RuntimeCompatibility);

            if (a != null)
            {
                var val = a.GetNamedValue("WrapNonExceptionThrows") as BoolConstant;
                if (val != null)
                {
                    wrap_non_exception_throws = val.Value;
                }
            }
        }
Ejemplo n.º 2
0
 public void TypeTest()
 {
     Type type = typeof(TestClass); // TODO: Initialize to an appropriate value
     GlobalAttribute target = new GlobalAttribute(type); // TODO: Initialize to an appropriate value
     Type actual;
     actual = target.Type;
     Assert.AreEqual(actual, type); ;
 }
Ejemplo n.º 3
0
    private void DoCommand(string command)
    {
        string[] str = command.Split(' ');
        if (RoleData.mainRole == null)
        {
            AddMsg("can't find mainRole.");
        }

        switch (str[0].ToLower().Trim())
        {
        case "additem":
            if (str.Length < 2)
            {
                AddMsg("please input command: additem item_id count.");
                break;
            }
            int count = 1;
            if (str.Length > 2)
            {
                count = int.Parse(str[2]);
            }
            string[] ids = str[1].Split('-');
            if (ids.Length == 2)
            {
                int min_id = int.Parse(ids[0]);
                int max_id = int.Parse(ids[1]);
                for (int item_id = min_id; item_id <= max_id; item_id++)
                {
                    int c = count;
                    RoleData.mainRole.AddOrCreateItem(item_id, ref c);
                }
            }
            else
            {
                int item_id = int.Parse(str[1]);
                RoleData.mainRole.AddOrCreateItem(item_id, ref count);
            }
            break;

        case "clearbag": {
            List <int> rm = new List <int>();;
            foreach (var item in RoleData.mainRole.bag_items)
            {
                if (!RoleData.mainRole.ItemIsEquip(item))
                {
                    rm.Add(item);
                }
            }
            foreach (var item in rm)
            {
                RoleData.mainRole.RemoveItem(item, 0);
            }
            break;
        }

        case "clearlog":
            gm_msg.Clear();
            show.text = string.Join("\n", gm_msg.ToArray());
            break;

        case "set":
            if (str.Length < 2)
            {
                AddMsg("please input command: set attributeName value. set value.");
                break;
            }
            int set_value;
            if (str.Length < 2)
            {
                set_value = int.Parse(str[1]);
                for (RoleAttribute i = 0; i < RoleAttribute.modao; i++)
                {
                    RoleData.mainRole.SetAttrebuteValue(i, set_value);
                }
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.max_item, set_value);
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.xinde, set_value);
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.daodian, set_value);
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.coin, set_value);
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.contributions, set_value);
                RoleData.mainRole.SetAttrebuteValue(RoleAttribute.city_token, set_value);
                break;
            }
            RoleAttribute attr = (RoleAttribute)Enum.Parse(typeof(RoleAttribute), str[1]);
            set_value = int.Parse(str[2]);
            RoleData.mainRole.SetAttrebuteValue(attr, set_value);
            break;

        case "game":
            if (str.Length < 3)
            {
                AddMsg("please input command: set attributeName value.");
                break;
            }
            if (GameData.instance != null)
            {
                GlobalAttribute gattr  = (GlobalAttribute)Enum.Parse(typeof(GlobalAttribute), str[1]);
                long            gvalue = long.Parse(str[2]);
                GameData.instance.SetGameData(gattr, gvalue);
            }
            else
            {
                AddMsg("can't find GameData.");
            }
            break;

        case "test": {
            MainUI.ShowUI("RoleWindow", "bag");
            // 清空背包
            List <int> rm = new List <int>();;
            foreach (var item in RoleData.mainRole.bag_items)
            {
                if (!RoleData.mainRole.ItemIsEquip(item))
                {
                    rm.Add(item);
                }
            }
            foreach (var item in rm)
            {
                RoleData.mainRole.RemoveItem(item, 0);
            }
            MessageWindow.Message(51, 52, () => {
                    //背包容量
                    RoleData.mainRole.SetAttrebuteValue(RoleAttribute.max_item, GameData.instance.item_static_data.Length + 5);
                    EventManager.SendEvent(EventTyp.ItemChange, RoleData.mainRole);
                    MessageWindow.Message(51, 53, () => {
                        //背包容量
                        RoleData.mainRole.SetAttrebuteValue(RoleAttribute.max_item, GameData.instance.item_static_data.Length + 5);
                        // 添加所有物品
                        for (int i = 0; i < GameData.instance.item_static_data.Length; i++)
                        {
                            int c = GameData.instance.item_static_data[i].maxcount;
                            RoleData.mainRole.AddOrCreateItem(i, ref c);
                        }
                        MessageWindow.Message(51, 54);
                    });
                });
            break;
        }

        default:
            AddMsg("please input command:" + err_command);
            break;
        }
    }
Ejemplo n.º 4
0
        public void Resolve()
        {
            if (RootContext.Unsafe)
            {
                //
                // Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)]
                // when -unsafe option was specified
                //

                Location loc = Location.Null;

                MemberAccess system_security_permissions = new MemberAccess(new MemberAccess(
                                                                                new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc);

                Arguments pos = new Arguments(1);
                pos.Add(new Argument(new MemberAccess(new MemberAccess(system_security_permissions, "SecurityAction", loc), "RequestMinimum")));

                Arguments named = new Arguments(1);
                named.Add(new NamedArgument(new LocatedToken(loc, "SkipVerification"), (new BoolLiteral(true, loc))));

                GlobalAttribute g = new GlobalAttribute(new NamespaceEntry(null, null, null), "assembly",
                                                        new MemberAccess(system_security_permissions, "SecurityPermissionAttribute"),
                                                        new Arguments[] { pos, named }, loc, false);
                g.AttachTo(this, this);

                if (g.Resolve() != null)
                {
                    declarative_security = new ListDictionary();
                    g.ExtractSecurityPermissionSet(declarative_security);
                }
            }

            if (OptAttributes == null)
            {
                return;
            }

            // Ensure that we only have GlobalAttributes, since the Search isn't safe with other types.
            if (!OptAttributes.CheckTargets())
            {
                return;
            }

            ClsCompliantAttribute = ResolveAttribute(PredefinedAttributes.Get.CLSCompliant);

            if (ClsCompliantAttribute != null)
            {
                is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue();
            }

            Attribute a = ResolveAttribute(PredefinedAttributes.Get.RuntimeCompatibility);

            if (a != null)
            {
                object val = a.GetPropertyValue("WrapNonExceptionThrows");
                if (val != null)
                {
                    wrap_non_exception_throws = (bool)val;
                }
            }
        }
Ejemplo n.º 5
0
 public void SetGameData(GlobalAttribute attr, long value)
 {
     globalAttr[(int)attr] = value;
     EventManager.SendEvent(EventTyp.GameDataChange, attr);
 }
Ejemplo n.º 6
0
 public long GetGameData(GlobalAttribute attr)
 {
     return(globalAttr[(int)attr]);
 }