Пример #1
0
 public VoiceParm(VoiceParm other)
 {
     this.kind        = other.kind;
     this.name        = other.name;
     this.description = other.description;
     this.valueKind   = other.valueKind;
     this.value       = other.value;
     this.imin        = other.imin;
     this.imax        = other.imax;
     this.fmin        = other.fmin;
     this.fmax        = other.fmax;
     this.ctlIndex    = other.ctlIndex;
     this.ret         = other.ret;
 }
Пример #2
0
        public ParmStatus CheckValidParm(VoiceParm parm, string value)
        {
            //log.InfoFormat("VoiceParmCollection.CheckValidParm: for parameter {0}, value is {1}", parm.name, value);
            ParmStatus ret = new ParmStatus();

            parm.ret = ret;
            if (parm == null)
            {
                ret.errorMessage = "There is no parameter named '" + parm.name + "'";
                return(ret);
            }
            switch (parm.valueKind)
            {
            case ValueKind.Int:
                try {
                    ret.iValue = Int32.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' can't be parsed",
                                                     parm.name, value);
                    return(ret);
                }
                if (ret.iValue < parm.imin || ret.iValue > parm.imax)
                {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' is outside the range from {2} to {3}",
                                                     parm.name, ret.iValue, parm.imin, parm.imax);
                    return(ret);
                }
                break;

            case ValueKind.Long:
                try {
                    ret.lValue = Int64.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' can't be parsed",
                                                     parm.name, value);
                    return(ret);
                }
                break;

            case ValueKind.Float:
                try {
                    ret.fValue = Single.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Float parameter '{0}' value '{1}' can't be parsed",
                                                     parm.name, value);
                    return(ret);
                }
                if (ret.fValue < parm.fmin || ret.fValue > parm.fmax)
                {
                    ret.errorMessage = string.Format("Float parameter '{0}' value '{1}' is outside the range from {2} to {3}",
                                                     parm.name, ret.fValue, parm.fmin, parm.fmax);
                    return(ret);
                }
                break;

            case ValueKind.Bool:
                try {
                    ret.bValue = Boolean.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Boolean parameter '{0}' value '{1}' can't be parsed",
                                                     parm.name, value);
                    return(ret);
                }
                break;

            case ValueKind.String:
                ret.sValue = value;
                break;
            }
            return(ret);
        }
        public ParmStatus CheckValidParm(VoiceParm parm, string value)
        {
            //log.InfoFormat("VoiceParmCollection.CheckValidParm: for parameter {0}, value is {1}", parm.name, value);
            ParmStatus ret = new ParmStatus();
            parm.ret = ret;
            if (parm == null) {
                ret.errorMessage = "There is no parameter named '" + parm.name + "'";
                return ret;
            }
            switch (parm.valueKind) {

            case ValueKind.Int:
                try {
                    ret.iValue = Int32.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' can't be parsed",
                        parm.name, value);
                    return ret;
                }
                if (ret.iValue < parm.imin || ret.iValue > parm.imax) {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' is outside the range from {2} to {3}",
                        parm.name, ret.iValue, parm.imin, parm.imax);
                    return ret;
                }
                break;

            case ValueKind.Long:
                try {
                    ret.lValue = Int64.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Int parameter '{0}' value '{1}' can't be parsed",
                        parm.name, value);
                    return ret;
                }
                break;

            case ValueKind.Float:
                try {
                    ret.fValue = Single.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Float parameter '{0}' value '{1}' can't be parsed",
                        parm.name, value);
                    return ret;
                }
                if (ret.fValue < parm.fmin || ret.fValue > parm.fmax) {
                    ret.errorMessage = string.Format("Float parameter '{0}' value '{1}' is outside the range from {2} to {3}",
                        parm.name, ret.fValue, parm.fmin, parm.fmax);
                    return ret;
                }
                break;

            case ValueKind.Bool:
                try {
                    ret.bValue = Boolean.Parse(value);
                }
                catch (Exception) {
                    ret.errorMessage = string.Format("Boolean parameter '{0}' value '{1}' can't be parsed",
                        parm.name, value);
                    return ret;
                }
                break;

            case ValueKind.String:
                ret.sValue = value;
                break;

            }
            return ret;
        }
 public VoiceParm(VoiceParm other)
 {
     this.kind = other.kind;
     this.name = other.name;
     this.description = other.description;
     this.valueKind = other.valueKind;
     this.value = other.value;
     this.imin = other.imin;
     this.imax = other.imax;
     this.fmin = other.fmin;
     this.fmax = other.fmax;
     this.ctlIndex = other.ctlIndex;
     this.ret = other.ret;
 }