コード例 #1
0
ファイル: DefaultProvider.cs プロジェクト: vildar82/AcadLib
        // ReSharper disable once UnusedParameter.Global
        public virtual T GetDefault(DefaultUsage usage)
        {
            var t = typeof(T);

            if (t.IsPrimitive || t.IsEnum)
            {
                return(default);
コード例 #2
0
        /// <summary>
        /// Returns a default value for the Key or Value properties for new dictionary entries
        /// </summary>
        /// <param name="usage">Specifies if the desired default value is to be used as Key or Value</param>
        /// <returns>Returns a value of type T to be used as the default</returns>
        /// <remarks>If the default value is to be used as Key it may NOT be null (because the Dictionary doesn't allow null as Key)</remarks>
        public virtual T GetDefault(DefaultUsage usage)
        {
            Type t = typeof(T);

            if (t.IsPrimitive || t.IsEnum)
            {
                return(default(T));
            }
            else if (t == typeof(string))
            {
                return((T)(object)String.Empty);
            }
            else
            {
                return(Activator.CreateInstance <T>());
            }
        }
コード例 #3
0
 public override int GetDefault(DefaultUsage usage)
 {
     // The mother of all numbers
     return(42);
 }
コード例 #4
0
 public override Color GetDefault(DefaultUsage usage)
 {
     // we want red as default color!
     return(Color.Red);
 }
コード例 #5
0
ファイル: GameObject.cs プロジェクト: thinhbocrazy/NMGAME
 public override string GetDefault(DefaultUsage usage)
 {
     return("0");
 }