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


C# UnitType.ToString方法代码示例

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


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

示例1: createNewUnit

    // ------------------------------------------------------------------------------------ //
    public static UnitBase createNewUnit(UnitType unitType)
    {
        GameObject unitGameObject = new GameObject ("Unit" + unitType.ToString());
        unitGameObject.tag = UnitBase.UNIT_TAG;

        UnitBase unitBase = null;

        if (unitType == UnitType.ZombieSober) {
            unitBase = unitGameObject.AddComponent<UnitZombieSober>();
        }
        else if (unitType == UnitType.ZombieDrunk) {
            unitBase = unitGameObject.AddComponent<UnitZombieDrunk>();
        }
        else if (unitType == UnitType.ManDrunk) {
            unitBase = unitGameObject.AddComponent<UnitManDrunk>();
        }
        else {
            SLog.logError("UnitFactory createNewUnit(): unknown type == " + unitType.ToString());
        }

        if (unitBase != null)
        {
            unitBase.setUnitType(unitType);
            unitBase.initialize();
        }

        return unitBase;
    }
开发者ID:YuriyKokosha,项目名称:ZombieSmash,代码行数:29,代码来源:UnitFactory.cs

示例2: Extract

        public override System.Data.DataTable Extract(UnitType source, int year, int id, string column, 
            bool addTimeColumn = false, bool forValidation = true)
        {
            if (source == UnitType.WATER)
                throw new Exception("ExtractSWAT_Text_Database doesn't support " + source.ToString());

            DataTable finalTable = null;
            //if (_interval == OutputIntervalType.DAY && source == UnitType.HRU) //record-by-record reading for daily HRU outputs to avoid out of memory
            //{
            //    finalTable = extractDailyHRU(column);
            //}
            //else
            //{
                //read the whole table if necessary
                DataTable wholeTable = getWholeTable(source, year != -1);

                DateTime startTime = DateTime.Now;
                _extractTime = -99.0;

                //select the request data from the whole table
                //Console.WriteLine(string.Format("Query data for {0}_{1}_{2}", source,id,column));
                DataView view = new DataView(wholeTable);
                string filter = "";
                if (id > 0) filter = string.Format("{0} = {1}", source, id);           //filter for certain id and remove the year summary,this is not good for yearly output
                if (_interval == OutputIntervalType.DAY || _interval == OutputIntervalType.MON)
                {
                    if (!string.IsNullOrWhiteSpace(filter)) filter += " and ";
                    filter += COLUMN_NAME_MON_SWAT + " <= 366";
                }
                if (year != -1)
                {
                    if (!string.IsNullOrWhiteSpace(filter)) filter += " and ";
                    filter += string.Format("{0} >= #{1}-01-01# and {0} < #{2}-01-01#", COLUMN_NAME_TIME, year,year + 1);
                }
                view.RowFilter = filter;

                string timeCol = COLUMN_NAME_MON_SWAT;
                DataTable queryTable = null;
                if (id > 0)
                    queryTable = view.ToTable(false, new string[] { timeCol, column });                     //time and value
                else
                    queryTable = view.ToTable(false, new string[] { timeCol, source.ToString(), column }); //output id when all ids is outputs
                finalTable = queryTable;

                if (finalTable == null || finalTable.Rows.Count == 0)
                    throw new Exception("No results!");

                //add time if necessary
                //don't do this on the whole dataset any more
                if (addTimeColumn && year == -1) calculateDate(finalTable);

            //}
            _extractTime = DateTime.Now.Subtract(startTime).TotalMilliseconds;
            return finalTable;
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:55,代码来源:ExtractSWAT_Text_Database.cs

示例3: Compare

        public double Compare(UnitType source)
        {
            //System.Diagnostics.Debug.WriteLine("------------------" + source.ToString() + "------------------");

            using(System.IO.StreamWriter file = new System.IO.StreamWriter(
                System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), source.ToString() + "_validation.txt")))
                {
                    string[] cols = ExtractSWAT_SQLite.GetSQLiteColumns(source);
                    if (cols == null) return -99.0;

                    double mean_R2 = 0;
                    int num_R2 = 0;
                    foreach (string col in cols)
                    {
                        double R2 = Compare(source, col,file);
                        if (R2 > -99)
                        {
                            mean_R2 += R2;
                            num_R2 += 1;
                        }
                    }

                    if (num_R2 > 0)
                        return mean_R2 / num_R2;
                    return -99.0;
                }
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:27,代码来源:SQLiteValidation.cs

示例4: Compare

        /// <summary>
        /// Compare outputs in text files and SQLite database for given SWAT unit
        /// </summary>
        /// <param name="source">SWAT unit type</param>
        /// <returns>Average R2</returns>
        /// <remarks>
        /// 1. R2 is calculated for each column
        /// 2. A text file would be created on desktop to record R2 for all columns
        /// </remarks>
        public double Compare(UnitType source)
        {
            using(StreamWriter file = new StreamWriter(
                Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), source.ToString() + "_" + _extractText.OutputInterval.ToString() + "_validation.txt")))
                {
                    string[] cols = ExtractSWAT_SQLite.GetSQLiteColumns(source);
                    if (cols == null) return -99.0;

                    double mean_R2 = 0;
                    int num_R2 = 0;
                    foreach (string col in cols)
                    {
                        double R2 = Compare(source, col,file);
                        if (R2 > -99)
                        {
                            mean_R2 += R2;
                            num_R2 += 1;
                        }
                    }

                    if (num_R2 > 0)
                        return mean_R2 / num_R2;
                    return -99.0;
                }
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:34,代码来源:SQLiteValidation2.cs

示例5: createNewUnit

    // ------------------------------------------------------------------------------------ //
    public static UnitBase createNewUnit(UnitType unitType)
    {
        GameObject unitGameObject = Instantiate (ResourcesBase.load("Prefabs/UI/Plane", true)) as GameObject;

        unitGameObject.name = "Unit" + unitType.ToString();
        unitGameObject.tag = UnitBase.UNIT_TAG;

        UnitBase unitBase = null;

        if (unitType == UnitType.Dog) {
            unitBase = unitGameObject.AddComponent<UnitDog>();
        }
        else if (unitType == UnitType.Pony) {
            unitBase = unitGameObject.AddComponent<UnitPony>();
        }
        else {
            SLog.logError("UnitFactory createNewUnit(): unknown type == " + unitType.ToString());
            return null;
        }

        unitBase.initialize();

        return unitBase;
    }
开发者ID:YuriyKokosha,项目名称:PonyGame,代码行数:25,代码来源:UnitFactory.cs

示例6: getRecordType

 /// <summary>
 /// Get the record type based on given SAWT unit type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private Type getRecordType(UnitType type)
 {
     switch (type)
     {
         case UnitType.HRU: return typeof(SWATHRU);
         case UnitType.RCH: return typeof(SWATReach);
         case UnitType.RSV: return typeof(SWATReservoir);
         case UnitType.SUB: return typeof(SWATSub);
         default:
             throw new Exception("Doesn't support " + type.ToString());
     }
 }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:17,代码来源:ExtractSWAT_Text_FileHelperEngine.cs

示例7: ConvertType

    /// <summary>
    /// Converts an existing object from one unit into another unit type.
    /// </summary>
    public void ConvertType(UnitType type)
    {
      if (this.type == type)
        return;

      if (!Enum.IsDefined(typeof(UnitType), type))
        throw new ArgumentException(DomSR.InvalidUnitType(type.ToString()));

      switch (type)
      {
        case UnitType.Centimeter:
          this.value = (float)this.Centimeter;
          this.type = UnitType.Centimeter;
          break;

        case UnitType.Inch:
          this.value = (float)this.Inch;
          this.type = UnitType.Inch;
          break;

        case UnitType.Millimeter:
          this.value = (float)this.Millimeter;
          this.type = UnitType.Millimeter;
          break;

        case UnitType.Pica:
          this.value = (float)this.Pica;
          this.type = UnitType.Pica;
          break;

        case UnitType.Point:
          this.value = (float)this.Point;
          this.type = UnitType.Point;
          break;

        default:
          //Remember missing unit type!!!
          Debug.Assert(false, "Missing unit type");
          break;
      }
    }
开发者ID:GorelH,项目名称:PdfSharp,代码行数:44,代码来源:Unit.cs

示例8: getNumberOfUnit

        private int getNumberOfUnit(UnitType type)
        {
            string outputFileName = string.Format("output.{0}",type.ToString().ToLower());
            string outputFile = getFilePath(outputFileName);
            if (!File.Exists(outputFile)) return 0;

            using (StreamReader sr = new StreamReader(outputFile))
            {
                for (int i = 1; i <= 9; i++) sr.ReadLine(); //ignore first 9 lines
                int previousID = -1;
                string line = "";

                //get the start index and length of id in output file
                int startIndex = 4; //for hru
                int idLength = 5;   //for hru
                if (type == UnitType.SUB)
                {
                    startIndex = 6;
                    idLength = 4;
                }
                else if (type == UnitType.RSV)
                {
                    startIndex = 3;
                    idLength = 11;
                }

                //start to read
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine();
                    int currentID = int.Parse(line.Substring(startIndex, idLength).Trim());
                    if (currentID < previousID) break;
                    else previousID = currentID;
                }
                return previousID;
            }
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:37,代码来源:ExtractSWAT_Text.cs

示例9: FormatLevelData

    private static string FormatLevelData(UnitType unitType, Era era)
    {
        string data = "";
        data += String.Format("{0,-20}", unitType.ToString());
        data += " ";
        data += String.Format("{0,-20}", era.ToString());
        data += " ";
        data += String.Format("{0,5}", mUnitLevels[(int) unitType, (int) era]);
        data += " ";
        data += String.Format("{0,5}", mUnitExperience[(int) unitType, (int) era]);

        return data;
    }
开发者ID:Chickenbottom,项目名称:CSS385_PowerOverwhelming,代码行数:13,代码来源:UnitStats.cs

示例10: Warn

        public override void Warn(string message, double value, UnitType unitType, string correlationId, Exception exception = null)
        {
            var logData = CreateLogData(message);
            logData.Level = Level.Warn;
            logData.Properties["correlationId"] = correlationId;
            logData.Properties["value"] = value;
            logData.Properties["unitType"] = unitType.ToString();

            if (exception != null)
                logData.Properties["exceptionMessage"] = exception.Message;

            SetEvent(logData);
        }
开发者ID:proactima,项目名称:UXRiskLogger,代码行数:13,代码来源:Log4NetLogger.cs

示例11: GrabSummonUnit

    private UnitEntity GrabSummonUnit(UnitType unitType)
    {
        UnitEntity ent = null;
        //check if it's safe to summon on the spot
        Vector2 pos = transform.position;
        pos += Random.insideUnitCircle * radius;
        if(!Physics.CheckSphere(pos, checkRadius, checkLayer.value)) {
            string typeName = unitType.ToString();
            ent = EntityBase.Spawn<UnitEntity>(spawnGroup, typeName, pos);
        }

        return ent;
    }
开发者ID:ddionisio,项目名称:1GAM_01_Aries,代码行数:13,代码来源:SummonController.cs

示例12: getSQL

        /// <summary>
        /// Get SQL for data query
        /// </summary>
        /// <param name="requestStartYear"></param>
        /// <param name="requestFinishYear"></param>
        /// <param name="source"></param>
        /// <param name="id"></param>
        /// <param name="var"></param>
        /// <returns></returns>
        /// <remarks>Still have no way to remove the average annual outputs for monthly and yearly HRU, subbain and reach</remarks>
        private string getSQL(int requestStartYear, int requestFinishYear,
            UnitType source, int id, string var)
        {
            //columns
            string cols = COLUMN_NAME_MON_SWAT + "," + var;
            if (var.Equals("*")) cols = "*";

            //get table
            string table = TEXT_FILE_NAME_SUB;
            if (source == UnitType.HRU)
                table = TEXT_FILE_NAME_HRU;
            else if (source == UnitType.RCH)
                table = TEXT_FILE_NAME_RCH;

            table += "_" + _interval.ToString().ToLower() + ".txt";

            string col_id = source.ToString();

            //id, for wtr is not correct
            string idCondition = "";
            if (id > 0) idCondition = string.Format("{0}={1}", col_id, id);

            //year condition
            if (requestStartYear < _startYear) requestStartYear = _startYear;
            if (requestFinishYear > _endYear || requestFinishYear < _startYear) requestFinishYear = _endYear;
            string yearCondition = "";
            if (requestStartYear != _startYear || requestFinishYear != _endYear)
            {
                if (requestStartYear == requestFinishYear)
                    yearCondition = string.Format("YEAR({0}) = {1}", COLUMN_NAME_TIME, requestStartYear);
                else
                    yearCondition = string.Format("YEAR({2}) >= {0} AND YEAR({2}) <= {1}", requestStartYear, requestFinishYear, COLUMN_NAME_TIME);
            }

            string extraRecordCondition = "";
            if (_interval == OutputIntervalType.DAY || _interval == OutputIntervalType.MON)
                extraRecordCondition = "MON <= 366";

            string where = "";
            if (!string.IsNullOrWhiteSpace(idCondition))
                where = idCondition;
            if (!string.IsNullOrWhiteSpace(yearCondition))
            {
                if (!string.IsNullOrWhiteSpace(where))
                    where += " and ";
                where += yearCondition;
            }
            if (!string.IsNullOrWhiteSpace(extraRecordCondition))
            {
                if (!string.IsNullOrWhiteSpace(where))
                    where += " and ";
                where += extraRecordCondition;
            }

            string query = string.Format("select {0} from {1}", cols, table);
            if (!string.IsNullOrWhiteSpace(where)) query += " where " + where;

            return query;
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:69,代码来源:ExtractSWAT_Text_FileDriver.cs

示例13: ConvertType

        /// <summary>
        /// Converts an existing object from one unit into another unit type.
        /// </summary>
        public void ConvertType(UnitType type)
        {
            if (_type == type)
                return;

            switch (type)
            {
                case UnitType.Centimeter:
                    _value = (float)Centimeter;
                    _type = UnitType.Centimeter;
                    break;

                case UnitType.Inch:
                    _value = (float)Inch;
                    _type = UnitType.Inch;
                    break;

                case UnitType.Millimeter:
                    _value = (float)Millimeter;
                    _type = UnitType.Millimeter;
                    break;

                case UnitType.Pica:
                    _value = (float)Pica;
                    _type = UnitType.Pica;
                    break;

                case UnitType.Point:
                    _value = (float)Point;
                    _type = UnitType.Point;
                    break;

                default:
                    if (!Enum.IsDefined(typeof(UnitType), type))
                        throw new ArgumentException(DomSR.InvalidUnitType(type.ToString()));

                    // Remember missing unit type.
                    Debug.Assert(false, "Missing unit type");
                    break;
            }
        }
开发者ID:Sl0vi,项目名称:MigraDoc,代码行数:44,代码来源:Unit.cs

示例14: getWholeTable

        protected DataTable getWholeTable(UnitType source, bool needCalculateDate)
        {
            if (!_wholeTables.ContainsKey(source)) //read the whole table first
            {
                //record the whole table loading time
                DateTime startTime = DateTime.Now;
                _prepareTime = -99.0;

                //read the table
                DataTable dt = readWholeTable(source);
                if (needCalculateDate) calculateDate(dt);

                //get the whole table loading time
                _prepareTime = DateTime.Now.Subtract(startTime).TotalMilliseconds;

                //add to cache
                dt.TableName = source.ToString();
                _wholeTables.Add(source, dt);
            }
            return _wholeTables[source];
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:21,代码来源:ExtractSWAT_Text_Database.cs

示例15: Debug

        public override void Debug(string message, double value, UnitType unitType, Exception exception = null)
        {
            var logData = CreateLogData(message);
            logData.Level = Level.Debug;
            logData.Properties["value"] = value;
            logData.Properties["unitType"] = unitType.ToString();

            if (exception != null)
                logData.Properties["exceptionMessage"] = exception.Message;

            SetEvent(logData);
        }
开发者ID:proactima,项目名称:UXRiskLogger,代码行数:12,代码来源:Log4NetLogger.cs


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