當前位置: 首頁>>代碼示例>>C#>>正文


C# EnumConverter.ConvertToString方法代碼示例

本文整理匯總了C#中System.ComponentModel.EnumConverter.ConvertToString方法的典型用法代碼示例。如果您正苦於以下問題:C# EnumConverter.ConvertToString方法的具體用法?C# EnumConverter.ConvertToString怎麽用?C# EnumConverter.ConvertToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.EnumConverter的用法示例。


在下文中一共展示了EnumConverter.ConvertToString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AnimationCurveToString

 private static string AnimationCurveToString(object value)
 {
     if (value == null)
     {
         return string.Empty;
     }
     AnimationCurve curve = (AnimationCurve) value;
     StringBuilder builder = new StringBuilder();
     EnumConverter converter = new EnumConverter(typeof(WrapMode));
     builder.AppendFormat("{0}\n{1}", converter.ConvertToString(curve.postWrapMode), converter.ConvertToString(curve.preWrapMode));
     foreach (Keyframe keyframe in curve.keys)
     {
         object[] args = new object[] { InvStr(keyframe.inTangent), InvStr(keyframe.outTangent), InvStr(keyframe.time), InvStr(keyframe.value) };
         builder.AppendFormat("\n{0}, {1}, {2}, {3}", args);
     }
     return builder.ToString();
 }
開發者ID:CarlosHBC,項目名稱:UnityDecompiled,代碼行數:17,代碼來源:AnimationCurveTypeConverter.cs

示例2: Serialize

 public override object Serialize(IDesignerSerializationManager manager, object value)
 {
     CodeExpression left = null;
     using (CodeDomSerializerBase.TraceScope("EnumCodeDomSerializer::Serialize"))
     {
         Enum[] enumArray;
         if (!(value is Enum))
         {
             return left;
         }
         bool flag = false;
         TypeConverter converter = TypeDescriptor.GetConverter(value);
         if ((converter != null) && converter.CanConvertTo(typeof(Enum[])))
         {
             enumArray = (Enum[]) converter.ConvertTo(value, typeof(Enum[]));
             flag = enumArray.Length > 1;
         }
         else
         {
             enumArray = new Enum[] { (Enum) value };
             flag = true;
         }
         CodeTypeReferenceExpression targetObject = new CodeTypeReferenceExpression(value.GetType());
         TypeConverter converter2 = new EnumConverter(value.GetType());
         foreach (Enum enum2 in enumArray)
         {
             string str = (converter2 != null) ? converter2.ConvertToString(enum2) : null;
             CodeExpression right = !string.IsNullOrEmpty(str) ? new CodeFieldReferenceExpression(targetObject, str) : null;
             if (right != null)
             {
                 if (left == null)
                 {
                     left = right;
                 }
                 else
                 {
                     left = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.BitwiseOr, right);
                 }
             }
         }
         if ((left != null) && flag)
         {
             left = new CodeCastExpression(value.GetType(), left);
         }
     }
     return left;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:47,代碼來源:EnumCodeDomSerializer.cs

示例3: Main

        static void Main(string[] args)
        {
            Console.WriteLine("使用 EnumConverter ");
            {
                EnumConverter converter = new EnumConverter(typeof(ProgrammingLanguage));

                // 將字符串轉換為枚舉.
                string langStr = "CS, Cpp, XAML";
                Console.WriteLine("將字符串 \"{0}\" 轉換為枚舉...", langStr);
                ProgrammingLanguage lang = (ProgrammingLanguage)converter.ConvertFromString(langStr);
                Console.WriteLine("完成!");

                // 將枚舉轉換為字符串.
                Console.WriteLine("將枚舉結果轉換為字符串...");
                langStr = converter.ConvertToString(lang);
                Console.WriteLine("完成! \"{0}\"", langStr);
            }

            Console.WriteLine("\n使用 EnumDescriptionConverter ");
            {
                EnumDescriptionConverter converter = new EnumDescriptionConverter(
                    typeof(ProgrammingLanguage));

                // 將枚舉轉換為字符串.
                string langStr = "Visual C#, Visual C++, XAML";
                Console.WriteLine("將字符串 \"{0}\" 轉換為枚舉...", langStr);
                ProgrammingLanguage lang = (ProgrammingLanguage)converter.ConvertFromString(langStr);
                Console.WriteLine("完成!");

                // 將枚舉轉換為字符串.
                Console.WriteLine("將枚舉結果轉換為字符串...");
                langStr = converter.ConvertToString(lang);
                Console.WriteLine("完成! \"{0}\"", langStr);
            }

            Console.ReadLine();
        }
開發者ID:zealoussnow,項目名稱:OneCode,代碼行數:37,代碼來源:Program.cs

示例4: Save

        internal void Save(XmlWriter writer)
        {
            writer.WriteStartElement("thumbnail");

              SizeConverter sizeConv = new SizeConverter();

              writer.WriteStartElement("size");
              writer.WriteAttributeString("value", sizeConv.ConvertToString(size));
              writer.WriteEndElement();

              EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode));

              writer.WriteStartElement("interpolationMode");
              writer.WriteAttributeString("value", ipConv.ConvertToString(interpolationMode));
              writer.WriteEndElement();

              ColorConverter colorConv = new ColorConverter();

              writer.WriteStartElement("backColor");
              writer.WriteAttributeString("value", colorConv.ConvertToString(backColor));
              writer.WriteEndElement();

              EnumConverter priorityConv = new EnumConverter(typeof(ThreadPriority));

              writer.WriteStartElement("threadPriority");
              writer.WriteAttributeString("value", priorityConv.ConvertToString(threadPriority));
              writer.WriteEndElement();

              writer.WriteEndElement();
        }
開發者ID:hazychill,項目名稱:oog,代碼行數:30,代碼來源:ThumbnailSetting.cs

示例5: Save

        internal void Save(XmlWriter writer)
        {
            writer.WriteStartElement("fullScreenViewer");

              ResizerConverter rsConv = new ResizerConverter();

              writer.WriteStartElement("resizer");
              writer.WriteAttributeString("value", (string)rsConv.ConvertTo(null, null, resizer, typeof(string)));
              writer.WriteEndElement();

              EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode));

              writer.WriteStartElement("interpolationMode");
              writer.WriteAttributeString("value", ipConv.ConvertToString(interpolationMode));
              writer.WriteEndElement();

              ColorConverter colorConv = new ColorConverter();

              writer.WriteStartElement("backColor");
              writer.WriteAttributeString("value", colorConv.ConvertToString(backColor));
              writer.WriteEndElement();

              writer.WriteEndElement();
        }
開發者ID:hazychill,項目名稱:oog,代碼行數:24,代碼來源:FullScreenViewerSettings.cs


注:本文中的System.ComponentModel.EnumConverter.ConvertToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。