コード例 #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
ファイル: ClassTable.cs プロジェクト: mengelmn/Dynamo
        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;
        }