コード例 #1
0
    private void Update()
    {
        if (bomRuim.ToString() == "ruim")
        {
            if (interagiu)
            {
                if (this.gameObject.name == "LavarPrato")
                {
                    listras[3].SetActive(true);
                    listras[4].SetActive(true);
                }

                if (this.gameObject.name == "TomarBanho")
                {
                    listras[0].SetActive(true);
                }

                if (this.gameObject.name == "LavarMão")
                {
                    listras[1].SetActive(true);
                    listras[2].SetActive(true);
                }

                interagiu = false;
                if (aux == 0)
                {
                    barsBerraviour.PerderBarra(1, 50);
                    barsBerraviour.GanharBarra(0, 10);
                    aux++;
                }
                animBool = true;
            }
        }

        if (bomRuim.ToString() == "bom")
        {
            if (interagiu)
            {
                interagiu = false;
                if (aux == 0)
                {
                    if (eletronico)
                    {
                        barsBerraviour.GanharBarra(1, 35);
                        aux++;
                    }
                    if (naoEletronico)
                    {
                        barsBerraviour.GanharBarra(1, 15);
                        aux++;
                    }
                }
                animBool = true;
            }
        }
        aux = 0;
        this.GetComponent <Animator>().SetBool("done", animBool);
    }
コード例 #2
0
 private static void m1(MyEnum n)
 {
     if ((n & MyEnum.b) == MyEnum.b)
     {
         Console.WriteLine("n: {0}", n.ToString("X"));
     }
     else
     {
         Console.WriteLine("Error n: {0}", n.ToString("X"));
     }
 }
コード例 #3
0
 private static void m2(MyEnum n)
 {
     if ((n & (MyEnum.a | MyEnum.b)) != 0)
     {
         Console.WriteLine("n: {0}", n.ToString("X"));
     }
     else
     {
         Console.WriteLine("Error n: {0}", n.ToString("X"));
     }
 }
コード例 #4
0
    public static MyEnum StringToMyEnum(string enumVal, MyEnum defaultValue)
    {
        MyEnum res = defaultValue;

        if (enumVal != null)
        {
#if !WORKAROUND
            try {
                if (Enum.IsDefined(typeof(MyEnum), enumVal))
                {
                    res = (MyEnum)Enum.Parse(typeof(MyEnum), enumVal, true);
                }
            } catch (Exception e) {
                Debug.LogError("Couldn't convert enum string '" + enumVal + " to MyEnum enum: " + e.Message);
            }
            else
            {
                // UNITY_FLASH workaround
                // Enum not well supported in Unity 4.0.0
                for (int i = 0; i < (int)MyEnum.Max; i++)
                {
                    MyEnum L = (MyEnum)i;
                    if (L.ToString() == enumVal)
                    {
                        res = L;
                        break;
                    }
                }
            }
#endif
        }
コード例 #5
0
 private void encounterSelector()
 {
     if (Encounter.ToString() == "Skeleted")
     {
         Skeleton();
     }
 }
コード例 #6
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     string[] data = getenum.ToString().Split('_');
     frameContainer.Navigate(new Uri(data[0] + "/" + data[1] + ".xaml", UriKind.RelativeOrAbsolute));
     btnNext.IsEnabled = true;
     btnPrev.IsEnabled = false;
 }
コード例 #7
0
 public static string ToDescriptionString(this MyEnum val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
コード例 #8
0
 public static string GetValue(this MyEnum key)
 {
     return typeof(MyEnum).GetField(key.ToString())
                          .GetCustomAttributes(typeof(DescriptionAttribute), false)
                          .Cast<DescriptionAttribute>()
                          .Single()
                          .Description;
 }
コード例 #9
0
ファイル: Person.cs プロジェクト: JohnFChas/OOP
        public void Test()
        {
            MyProp = MyEnum.Action;

            int input = 1;

            bool compare = MyProp == (MyEnum)input;

            Console.WriteLine("{0}: {1}", MyProp.ToString(), "Movie name");
        }
コード例 #10
0
        private void OnBtnClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            tbxDisplayContent.Text = button.Content.ToString();

            Debug.Assert(button.Tag is MyEnum);
            MyEnum tag = (MyEnum)button.Tag;

            tbxDisplayTag.Text = tag.ToString();
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Console.WriteLine(new string('_', 50));
            DateTime data  = new DateTime(2020, 2, 13);
            DateTime today = DateTime.Now;

            TimeSpan left = data - today;

            Console.WriteLine("до мой днем раждения осталось {0} день", left.Days);
            Console.WriteLine("до мой днем раждения осталось {0} час", left.TotalHours);
            Console.WriteLine(new string('_', 50));


            MyEnum my = MyEnum.one;

            Console.WriteLine("{0}-{1}", my, (int)my);
            Console.WriteLine(new string('_', 10));

            Type typemy = my.GetType(); //1

            Console.WriteLine(typemy);

            Type typemy1 = Enum.GetUnderlyingType(typemy); //2 //...enumi tareri typ@

            Console.WriteLine(typemy1);

            Console.WriteLine(Enum.GetUnderlyingType(typeof(MyEnum))); //3=2
            Console.WriteLine(typeof(MyEnum));                         //4=1

            Console.WriteLine(my.ToString());
            Console.WriteLine(Enum.Format(typeof(MyEnum), MyEnum.one, "X"));
            Console.WriteLine(Enum.Format(typeof(MyEnum), MyEnum.one, "D"));
            Console.WriteLine(Enum.Format(typeof(MyEnum), 2, "G"));

            Console.WriteLine(new string('_', 10));
            for (MyEnum number = MyEnum.zero; number <= MyEnum.tree; number++)
            {
                Console.WriteLine("{0}-{1}", number, (int)number);
            }
            Console.WriteLine(new string('_', 50));

            Array array = Enum.GetValues(typeof(MyEnum)); /// enum-i tarer@ qcum enq zangvaci mej

            Console.WriteLine("Array Lenght equal -{0}", array.Length);

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine("name const {0} a value {0:D}", array.GetValue(i));
            }
            Console.ReadKey();
        }
コード例 #12
0
 private void btnNext_Click(object sender, RoutedEventArgs e)
 {
     getenum = getenum + 1;
     string[] data = getenum.ToString().Split('_');
     frameContainer.Navigate(new Uri(data[0] + "/" + data[1] + ".xaml", UriKind.RelativeOrAbsolute));
     if (getenum == MyEnum.Configs_Settings)
     {
         btnNext.IsEnabled = false;
     }
     if (getenum == MyEnum.Commercial_ContactRole)
     {
         btnPrev.IsEnabled = true;
     }
 }
コード例 #13
0
    public static int Num(this MyEnum val)
    {
        int       n  = 0;
        FieldInfo fi = val.GetType().GetField(val.ToString());

        TestAttribute[] attrs =
            fi.GetCustomAttributes(typeof(TestAttribute),
                                   false) as TestAttribute[];
        if (attrs.Length > 0)
        {
            n = attrs[0].Num;
        }
        return(n);
    }
コード例 #14
0
ファイル: MyTests.cs プロジェクト: RudyMeijer/My
        public void EnumTest()
        {
            var expected = 1;
            var v        = (int)My.GetEnum <MyEnum>("Yes");

            Assert.IsTrue(v == 1, $"Invalid enum {v} should be {expected}");

            v = (int)My.GetEnum <MyEnum>("xxx");
            Assert.IsTrue(v == 0, $"Invalid enum {v} should be {expected}");

            MyEnum name = My.GetEnumByIndex <MyEnum>(1);

            Assert.IsTrue(name.ToString() == "Yes", $"Invalid enum {name} should be Yes.");
        }
コード例 #15
0
ファイル: EnumConverterTests.cs プロジェクト: naricc/runtime
        public static void MoreThan64EnumValuesToSerializeWithNamingPolicy()
        {
            var options = new JsonSerializerOptions
            {
                Converters = { new JsonStringEnumConverter(new ToLowerNamingPolicy()) }
            };

            for (int i = 0; i < 128; i++)
            {
                MyEnum value    = (MyEnum)i;
                string asStr    = value.ToString().ToLowerInvariant();
                string expected = char.IsLetter(asStr[0]) ? $@"""{asStr}""" : asStr;
                Assert.Equal(expected, JsonSerializer.Serialize(value, options));
            }
        }
コード例 #16
0
ファイル: Chap3.cs プロジェクト: neveand/study
    static void EnumTest()
    {
        MyEnum e = MyEnum.Farther;

        Console.WriteLine("Enum value : {0}", e.ToString());
        Console.WriteLine("Underlying Enum : {0}", Enum.GetUnderlyingType(e.GetType()));
        Array enumData = Enum.GetValues(e.GetType());

        for (int i = 0; i < enumData.Length; ++i)
        {
            object o     = enumData.GetValue(i);
            int    value = (int)o;
            Console.WriteLine("{0} = {1:D}", o.ToString(), value);
        }
        int value18 = 18;

        Console.WriteLine("int.ToString() = {0}", value18.ToString());
    }
コード例 #17
0
        public void TestEnum()
        {
            var options = new Options();
            var s       = OptionsReader.ReadOptions("/oe hello ", options);

            System.Diagnostics.Trace.TraceWarning(s);
            Assert.AreEqual(MyEnum.Hello, options.OkEnum);

            MyEnum em = MyEnum.Hello | MyEnum.World;

            System.Diagnostics.Debug.WriteLine(em.ToString());

            var em1 = (MyEnum)Enum.Parse(typeof(MyEnum), "Hello, World");

            Assert.AreEqual(em, em1);

            var em2 = (MyEnum)Enum.Parse(typeof(MyEnum), "Hello,World");

            Assert.AreEqual(em, em2);
        }
コード例 #18
0
        static void Main(string[] args)
        {
            MyEnum digit = MyEnum.Teeeeeeeeeeen;

            Console.WriteLine($"Число {digit.ToString()}");

            //Enum.Format() - позволяет производить более точное форматирование за счет указания флага,
            //а так же получать имена элементов перечисления по их числовым значениям

            //Вывод в 16-ричном формате. Флаг "х" - hex (16-ричный формат)
            Console.WriteLine($"Hex значение {Enum.Format(typeof(MyEnum),MyEnum.Teeeeeeeeeeen,"x")}");

            //Вывод в 10-ричном формате. Флаг "D" - dec (10-ричный формат)
            // вместо typeof(MyEnum) использую digit.GetType()
            Console.WriteLine($"Dec значение {Enum.Format(digit.GetType(), digit, "D")}");

            //Вывод в строковом формате. Флаг "G" - str (Строковой формат)
            Console.WriteLine($"Str значение {Enum.Format(typeof(MyEnum), 10, "G")}");

            //Delay
            Console.ReadKey();
        }
コード例 #19
0
 public override string ToString() => value.ToString();
コード例 #20
0
 // The enum value string need not case match.
 // Technically, this ought to be a "statement is always false" as lowercase first
 // will never match any MyEnum values.
 public void Match3(MyEnum e)
 {
     if (e.ToString() == "first")
     {
     }
 }
コード例 #21
0
        public void test()
        {
            MyEnum color = MyEnum.red;

            color.ToString();
        }
 // The enum value string need not case match.
 // Technically, this ought to be a "statement is always false" as lowercase first
 // will never match any MyEnum values.
 public void Match3(MyEnum e)
 {
     if (e.ToString() == "first") { }
 }
コード例 #23
0
 // The string is not one of the known enum values.
 public void NotMatch2(MyEnum e)
 {
     if (e.ToString() == "StringThatDoesn'tMatchTheEnumValue")
     {
     }
 }
コード例 #24
0
 // Simple case.
 public void Match1(MyEnum e, NotEnum ne)
 {
     if (e.ToString() == "First")
     {
     }
 }
コード例 #25
0
 public string MyMethod(MyEnum enm)
 {
     return("[" + enm.ToString() + "]");
 }
コード例 #26
0
 public override string ToString()
 {
     return("a=" + a.ToString() + ", b=" + b + ", c=" + c.ToString() + ", d=" + d.ToString() +
            ", e=" + e.ToString("F2"));
 }
コード例 #27
0
ファイル: Form1.cs プロジェクト: Cardman/tutorials
        public Hello()
        {
            InitializeComponent();
            //Class1 cl_ = new Class1();
            textBox3.Text = Convert.ToString(Class1.SayHello(1, 2));

            /*System.Type type_ = typeof(MyEnum);
             * Array array_ = type_.GetEnumValues();
             * foreach (object o in array_) {
             *  if (o.ToString() == "ONE")
             *  {
             *      textBox3.Text = o.ToString()+" "+o.GetType();
             *      break;
             *  }
             * }*/
            try
            {
                //Type type_ = Type.GetType("FirstGui.MyEnum");
                //textBox3.Text = type_.ToString();
                textBox3.Text = valueOf("FirstGui.MyEnum", "ONE").ToString();
                MyEnum myEnum_ = valueOf2 <MyEnum>(typeof(MyEnum), "TWO");
                textBox3.Text = myEnum_.ToString();
            }
            catch (Exception e)
            {
            }
            try
            {
                MyClassReflect myObject    = new MyClassReflect();
                Type           myType      = typeof(MyClassReflect);
                FieldInfo      myFieldInfo = myType.GetField("myField",
                                                             BindingFlags.NonPublic | BindingFlags.Instance);
                textBox3.AppendText("\r\nold:" + myFieldInfo.GetValue(myObject).ToString());
                myFieldInfo.SetValue(myObject, 6);
                textBox3.AppendText("\r\nnew:" + myFieldInfo.GetValue(myObject).ToString());
            }
            catch (Exception e)
            {
                textBox3.AppendText("\r\n" + e.ToString());
            }
            try
            {
                MyClassReflect myObject = new MyClassReflect();
                Type           myType   = typeof(MyClassReflect);
                //ConstructorInfo const_ = myType.GetConstructor(new Type[] { typeof(String) });
                ConstructorInfo constructorInfoObj = myType.GetConstructor(
                    BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(String) }, null);
                object    obj_        = constructorInfoObj.Invoke(new String[] { "7" });
                FieldInfo myFieldInfo = myType.GetField("myField",
                                                        BindingFlags.NonPublic | BindingFlags.Instance);
                textBox3.AppendText("\r\ninit:" + myFieldInfo.GetValue(obj_).ToString());
            }
            catch (Exception e)
            {
                textBox3.AppendText("\n" + e.ToString());
            }
            //myObject.setF(6);
            //MyEnum.
            //MessageBox.Show("du texte");
            try
            {
                // Create an XML document instance.
                // The same instance of DOM is used through out this code; this
                // may or may not be the actual case.
                XmlDocument doc = new XmlDocument();

                // Load the XML data from a file.
                // This code assumes that the XML file is in the same folder.
                ///doc.Load("Q317662.xml");

                // Load the XML data from a file stream.
                // You can also use other I/O streams in the same way with the
                // Load method.
                ///FileStream fileStrm = new FileStream("Q317662.xml", FileMode.Open);
                // New content replaces older content because the same DOM is
                // used.
                ///doc.Load(fileStrm);
                // Use DOM to manipulate the XML data here.
                // Close any Streams once they are used.
                ///fileStrm.Close();

                // Load the XML data from a URL.
                // Make sure that the URL points to a correct XML resource.
                ///doc.Load("http://localhost/xmltest/Q317662.xml");

                // Load the XML data from a reader object.
                // Ignore the white spaces.
                ///doc.PreserveWhitespace = false;
                // Read the XML by using XmlTextReader.
                ///XmlTextReader rdr = new XmlTextReader("Q317662.xml");
                ///rdr.MoveToContent();     // Move to the content nodes.
                ///rdr.Read();              // Start reading.
                ///rdr.Skip();              // Skip the root.
                ///rdr.Skip();              // Skip the first content node.
                ///doc.Load(rdr);           // Read the second node data into DOM.

                // To load the entire data, pass in the reader object when its
                // state is ReadState.Initial.
                // To do this in the aforementioned code section, comment out
                // the Skip and MoveToContent method calls.

                // Load the XML strings.
                //doc.LoadXml("<Collection><Book><Title>Priciple of Relativity</Title>" +
                //  "<Author>Albert Einstein</Author>" +
                //  "<Genre>Physics</Genre></Book></Collection>");

                // Display the content of the DOM document.
                textBox3.AppendText("\r\n" + doc.OuterXml);
                //XmlDocument contactDoc = new XmlDocument();
                //FileStream docOut =
                //new FileStream("C:/Users/cardman/Documents/output_c_sharp/xml_test.xml", FileMode.Create, FileAccess.Write, FileShare.Write);
                //contactDoc.Save(docOut);
                Stream myStream = new FileStream("C:/Users/cardman/Documents/output_c_sharp/xml_test_2.xml", FileMode.Create);

                if (myStream != null)
                {
                    using (myStream)
                    {
                        using (StreamWriter writer = new StreamWriter(myStream, Encoding.UTF8))
                        {
                            writer.Write(doc.OuterXml);
                        }
                    }
                }
                //string zipPath = @"c:\example\start.zip";
                string zipPath = @"C:\Users\cardman\workspace_cleaned\gestiondatabasepokemon\tmp_copy\rom_test\rom_pk_38.zip";
                //
                //string extractPath = @"c:\example\extract";
                using (ZipArchive archive = ZipFile.OpenRead(zipPath))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.FullName.Contains("/"))
                        {
                            continue;
                        }
                        if (entry.FullName.Contains("tm"))
                        {
                            continue;
                        }
                        if (entry.FullName.Contains("storage"))
                        {
                            continue;
                        }
                        if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
                        {
                            DeflateStream read_ = entry.Open() as DeflateStream;
                            String        str_  = "";
                            byte[]        by_   = new byte[1024];
                            while (true)
                            {
                                int nb_ = read_.Read(by_, 0, 1024);
                                if (nb_ <= 0)
                                {
                                    break;
                                }
                                str_ += System.Text.Encoding.UTF8.GetString(by_, 0, nb_);
                            }
                            str_ = str_.Replace("\n", "\r\n");
                            str_ = str_.Replace("\r\r\n", "\r\n");
                            //ZipArchiveEntry.
                            textBox3.AppendText("\r\n" + entry.FullName);
                            textBox3.AppendText("\r\n" + str_);
                            read_.Close();
                            //read_.rea
                            //entry.ExtractToFile(Path.Combine(extractPath, entry.FullName));
                        }
                    }
                }
                zipPath = @"C:\Users\cardman\Documents\output_c_sharp\zip_test.zip";
                using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Create))
                {
                    ZipArchiveEntry readmeEntry = archive.CreateEntry("Readme.txt");
                    using (StreamWriter writer = new StreamWriter(readmeEntry.Open()))
                    {
                        writer.WriteLine("Information about this package.");
                        writer.WriteLine("========================");
                    }
                }
            }
            catch (XmlException xmlEx)   // Handle the XML exceptions here.
            {
                textBox3.AppendText("\r\n" + xmlEx.Message);
            }
            catch (Exception ex)         // Handle the generic exceptions here.
            {
                textBox3.AppendText("\r\n" + ex.Message);
            }
            finally
            {
                // Finalize here.
            }
        }
 // Simple case.
 public void Match1(MyEnum e, NotEnum ne)
 {
     if (e.ToString() == "First") { }
 }
 // ToLower, ToUpper, and Trim (with no params) are all ok on the left hand side.
 public void Match2(MyEnum e)
 {
     if (e.ToString().ToLower() == "first") { }
 }
コード例 #30
0
ファイル: SayHello.cs プロジェクト: unshorn/Anathema
 private void ReceiveEnum(MyEnum e)
 {
     Console.WriteLine("Enum: " + e.ToString());
 }
 // The string is not one of the known enum values.
 public void NotMatch2(MyEnum e)
 {
     if(e.ToString() == "StringThatDoesn'tMatchTheEnumValue") { }
 }
コード例 #32
0
 public MyDisplayNameAttribute(MyEnum myEnum)
     : base("Is Active in " + myEnum.ToString())
 {
 }
コード例 #33
0
        public string GetStringRepresentation(MyEnum e)
        {
            MyEnum e2 = MyEnum.Apples;

            return(e.ToString() + e2.ToString());
        }
コード例 #34
0
 public string MyMethod2(MyEnum enm)
 {
     return("(" + enm.ToString() + ")");
 }