コード例 #1
0
ファイル: BoxData.cs プロジェクト: zerodowned/annox
        /// <summary>
        /// Processes the types and extracts item and mobile information
        /// </summary>
        /// <param name="types">A list of types to process</param>
        /// <param name="items">An array list that will hold the extracted items</param>
        /// <param name="mobiles">An array list that will hold the extracted mobiles</param>
        /// <param name="table">The StringDictionary item providing information about the classes location</param>
        private static void ProcessTypes(ArrayList types, ArrayList items, ArrayList mobiles, StringDictionary table)
        {
            foreach (Type t in types)
            {
                if (t.IsSpecialName)
                {
                    continue;
                }

                if ((typeof(Item)).IsAssignableFrom(t))
                {
                    // Item
                    BoxItem item = BoxItem.FromType(t);

                    if (item != null)
                    {
                        item.FileName = table[item.Name.ToLower()];
                        items.Add(item);
                    }
                }
                else if ((typeof(Mobile)).IsAssignableFrom(t))
                {
                    // Mobile
                    BoxMobile mobile = BoxMobile.FromType(t);

                    if (mobile != null)
                    {
                        mobile.FileName = table[mobile.Name.ToLower()];
                        mobiles.Add(mobile);
                    }
                }
            }
        }
コード例 #2
0
ファイル: BoxData.cs プロジェクト: zerodowned/annox
        /// <summary>
        /// Gets a BoxMobile object from a type
        /// </summary>
        /// <param name="t">The type to evaluate</param>
        /// <returns>A BoxMobile object or null if the type can't be constructed properly</returns>
        public static BoxMobile FromType(Type t)
        {
            ConstructorInfo[] ctors = t.GetConstructors();

            bool      constructable = false;
            BoxMobile mobile        = null;

            foreach (ConstructorInfo c in ctors)
            {
                if (BoxUtil.IsConstructable(c))
                {
                    constructable = true;
                    break;
                }
            }

            if (constructable)
            {
                mobile        = new BoxMobile();
                mobile.m_Name = t.Name;

                foreach (ConstructorInfo c in ctors)
                {
                    if (BoxUtil.IsConstructable(c))
                    {
                        ParameterInfo[] pms = c.GetParameters();

                        if (pms.Length == 0)
                        {
                            try
                            {
                                Mobile theMobile = (Mobile)Activator.CreateInstance(t);

                                mobile.m_Art = theMobile.Body.BodyID;
                                mobile.Hue   = theMobile.Hue;

                                if (theMobile != null)
                                {
                                    theMobile.Delete();
                                }
                            }
                            catch
                            {
                                // TODO : Logging?
                                return(null);
                            }
                        }
                        else if (pms.Length == 1 && (pms[0].ParameterType == typeof(string)))
                        {
                            mobile.CanBeNamed = true;
                        }
                    }
                }
            }

            return(mobile);
        }
コード例 #3
0
ファイル: BoxData.cs プロジェクト: zerodowned/annox
        public int CompareTo(object obj)
        {
            BoxMobile mob = obj as BoxMobile;

            if (mob != null)
            {
                return(m_Name.CompareTo(mob.m_Name));
            }
            else
            {
                return(0);
            }
        }
コード例 #4
0
ファイル: TreeSearch.cs プロジェクト: tandj1116/pandorasbox3
        private static void DoNode(TreeNode node, SearchResults results, string text)
        {
            foreach (TreeNode subNode in node.Nodes)
            {
                DoNode(subNode, results, text);
            }
            // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
            if (node.Tag != null && node.Tag is List <object> )
            {
                List <object> list = node.Tag as List <object>;
                // Issue 10 - End

                for (int i = 0; i < list.Count; i++)
                {
                    object o = list[i];

                    if (o is BoxMobile)
                    {
                        BoxMobile mob = o as BoxMobile;

                        if (mob.Name.ToLower().IndexOf(text.ToLower()) > -1)
                        {
                            Result res = new Result(node, i);
                            results.Add(res);
                        }
                    }
                    else if (o is BoxItem)
                    {
                        BoxItem item = o as BoxItem;

                        if (item.Name.ToLower().IndexOf(text.ToLower()) > -1)
                        {
                            Result res = new Result(node, i);
                            results.Add(res);
                        }
                    }
                }
            }
        }
コード例 #5
0
        public int CompareTo(object obj)
        {
            BoxMobile cmp = obj as BoxMobile;

            return(m_Name.CompareTo(cmp.m_Name));
        }
コード例 #6
0
ファイル: BoxData.cs プロジェクト: greeduomacro/annox
		/// <summary>
		/// Gets a BoxMobile object from a type
		/// </summary>
		/// <param name="t">The type to evaluate</param>
		/// <returns>A BoxMobile object or null if the type can't be constructed properly</returns>
		public static BoxMobile FromType( Type t )
		{
			ConstructorInfo[] ctors = t.GetConstructors();

			bool constructable = false;
			BoxMobile mobile = null;

			foreach ( ConstructorInfo c in ctors )
			{
				if ( BoxUtil.IsConstructable( c ) )
				{
					constructable = true;
					break;
				}
			}

			if ( constructable )
			{
				mobile = new BoxMobile();
				mobile.m_Name = t.Name;

				foreach ( ConstructorInfo c in ctors )
				{
					if ( BoxUtil.IsConstructable( c ) )
					{
						ParameterInfo[] pms = c.GetParameters();

						if ( pms.Length == 0 )
						{
							try
							{
								Mobile theMobile = (Mobile) Activator.CreateInstance( t );

								mobile.m_Art = theMobile.Body.BodyID;
								mobile.Hue = theMobile.Hue;

								if ( theMobile != null )
								{
									theMobile.Delete();
								}
							}
							catch
							{
								// TODO : Logging?
								return null;
							}
						}
						else if ( pms.Length == 1 && ( pms[ 0 ].ParameterType == typeof( string ) ) )
						{
							mobile.CanBeNamed = true;
						}
					}
				}
			}

			return mobile;
		}