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


C# StorageType.ToString方法代码示例

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


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

示例1: AddItem

        public bool AddItem(Player player, StorageType type, KeyValuePair<int, StorageItem> kvp)
        {
            string cmdString = "SELECT * FROM inventory WHERE PlayerId=?pid AND ItemId=?itemid AND Slot=?slot";
            MySqlCommand command = new MySqlCommand(cmdString, InvenDAOConnection);
            command.Parameters.AddWithValue("?pid", player.Id);
            command.Parameters.AddWithValue("?itemid", kvp.Value.ItemId);
            command.Parameters.AddWithValue("?slot", kvp.Key);
            MySqlDataReader reader = command.ExecuteReader();
            bool isExists = reader.HasRows;
            reader.Close();

            if (!isExists)
            {
                cmdString = "INSERT INTO inventory "
                + "(`AccountName`,`PlayerId`,`ItemId`,`Amount`,`Color`,`Slot`,`StorageType`) "
                + "VALUES (?aname, ?pid, ?itemid, ?count, ?color, ?slot, ?type); SELECT LAST_INSERT_ID();";
                command = new MySqlCommand(cmdString, InvenDAOConnection);
                command.Parameters.AddWithValue("?aname", player.AccountName);
                command.Parameters.AddWithValue("?pid", player.Id);
                command.Parameters.AddWithValue("?itemid", kvp.Value.ItemId);
                command.Parameters.AddWithValue("?count", kvp.Value.Count);
                command.Parameters.AddWithValue("?color", kvp.Value.Color);
                command.Parameters.AddWithValue("?slot", kvp.Key);
                command.Parameters.AddWithValue("?type", type.ToString());
            }
            else
            {
                cmdString = "UPDATE inventory SET "
                + "`Amount`=?count,`Color`=?color,`Slot`=?slot,`StorageType`=?type WHERE `ItemId`=?itemid AND `PlayerId`=?pid";
                command = new MySqlCommand(cmdString, InvenDAOConnection);
                command.Parameters.AddWithValue("?count", kvp.Value.Count);
                command.Parameters.AddWithValue("?color", kvp.Value.Color);
                command.Parameters.AddWithValue("?slot", kvp.Key);
                command.Parameters.AddWithValue("?type", type.ToString());
                command.Parameters.AddWithValue("?itemid", kvp.Value.ItemId);
                command.Parameters.AddWithValue("?pid", player.Id);
            }

            try
            {
                command.ExecuteNonQuery();
                return true;
            }
            catch (MySqlException ex)
            {
                Log.ErrorException("AddItem Error", ex);
            }

            return false;
        }
开发者ID:ZettaZero,项目名称:TeraEmulator,代码行数:50,代码来源:InventoryDAO.cs

示例2: AddItem

        public bool AddItem(Player player, StorageType type, KeyValuePair<int, StorageItem> KeyVP)
        {
            string SQL = "INSERT INTO `inventory` "
                    + "(`accountname`, `playerid`, `itemid`, `amount`, `color`, `slot`, `storagetype`) "
                    + "VALUES(?accountname, ?pid, ?itemid, ?count, ?color, ?slot, ?type);";
            MySqlCommand cmd = new MySqlCommand(SQL, InventoryDAOConnection);
            cmd.Parameters.AddWithValue("?accountname", player.AccountName);
            cmd.Parameters.AddWithValue("?pid", player.pid);
            cmd.Parameters.AddWithValue("?itemid", KeyVP.Value.ItemId);
            cmd.Parameters.AddWithValue("?count", KeyVP.Value.Count);
            cmd.Parameters.AddWithValue("?color", KeyVP.Value.Color);
            cmd.Parameters.AddWithValue("?slot", KeyVP.Key);
            cmd.Parameters.AddWithValue("?type", type.ToString());

            try
            {
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception e)
            {
                Log.ErrorException("DAO: ADD ITEM ERROR!", e);
            }

            return false;
        }
开发者ID:uebari,项目名称:TeraEmulatorDev,代码行数:26,代码来源:InventoryDAO.cs

示例3: LoadStorage

        public Storage LoadStorage(Player player, StorageType type)
        {
            string SQL = "SELECT * FROM `inventory` WHERE "
                + "`playerid` = ?pid AND `storagetype` = ?type";
            MySqlCommand cmd = new MySqlCommand(SQL, InventoryDAOConnection);
            cmd.Parameters.AddWithValue("?pid", player.Id);
            cmd.Parameters.AddWithValue("?type", type.ToString());
            MySqlDataReader LoadStorageReader = cmd.ExecuteReader();

            var storage = new Storage { StorageType = StorageType.Inventory };
            if (LoadStorageReader.HasRows)
            {
                while (LoadStorageReader.Read())
                {
                    if (LoadStorageReader.GetInt32(2) != 20000000)
                    {
                        StorageItem item = new StorageItem()
                        {
                            ItemId = LoadStorageReader.GetInt32(2),
                            Amount = LoadStorageReader.GetInt32(3),
                            Color = LoadStorageReader.GetInt32(4),
                        };

                        storage.Items.Add(LoadStorageReader.GetInt32(5), item);
                    }
                    else
                    {
                        storage.Money = LoadStorageReader.GetInt32(3);
                    }
                }
            }
            LoadStorageReader.Close();

            return storage;
        }
开发者ID:arkanoid1,项目名称:Temu,代码行数:35,代码来源:InventoryDAO.cs

示例4: CreateStorage

 /// <summary>
 /// Creates a storage of specified type using metadata information of enumeration value.
 /// </summary>
 /// <param name="st">Type of storage to create.</param>
 /// <param name="storageStr">Connection string or file path for data storage.</param>
 /// <returns>Newly created storage.</returns>
 public static AbstractResultStorage CreateStorage(StorageType st, string storageStr)
 {
     Type[] patametersType = { typeof(String) };
     object[] invokeParameters = { storageStr };
     StorageTypeInfo[] info = (StorageTypeInfo[])st.GetType().GetField(st.ToString()).GetCustomAttributes(typeof(StorageTypeInfo), false);
     Type t = Type.GetType(info[0].Implementation, true);
     return (AbstractResultStorage)t.GetConstructor(patametersType).Invoke(invokeParameters);
 }
开发者ID:kocharyan-ani,项目名称:random_networks_explorer,代码行数:14,代码来源:AbstractResultStorage.cs

示例5: LoadStorage

        public Dictionary<int, StorageItem> LoadStorage(Player player, StorageType type)
        {
            string cmdString = "SELECT * FROM inventory WHERE PlayerId=?id AND StorageType=?type";
            MySqlCommand command = new MySqlCommand(cmdString, InvenDAOConnection);
            command.Parameters.AddWithValue("?id", player.Id);
            command.Parameters.AddWithValue("?type", type.ToString());
            MySqlDataReader reader = command.ExecuteReader();

            Dictionary<int, StorageItem> items = new Dictionary<int, StorageItem>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    StorageItem item = new StorageItem()
                    {
                        ItemId = reader.GetInt32(3),
                        Count = reader.GetInt32(4),
                        Color = reader.GetInt32(5),
                    };
                    items.Add(reader.GetInt32(6), item);
                }
            }
            reader.Close();

            return items;
        }
开发者ID:ZettaZero,项目名称:TeraEmulator,代码行数:26,代码来源:InventoryDAO.cs

示例6: ParameterConditionalDBExists

 public ParameterConditionalDBExists(Parameter compared, StorageType storage)
     : base(compared, WarningType.INVALID_VALUE)
 {
     this.storage = storage;
     this.description = storage.ToString() + " doesn't exist";
 }
开发者ID:armano2,项目名称:VisualSAIStudio,代码行数:6,代码来源:ParameterConditional.cs

示例7: Put

        public FooResponse Put(string blobID, StorageType type)
        {
            using (var fooCDN = new HttpClient())
            {
                fooCDN.BaseAddress = _baseUri;
                fooCDN.DefaultRequestHeaders.Accept.Clear();

                HttpContent empty = new StringContent("");
                empty.Headers.Add("Content-Length", "0");

                HttpResponseMessage response = fooCDN.PutAsync("/api/content/" + blobID + "?type=" + type.ToString(), empty).Result;

                FooResponse fooResult = new FooResponse()
                {
                    StatusCode = response.StatusCode
                };
                var x = response.IsSuccessStatusCode;
                return fooResult;
            }
        }
开发者ID:Rumel,项目名称:Radabite,代码行数:20,代码来源:FooCDNAccessor.cs

示例8: ChooseRowFromDBForm

 public ChooseRowFromDBForm(StorageType storage)
 {
     InitializeComponent();
     data = DB.GetInstance().GetStringDictionary(storage);
     this.Text = "Select " + storage.ToString().ToLower();
 }
开发者ID:Jeidai,项目名称:VisualSAIStudio,代码行数:6,代码来源:ChooseRowFromDBForm.cs


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