Equals() 개인적인 메소드

private Equals ( Object obj ) : bool
obj Object
리턴 bool
예제 #1
0
 public void selectService(Enum id)
 {
     if (id.Equals(SocialServices.FACEBOOK))
     {
         selectedService = facebook;
     }
     else if (id.Equals(SocialServices.GOOGLE_PLUS))
     {
         selectedService = googlePlus;
     }
     else
     {
         throw new Exception ("MultiSocialService received unrecognized service id.");
     }
 }
예제 #2
0
 public static IEnumerable <SelectListItem> ToSelectList <T>(this System.Enum enumValue)
 {
     return
         (System.Enum.GetValues(enumValue.GetType()).Cast <T>()
          .Select(
              x =>
              new SelectListItem
     {
         Text = ((System.Enum)(object) x).ToDescription(),
         Value = x.ToString(),
         Selected = (enumValue.Equals(x))
     }));
 }
	static int Equals(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 2);
			System.Enum obj = (System.Enum)ToLua.CheckObject(L, 1, typeof(System.Enum));
			object arg0 = ToLua.ToVarObject(L, 2);
			bool o = obj != null ? obj.Equals(arg0) : arg0 == null;
			LuaDLL.lua_pushboolean(L, o);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
예제 #4
0
        private void ReadConfig(Enum choice)
        {
            // read the XML file from                       v here
                path = Directory.GetCurrentDirectory() + @"\Dependency\ProfileConfig\ProfileConfig.xml";
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(new StreamReader(path));
                if (xmldoc.DocumentElement == null)
                    {
                    return;
                    }
                var nodeList = xmldoc.DocumentElement.SelectNodes("Server"); // <- This gets the stuff related to servers, all of it

                try
                    {
                    if (choice.Equals(ConfigType.Students)) // if you want to find a students RF data, do this
                        {

                        ConfStrings[0] = nodeList[0].SelectSingleNode("address").InnerText;
                        ConfStrings[1] = nodeList[0].SelectSingleNode("sqldirectory").InnerText;
                        ConfStrings[2] = nodeList[0].SelectSingleNode("table").InnerText;
                        ConfStrings[3] = nodeList[0].SelectSingleNode("dbuser").InnerText;
                        ConfStrings[4] = nodeList[0].SelectSingleNode("dbpass").InnerText;

                        }
                    else
                        {
                        // this is teacher data
                        ConfStrings[0] = nodeList[0].NextSibling.SelectSingleNode("address").InnerText;
                        ConfStrings[1] = nodeList[0].NextSibling.SelectSingleNode("sqldirectory").InnerText;
                        ConfStrings[2] = nodeList[0].NextSibling.SelectSingleNode("table").InnerText;
                        ConfStrings[3] = nodeList[0].NextSibling.SelectSingleNode("dbuser").InnerText;
                        ConfStrings[4] = nodeList[0].NextSibling.SelectSingleNode("dbpass").InnerText;
                        }
                    if (DiagXML)
                        {
                            var str = "XML status: filtilgang og lesning OK";
                        }
                    }
                catch (NullReferenceException e)
                    {
                //TODO Handle exception
                // okay
                        LogThis.Report("ConfigReader",e.StackTrace); // write the error down in the logfile
                    }
        }
예제 #5
0
    static int Equals(IntPtr L)
    {
        ToLua.CheckArgsCount(L, 2);
        System.Enum obj  = (System.Enum)ToLua.CheckObject(L, 1, typeof(System.Enum));
        object      arg0 = ToLua.ToVarObject(L, 2);
        bool        o;

        try
        {
            o = obj != null?obj.Equals(arg0) : arg0 == null;
        }
        catch (Exception e)
        {
            return(LuaDLL.luaL_error(L, e.Message));
        }

        LuaDLL.lua_pushboolean(L, o);
        return(1);
    }
예제 #6
0
        static StackObject *Equals_20(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object @obj = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Enum instance_of_this_method = (System.Enum) typeof(System.Enum).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Equals(@obj);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
예제 #7
0
        private void ReadConfig(Enum choice)
        {
            // read the XML file from                       v here
                                _path = Directory.GetCurrentDirectory() + @"\Dependency\Config\Config.xml";
                                XmlDocument xmldoc = new XmlDocument();
                                xmldoc.Load(new StreamReader(_path));
                                if (xmldoc.DocumentElement == null)
                                    {
                                        return;
                                    }
                                var nodeList = xmldoc.DocumentElement.SelectNodes("Server"); // <- This gets the stuff related to servers, all of it

                                //Console.WriteLine(nodeList[0].NextSibling.SelectSingleNode("table").InnerText);

                                try
                                    {
                                        if (choice.Equals(ConfigType.Students)) // if you want to find a students RF data, do this
                                            {

                                                ConfStrings[0] = nodeList[0].SelectSingleNode("address").InnerText;
                                                ConfStrings[1] = nodeList[0].SelectSingleNode("sqldirectory").InnerText;
                                                ConfStrings[2] = nodeList[0].SelectSingleNode("table").InnerText;
                                                ConfStrings[3] = nodeList[0].SelectSingleNode("dbuser").InnerText;
                                                ConfStrings[4] = nodeList[0].SelectSingleNode("dbpass").InnerText;

                                            }
                                        else
                                            {
                                                // this is teacher data
                                                ConfStrings[0] = nodeList[0].NextSibling.SelectSingleNode("address").InnerText;
                                                ConfStrings[1] = nodeList[0].NextSibling.SelectSingleNode("sqldirectory").InnerText;
                                                ConfStrings[2] = nodeList[0].NextSibling.SelectSingleNode("table").InnerText;
                                                ConfStrings[3] = nodeList[0].NextSibling.SelectSingleNode("dbuser").InnerText;
                                                ConfStrings[4] = nodeList[0].NextSibling.SelectSingleNode("dbpass").InnerText;
                                            }
                                        if (DiagXML)
                                            {
                                                Speaker sp = new Speaker(Language.Norwegian);
                                                var str = "XML status: filtilgang og lesning OK";
                                                sp.Speak(str, 0);

                                            }
                                    }
                                catch (Exception e)
                                    {
                                        Console.WriteLine(e); // you done f****d up.
                                    }
        }
 /// <summary>
 /// Writes the attribute.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 /// <param name="defaultValue">The default value.</param>
 protected void WriteAttribute(string name, Enum value, Enum defaultValue)
 {
     if (this.settings.WriteDefaultValues || !value.Equals(defaultValue)) {
         this.writer.WriteAttributeString(name, value.Format());
     }
 }
예제 #9
0
 public static void Equals(Enum e, object obj, bool expected, bool hashExpected)
 {
     Assert.Equal(expected, e.Equals(obj));
     Assert.Equal(e.GetHashCode(), e.GetHashCode());
     if (obj != null)
     {
         Assert.Equal(hashExpected, e.GetHashCode().Equals(obj.GetHashCode()));
     }
 }
예제 #10
0
        protected internal void SetEnumAttribute(string attribute, Enum value, Enum defaultValue)
        {
            Debug.Assert(value.GetType().Equals(defaultValue.GetType()));

            if (value.Equals(defaultValue))
            {
                RemoveAttribute(attribute);
            }
            else
            {
                SetAttribute(attribute, value.ToString());
            }
        }
        /// <summary>
        /// Returns true if the given enum instance can map exactly to one of the enum's constants.
        /// This doesn't always happen when using BitField enums.
        /// </summary>
        /// <param name="input">An instance of an enum.</param>
        /// <returns>True, if the instance maps directly to a single enum property, false if otherwise.</returns>
        private static bool DirectlyMapsToEnumConstant(Enum input)
        {
            bool exactMatch = false;

            foreach (var raw in Enum.GetValues(input.GetType()))
            {
                if (input.Equals(raw))
                {
                    exactMatch = true;
                    break;
                }
            }

            return exactMatch;
        }
예제 #12
0
 public static bool IsOneOf <T>(this System.Enum type, params T[] values)
 {
     //[sk]: do not tested
     return(values.Any(value => type.Equals(value)));
 }
예제 #13
0
파일: Element.cs 프로젝트: ikvm/webmatrix
 protected internal void SetEnumAttribute(string attribute, Enum value, Enum defaultValue)
 {
     if (value.Equals(defaultValue))
     {
         this.RemoveAttribute(attribute);
     }
     else
     {
         this.SetAttribute(attribute, value.ToString(CultureInfo.InvariantCulture));
     }
 }