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


C# Business.AddDeal方法代码示例

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


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

示例1: GetBusinessInformation

    // ***************************************************
    // Initial pull from the UniverCity servert for the 
    // business information.
    // ---------------------------------------------------
    public IEnumerator GetBusinessInformation()
    {
        //if (Application.platform == RuntimePlatform.WindowsEditor) ;
        //    //loader.SetActive(true);
        //else if (Application.platform == RuntimePlatform.Android ||
        //         Application.platform == RuntimePlatform.IPhonePlayer)
        //NativeDialogs.Instance.ShowProgressDialog("Please Wait", "Loading Businesses", false, false);  
        string bURL = serverURL + "BusinessInfo?u=UofO";
        string bLURL = serverURL + "BusinessLogos?b=";
        string bName = "";
        string bDesc = "";
        int id = 0;
        Vector2 busPos;
        WWW page = null;
        bool goodDownload = false;

        // This string will be populated with a list of all business IDs.
        string businessIDs = "";

        while (!goodDownload)
        {
            page = new WWW(bURL);
            yield return page;

            if (page.error == null && page.text != null && page.isDone)
                goodDownload = true;
        }


        // Create an IList of all of the businesses returned to me.
        List<object> businessInfo = Json.Deserialize(page.text) as List<object>;
        // Iterate through each of the dictionaries in the list.
        foreach (Dictionary<string, object> business in businessInfo)
        {
            // Retrieve the ID, Name, and Description of each business.
            id = Convert.ToInt32(business["id"]);
            bName = business["name"] as string;
            bDesc = business["desc"] as string;
            Business bus = new Business(id, bName, bDesc);
            businesses.Add(bus);
            // Check to see if the business has a discount...
            if (business.ContainsKey("discount"))
            {
                Dictionary<string, object> discount = business["discount"] as Dictionary<string, object>;
                bus.AddDiscount(discount["title"] as string, discount["desc"] as string);

            }

            // Check to see if the business has a deal...
            if (business.ContainsKey("megadeal"))
            {
                Dictionary<string, object> deal = business["megadeal"] as Dictionary<string, object>;
                bus.AddDeal(deal["title"] as string, deal["desc"] as string);
            }

            if (business.ContainsKey("hasAd"))
                bus.hasAd = Convert.ToBoolean(business["hasAd"]);

            // Get the X, Z coordinates.
            if (business.ContainsKey("locs"))
            {
                foreach (Dictionary<string, object> coords in (IList)business["locs"])
                {
                    try
                    {
                        bus.xPos = (float) Convert.ToDouble(coords["x"]);
                        bus.zPos = (float) Convert.ToDouble(coords["z"]);
                        busPos.x = bus.xPos;
                        busPos.y = bus.zPos;
                    }
                    catch (KeyNotFoundException)
                    {
                        busPos.x = -1;
                        busPos.y = -1;
                    }

                    if (!busByCoord.ContainsKey(busPos))
                    {
                        busByCoord[busPos] = new List<Business>();
                    }

                    busByCoord[busPos].Add(bus);
                }
            }


            // All arrays in JSON come in as List<object>.
            foreach (string category in business["cats"] as List<object>)
            {
                // If the category does not exist, we need to create it...
                if (!businessesByCategory.ContainsKey(category))
                    businessesByCategory.Add(category, new List<Business>());
                // Add the business to the category it belongs to.
                businessesByCategory[category].Add(bus);
            }
        }
//.........这里部分代码省略.........
开发者ID:uvcteam,项目名称:univercity3d_uofo,代码行数:101,代码来源:BusinessManager.cs


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