当前位置: 首页>>代码示例>>C#>>正文


C# Page.MapPath方法代码示例

本文整理汇总了C#中Page.MapPath方法的典型用法代码示例。如果您正苦于以下问题:C# Page.MapPath方法的具体用法?C# Page.MapPath怎么用?C# Page.MapPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page.MapPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDemoXmlDocument

    public static XmlDocument GetDemoXmlDocument(Page page) {
        //if(BasePage.demoXmlDocument == null) {
            BasePage.demoXmlDocument = new XmlDocument();
			BasePage.demoXmlDocument.Load(page.MapPath("~/App_Data/Demos.xml"));
        //}
        return BasePage.demoXmlDocument;
    }
开发者ID:BiYiTuan,项目名称:soa,代码行数:7,代码来源:Utils.cs

示例2: CheckPeriodicAttacks

    public void CheckPeriodicAttacks(Page page)
    {
        if (attackDoc == null)
        {
            attackDoc = new XmlDocument();
            attackDoc.Load(page.MapPath(@"~/LastStand/LastStandXml/Attacks.xml"));
        }

        if (gangDoc == null)
        {
            gangDoc = new XmlDocument();
            gangDoc.Load(page.MapPath(@"~/LastStand/LastStandXml/Gang.xml"));
        }

        DateTime d1 = new DateTime(1970, 1, 1);
        DateTime d2;
        rand = new Random();

        foreach (XmlNode gang in gangDoc.LastChild.ChildNodes)
        {
            d2 = DateTime.UtcNow;
            int status = System.Convert.ToInt32(gang.Attributes["Status"].Value);
            int RestTimeAllowed = 24 - (status * 4);
            d2 = d2.AddHours(-RestTimeAllowed);
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);

            XmlAttribute la = gang.Attributes["LastAttack"];
            if (la == null || Convert.ToDouble(la.Value) < ts.TotalMilliseconds)
            {
                if (la == null)
                {
                    la = gangDoc.CreateAttribute("LastAttack");
                    gang.Attributes.Append(la);
                }
                // new attack
                Attack(gang, page, (AttackDifficulty)status);
            }
        }
    }
开发者ID:Rawne,项目名称:Last-stand,代码行数:39,代码来源:AttackSender.cs

示例3: HandleArrivedAttacks

    public bool HandleArrivedAttacks(Page page)
    {
        if (page == null)
            return false;

        XmlDocument doc = new XmlDocument();
        doc.Load(page.MapPath(@"~/LastStand/LastStandXml/Attacks.xml"));

        DateTime d1 = new DateTime(1970, 1, 1).ToUniversalTime();
        DateTime d2 = DateTime.UtcNow;
        TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
        double dateNow = ts.TotalMilliseconds;

        for (int i = doc.LastChild.ChildNodes.Count -1; i >= 0; i--)
        {
            XmlNode node = doc.LastChild.ChildNodes[i];
            if (System.Convert.ToDouble(node.Attributes["ETA"].Value) < dateNow)
            {
                ResolveAttack(node, page);

                doc.LastChild.RemoveChild(node);
                doc.Save(page.MapPath(@"~/LastStand/LastStandXml/Attacks.xml"));
            }
            /*else // debug code
            {
                XmlAttribute attr = doc.CreateAttribute("test1");
                attr.Value = System.Convert.ToDouble(node.Attributes["ETA"].Value).ToString();
                XmlAttribute attr2 = doc.CreateAttribute("test2");
                attr2.Value = dateNow.ToString();
                node.Attributes.Append(attr);
                node.Attributes.Append(attr2);
                doc.Save(page.MapPath(@"~/LastStand/LastStandXml/Attacks.xml"));
            }*/
        }

        return true;
    }
开发者ID:Rawne,项目名称:Last-stand,代码行数:37,代码来源:AttackHandler.cs

示例4: ResolveAttack

    private void ResolveAttack(XmlNode attackNode, Page page)
    {
        // all of the required xml files for combat resolutions-------------------------------
        if (gang == null)
        {
            gang = new XmlDocument();
            gang.Load(page.MapPath(@"~/LastStand/LastStandXml/Gang.xml"));
        }
        if (defenderGangers == null)
        {
            defenderGangers = new XmlDocument();
            defenderGangers.Load(page.MapPath(@"~/LastStand/LastStandXml/GangMembers.xml"));
        }
        if (gangerTypes == null)
        {
            gangerTypes = new XmlDocument();
            gangerTypes.Load(page.MapPath(@"~/LastStand/LastStandXml/LastStandGangerTypes.xml"));
        }
        if (weaponTypes == null)
        {
            weaponTypes = new XmlDocument();
            weaponTypes.Load(page.MapPath(@"~/LastStand/LastStandXml/LastStandWeaponTypes.xml"));
        }
        if (neutralTypes == null)
        {
            neutralTypes = new XmlDocument();
            neutralTypes.Load(page.MapPath(@"~/LastStand/LastStandXml/LastStandNeutralTypes.xml"));
        }
        if (leaderDoc == null)
        {
            leaderDoc = new XmlDocument();
            leaderDoc.Load(page.MapPath(@"~/LastStand/LastStandXml/Leader.xml"));
        }
        if (defenses == null)
        {
            defenses = new XmlDocument();
            defenses.Load(page.MapPath(@"~/LastStand/LastStandXml/Defense.xml"));
        }
        if (defenseTypes == null)
        {
            defenseTypes = new XmlDocument();
            defenseTypes.Load(page.MapPath(@"~/LastStand/LastStandXml/HideoutDefensesTypes.xml"));
        }
        if (combatLog == null)
        {
            combatLog = new XmlDocument();
            combatLog.Load(page.MapPath(@"~/LastStand/LastStandXml/CombatLogs.xml"));
        }

        //-------------------------------------------------------------------------------------

        string id = attackNode.Attributes["TargetId"].Value;
        string attackerId = attackNode.Attributes["AttackerId"].Value;
        totalDefense = 0;

        defenders = new List<Fighter>();
        attackers = new List<Fighter>();
        weapons = new List<Weapon>();
        //Defenses:
        initDefenses(id);
        //Attacker:
        initAttacker(attackNode);
        //Calculate battle:
        calculateBattle(id, attackerId, page);

        combatLog.Save(page.MapPath(@"~/LastStand/LastStandXml/CombatLogs.xml"));
        leaderDoc.Save(page.MapPath(@"~/LastStand/LastStandXml/Leader.xml"));
        defenderGangers.Save(page.MapPath(@"~/LastStand/LastStandXml/GangMembers.xml"));
        gang.Save(page.MapPath(@"~/LastStand/LastStandXml/Gang.xml"));
    }
开发者ID:Rawne,项目名称:Last-stand,代码行数:70,代码来源:AttackHandler.cs

示例5: Attack

    private void Attack(XmlNode gang, Page page, AttackDifficulty difficulty)
    {
        System.Xml.XmlNode attackNode = attackDoc.CreateElement("Attack");
        System.Xml.XmlAttribute targetId = attackDoc.CreateAttribute("TargetId");
        System.Xml.XmlAttribute ETA = attackDoc.CreateAttribute("ETA");
        System.Xml.XmlAttribute typeAttack = attackDoc.CreateAttribute("Type");
        System.Xml.XmlAttribute attackerId = attackDoc.CreateAttribute("AttackerId");
        targetId.Value = gang.Attributes["Id"].Value;
        attackerId.Value = "0";

        DateTime d1 = new DateTime(1970, 1, 1).ToUniversalTime();
        DateTime d2 = DateTime.UtcNow.AddHours(3 + rand.Next(0, 3));
        DateTime d3 = DateTime.UtcNow;
        TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
        string arrival = ts.TotalMilliseconds.ToString();
        ts = new TimeSpan(d3.Ticks - d1.Ticks);
        string now = ts.TotalMilliseconds.ToString();
        ETA.Value = arrival;

        typeAttack.Value = "Zombies";
        attackNode.Attributes.Append(targetId);
        attackNode.Attributes.Append(ETA);
        attackNode.Attributes.Append(typeAttack);
        attackNode.Attributes.Append(attackerId);
        attackDoc.LastChild.AppendChild(attackNode);

        int random = rand.Next(2, 5);

        int zombies = random * ((int)difficulty + 1);

        int exposure = System.Convert.ToInt32(gang.Attributes["Exposure"].Value);

        for (int i = 0; i < zombies; i++)
        {

            int exposureOffset = rand.Next(0, 50);
            System.Xml.XmlNode neutNode = attackDoc.CreateElement("Attacker");
            System.Xml.XmlAttribute neutType = attackDoc.CreateAttribute("NeutType");

            if (exposure < 55)
                neutType.Value = "Zombie";
            else if (exposure < 85)
                neutType.Value = "PlagueZombie";
            else if (exposure < 120)
                neutType.Value = "BloodZombie";
            else
                neutType.Value = "ZombieLord";

            neutNode.Attributes.Append(neutType);
            attackNode.AppendChild(neutNode);
        }

        gang.Attributes["LastAttack"].Value = now;

        gangDoc.Save(page.MapPath(@"~/LastStand/LastStandXml/Gang.xml"));
        attackDoc.Save(page.MapPath(@"~/LastStand/LastStandXml/Attacks.xml"));
    }
开发者ID:Rawne,项目名称:Last-stand,代码行数:57,代码来源:AttackSender.cs


注:本文中的Page.MapPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。