コード例 #1
0
ファイル: PropsData.cs プロジェクト: zerodowned/annox
        /// <summary>
        /// Creates a BoxProp object from a PropertyInfo
        /// </summary>
        /// <param name="info">The PropertyInfo used to extract the BoxProp object</param>
        /// <returns>The extracted BoxProp object</returns>
        public static BoxProp FromPropertyInfo(PropertyInfo info)
        {
            object[] cpa = info.GetCustomAttributes(typeof(CommandPropertyAttribute), false);

            if (cpa.Length > 0)
            {
                BoxProp prop = new BoxProp();

                prop.Name   = info.Name;
                prop.CanGet = info.CanRead;
                prop.CanSet = info.CanWrite;

                CommandPropertyAttribute attr = cpa[0] as CommandPropertyAttribute;

                prop.GetAccess = attr.ReadLevel;
                prop.SetAccess = attr.WriteLevel;

                if (prop.SetAccess.ToString() == "5")                   // Weird access level on Account property
                {
                    prop.SetAccess = AccessLevel.Administrator;
                    prop.CanSet    = false;
                }

                prop.ValueType = GetPropType(info.PropertyType);

                if (prop.ValueType == BoxPropType.Enumeration)
                {
                    prop.EnumName = info.PropertyType.Name;
                }

                return(prop);
            }

            return(null);
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: Orion321/unknown-shard
        /// <summary>
        /// Extracts a ParamDef object from a ParameterInfo
        /// </summary>
        /// <param name="pInfo">The ParameterInfo object containing information about a constructor parameter</param>
        /// <returns>A ParamDef object</returns>
        public static ParamDef FromParameterInfo(ParameterInfo pInfo)
        {
            ParamDef def = new ParamDef();

            def.m_Name      = pInfo.Name;
            def.m_ParamType = BoxProp.GetPropType(pInfo.ParameterType);

            if (pInfo.ParameterType.IsEnum)
            {
                def.m_EnumValues = new ArrayList();
                def.m_EnumValues.AddRange(Enum.GetNames(pInfo.ParameterType));
            }

            return(def);
        }
コード例 #3
0
ファイル: PropsData.cs プロジェクト: zerodowned/annox
        /// <summary>
        /// Processes a type and collects information about its properties
        /// </summary>
        /// <param name="t">The Type to examine</param>
        private void ProcessType(Type t)
        {
            ArrayList list = new ArrayList();

            if ((BoxUtil.IsItem(t) || BoxUtil.IsMobile(t)))
            {
                PropertyInfo[] props = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

                if (props.Length > 0)
                {
                    foreach (PropertyInfo info in props)
                    {
                        BoxProp p = BoxProp.FromPropertyInfo(info);

                        if (p != null)
                        {
                            list.Add(p);

                            if (p.ValueType == BoxPropType.Enumeration)
                            {
                                if (!EnumListed(p.EnumName))
                                {
                                    BoxEnum e = BoxEnum.FromPropertyInfo(info);
                                    m_Enums.Add(e);
                                }
                            }
                        }
                    }
                }
            }

            if (list.Count > 0)
            {
                m_Constructables[t.Name] = list;
            }
            else
            {
                m_Constructables[t.Name] = null;
            }
        }
コード例 #4
0
ファイル: PropsData.cs プロジェクト: aj9251/pandorasbox3
		/// <summary>
		/// Creates a BoxProp object from a PropertyInfo
		/// </summary>
		/// <param name="info">The PropertyInfo used to extract the BoxProp object</param>
		/// <returns>The extracted BoxProp object</returns>
		public static BoxProp FromPropertyInfo( PropertyInfo info )
		{
			object[] cpa = info.GetCustomAttributes( typeof( CommandPropertyAttribute ), false );

			if ( cpa.Length > 0 )
			{
				BoxProp prop = new BoxProp();

				prop.Name = info.Name;
				prop.CanGet = info.CanRead;
				prop.CanSet = info.CanWrite;

				CommandPropertyAttribute attr = cpa[ 0 ] as CommandPropertyAttribute;

				prop.GetAccess = attr.ReadLevel;
				prop.SetAccess = attr.WriteLevel;

				if ( prop.SetAccess.ToString() == "5" ) // Weird access level on Account property
				{
					prop.SetAccess = AccessLevel.Administrator;
					prop.CanSet = false;
				}

				prop.ValueType = GetPropType( info.PropertyType );

				if ( prop.ValueType == BoxPropType.Enumeration )
				{
					prop.EnumName = info.PropertyType.Name;
				}
				
				return prop;
			}

			return null;
		}
コード例 #5
0
ファイル: Props.cs プロジェクト: aj9251/pandorasbox3
		/// <summary>
		/// User has selected a property
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void tProps_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			if ( e.Node != null && e.Node.Tag != null )
			{
				SelectedProperty = e.Node.Tag as BoxProp;
			}
			else
			{
				SelectedProperty = null;
			}
		}
コード例 #6
0
ファイル: Props.cs プロジェクト: aj9251/pandorasbox3
		/// <summary>
		/// User has clicked a class, display properties
		/// </summary>
		private void tClasses_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			RefreshPropsTree();
			SelectedProperty = null;
		}