예제 #1
0
        /////////////////////////////////////////////////////////////
        //
        //	Get property value in string format
        //
        /////////////////////////////////////////////////////////////
        public static string getPropertyValue(CEWSI.PropertyType objProp)
        {
            if (objProp == null)
            {
                return("null");
            }

            string strValue = "";
            Type   objType  = objProp.GetType();

            if (objType == typeof(CEWSI.SingletonString))
            {
                strValue = (string)((CEWSI.SingletonString)objProp).Value;
            }
            else
            if (objType == typeof(CEWSI.SingletonBoolean))
            {
                strValue = (string)((CEWSI.SingletonBoolean)objProp).Value.ToString();
            }
            else
            if (objType == typeof(CEWSI.SingletonDateTime))
            {
                strValue = (string)((CEWSI.SingletonDateTime)objProp).Value.ToString();
            }
            else
            if (objType == typeof(CEWSI.SingletonFloat64))
            {
                strValue = (string)((CEWSI.SingletonFloat64)objProp).Value.ToString();
            }
            else
            if (objType == typeof(CEWSI.SingletonId))
            {
                strValue = (string)((CEWSI.SingletonId)objProp).Value;
            }
            else
            if (objType == typeof(CEWSI.SingletonInteger32))
            {
                strValue = (string)((CEWSI.SingletonInteger32)objProp).Value.ToString();
            }
            else
            if (objType == typeof(CEWSI.SingletonObject))
            {
                CEWSI.SingletonObject objSO = (CEWSI.SingletonObject)objProp;

                if (objSO.Value == null)
                {
                    strValue = "null";
                }
                else
                {
                    try
                    {
                        CEWSI.ObjectReference objRef = (CEWSI.ObjectReference)objSO.Value;
                        strValue = (string)(objRef.objectId);
                    }
                    catch (System.Exception)
                    {
                        strValue = "Unevaluated";
                    }
                }
            }
            else
            if (objType == typeof(CEWSI.EnumOfObject))
            {
                StringBuilder      buffer  = new StringBuilder();
                CEWSI.EnumOfObject objEnum = (CEWSI.EnumOfObject)objProp;
                if ((CEWSI.ObjectValue[])objEnum.Value != null)
                {
                    buffer.Append("\r\n");
                    foreach (CEWSI.ObjectValue obj in (CEWSI.ObjectValue[])objEnum.Value)
                    {
                        buffer.Append("          " + obj.objectId + "\r\n");
                    }
                }
                strValue = buffer.ToString();
            }
            else
            if (objType == typeof(CEWSI.ListOfString))
            {
                if (((CEWSI.ListOfString)objProp).Value != null)
                {
                    StringBuilder buffer = new StringBuilder();
                    foreach (string str in (string[])((CEWSI.ListOfString)objProp).Value)
                    {
                        buffer.Append(str + ",");
                    }
                    strValue = buffer.ToString();
                }
            }
            else
            if (objType == typeof(CEWSI.ListOfObject))
            {
                CEWSI.ListOfObject objList = (CEWSI.ListOfObject)objProp;
                if (objProp.propertyId == "ContentElements")
                {
                    strValue = ("ContentElements");
                }
                else
                {
                    if (objList != null)
                    {
                        StringBuilder buffer = new StringBuilder();
                        foreach (CEWSI.DependentObjectType obj in (CEWSI.DependentObjectType[])((CEWSI.ListOfObject)objList).Value)
                        {
                            buffer.Append(obj.classId + ", ");
                        }
                        strValue = buffer.ToString();
                    }
                }
            }
            else
            {
                strValue = (string)objProp.ToString();
            }

            //buffer.Append((objRet == null) ? "null" : objRet.ToString());

            return(strValue);
        }