예제 #1
0
파일: ClassTable.cs 프로젝트: wynged/Dynamo
        public int GetCoercionScore(int type)
        {
            Validity.Assert(null != CoerceTypes);
            int score = (int)ProtoCore.DSASM.ProcedureDistance.NotMatchScore;

            if (type == ID)
            {
                return((int)ProtoCore.DSASM.ProcedureDistance.ExactMatchScore);
            }

            if ((int)PrimitiveType.Null == ID)
            {
                score = (int)ProtoCore.DSASM.ProcedureDistance.CoerceScore;
            }
            else
            {
                if (CoerceTypes.ContainsKey(type))
                {
                    score = CoerceTypes[type];
                }
            }


            return(score);
        }
예제 #2
0
        public bool ConvertibleTo(int type)
        {
            Validity.Assert(null != CoerceTypes);
            Validity.Assert((int)PrimitiveType.InvalidType != ID);

            if ((int)PrimitiveType.Null == ID || CoerceTypes.ContainsKey(type))
            { 
                return true;
            }

            //chars are convertible to string

            else if (ID == (int)PrimitiveType.Char && type==(int)PrimitiveType.String)
            {
                return true;
            }

            //user defined type to bool
            else if (ID >=(int)PrimitiveType.MaxPrimitive && type == (int)PrimitiveType.Bool)
            {
                return true;
            }
                
                //string to boolean

            else if (ID == (int)PrimitiveType.String && type == (int)PrimitiveType.Bool)
            {
                return true;
            }
            //char to boolean
            else if (ID == (int)PrimitiveType.Char && type == (int)PrimitiveType.Bool)
            {
                return true;
            }
            
            return false;
        }