コード例 #1
0
            /// <summary>
            /// Initializes the config.
            /// </summary>
            /// <exception cref="System.Exception">InitializeProperties: ERROR:undefined property
            /// type: + property.PropertyType.ToString()</exception>
            private void InitializeConfig()
            {
                foreach (PropertyInfo property in typeof(ConfigurationProperties).GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (property.PropertyType == typeof(string))
                    {
                        property.SetValue(this, string.Empty, null);
                    }
                    else if (property.PropertyType == typeof(int))
                    {
                        property.SetValue(this, 0, null);
                    }
                    else if (property.PropertyType == typeof(uint))
                    {
                        property.SetValue(this, (uint)0, null);
                    }
                    else if (property.PropertyType == typeof(bool))
                    {
                        property.SetValue(this, false, null);
                    }
                    else if (property.PropertyType.IsEnum)
                    {
                        if (EnumProperties.IsDefined(property.PropertyType, "Unknown"))
                        {
                            property.SetValue(this, EnumProperties.Parse(property.PropertyType, "Unknown", true), null);
                        }
                    }
                    else if (property.PropertyType.IsArray)
                    {
                        property.SetValue(this, new string[0], property.GetIndexParameters());
                    }
                    else
                    {
                        throw new Exception("InitializeProperties: ERROR:undefined property type:" + property.PropertyType.ToString());
                    }
                }

                Activity         = ActivityType.Unknown.ToString();
                ConfigFile       = Process.GetCurrentProcess().MainModule.ModuleName + ".config";
                LogFileAutoFlush = true;
                LogToConsole     = true;
                RunAs            = ExecutionOptions.Unknown.ToString();
                SmtpPort         = 25;
                LogLevel         = 16;
                BufferLines      = 99999;
                BufferMin        = 40;
                BufferMax        = 80;
                BufferSize       = 100;
                Retries          = 1;
                LogFileOverWrite = true;
                LogFileMaxCount  = 10;
                LogFileMaxSize   = 20;
                RemoteActivity   = RemoteOperations.RemoteOperationMethods.Unknown.ToString();
                ServiceStartMode = Configuration.ServiceStartModeOptionEnum.Automatic.ToString();
                StartEventSource = "Application";
                StopEventSource  = "Application";
                ModuleSource     = ModuleSourceType.Configuration.ToString();
                UdpClientPort    = 45000;
                UdpPingTimer     = 60;
                UdpServerPort    = 45001;
                AutoScroll       = true;
            }
コード例 #2
0
ファイル: TextParsing.cs プロジェクト: thirgen/gwant
    private static Enum GetEnumProperty(EnumProperties Property, string Text)
    {
        string pattern = @"(" + Property.ToString().ToLower() + @")\s*=\s*(?'data'";// ([0-9]{1,2})";

        Type enumType;

        if (Property == EnumProperties.Ability)
        {
            enumType = typeof(Card.Abilities);
        }
        else if (Property == EnumProperties.Section)
        {
            enumType = typeof(UnitCard.Sections);
        }
        else// if (Property == EnumProperties.WeatherType)
        {
            enumType = typeof(SpecialCard.WeatherTypes);
        }

        #region Regex Pattern
        if (Property == EnumProperties.Ability)
        {
            //Add Card.Abilities enums to the regex pattern
            for (int i = 0; i < (int)Card.Abilities.COUNT; i++)
            {
                if (i != (int)Card.Abilities.UNIT_END && i != (int)Card.Abilities.SPECIAL_START)
                {
                    pattern += ((Card.Abilities)i).ToString();
                    if (i != (int)Card.Abilities.COUNT - 1)
                    {
                        pattern += @"|";
                    }
                    else
                    {
                        pattern += @")";
                    }
                }
            }
        }
        else if (Property == EnumProperties.Section)
        {
            //Add UnitCard.Sections enums to the regex pattern
            for (int i = 0; i < (int)UnitCard.Sections.COUNT; i++)
            {
                pattern += ((UnitCard.Sections)i).ToString();
                if (i != (int)UnitCard.Sections.COUNT - 1)
                {
                    pattern += @"|";
                }
                else
                {
                    pattern += @")";
                }
            }
        }
        else if (Property == EnumProperties.WeatherType)
        {
            //Add EnumProperties.WeatherTypes enums to the regex pattern
            for (int i = 0; i < (int)SpecialCard.WeatherTypes.COUNT; i++)
            {
                pattern += ((SpecialCard.WeatherTypes)i).ToString();
                if (i != (int)SpecialCard.WeatherTypes.COUNT - 1)
                {
                    pattern += @"|";
                }
                else
                {
                    pattern += @")";
                }
            }
        }
        #endregion

        try
        {
            object o = GetProperty(Text, pattern);
            if (o != null)
            {
                string output = (string)o;
                char   ch     = char.ToUpper(output[0]);
                output = ch + output.Substring(1);
                return((Enum)Enum.Parse(enumType, output));
            }
            return(null);
        }
        catch (InvalidCastException)
        {
            return(null);
        }
    }
コード例 #3
0
        private ControlProperties CreateProperties(PropertyType type, PropertyInfo info, ExposePropertyAttribute attribute)
        {
            ControlProperties control = null;

            switch (type)
            {
            case PropertyType.AnimationCurve:
                control = new AnimationCurveProperties(this, info, attribute);
                break;

            case PropertyType.Boolean:
                control = new BooleanProperties(this, info, attribute);
                break;

            case PropertyType.Bounds:
                control = new BoundsProperties(this, info, attribute);
                break;

            case PropertyType.Color:
                control = new ColorProperties(this, info, attribute);
                break;

            case PropertyType.Enum:
                control = new EnumProperties(this, info, attribute);
                break;

            case PropertyType.Float:
                control = new FloatProperties(this, info, attribute);
                break;

            case PropertyType.Integer:
                control = new IntegerProperties(this, info, attribute);
                break;

            case PropertyType.LayerMask:
                control = new LayerMaskProperties(this, info, attribute);
                break;

            case PropertyType.ObjectReference:
                control = new UnityObjectProperties(this, info, attribute);
                break;

            case PropertyType.Quaternion:
                control = new QuaternionProperties(this, info, attribute);
                break;

            case PropertyType.Rect:
                control = new RectProperties(this, info, attribute);
                break;

            case PropertyType.String:
                control = new StringProperties(this, info, attribute);
                break;

            case PropertyType.Vector2:
                control = new Vector2Properties(this, info, attribute);
                break;

            case PropertyType.Vector3:
                control = new Vector3Properties(this, info, attribute);
                break;

            case PropertyType.Vector4:
                control = new Vector4Properties(this, info, attribute);
                break;

            case PropertyType.SerializableObject:
                control = new SerializableObjectProperties(this, info, attribute);
                break;

            case PropertyType.Array:
                control = new ArrayProperties(this, info, attribute);
                break;
            }

            if (control != null)
            {
                var margin = control.Control.Margin;
                margin.Left           += 2;
                margin.Top            += 2;
                margin.Bottom         += 2;
                control.Control.Margin = margin;
            }
            return(control);
        }