当前位置: 首页>>代码示例>>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;未经允许,请勿转载。