public object defaultAdapt(ReferenceCache refCache)
 {
     if (realType is ICacheableAdaptingType)
     {
         return(((ICacheableAdaptingType)realType).defaultAdapt(refCache));
     }
     else
     {
         return(realType.defaultAdapt());
     }
 }
Пример #2
0
 public object defaultAdapt(ReferenceCache refCache)
 {
     if (mappedType != null)
     {
         if (typedObject is ICacheableAdaptingType)
         {
             return(((ICacheableAdaptingType)typedObject).adapt(mappedType, refCache));
         }
         else
         {
             return(typedObject.adapt(mappedType));
         }
     }
     else
     {
         if (typedObject is ICacheableAdaptingType)
         {
             return(((ICacheableAdaptingType)typedObject).defaultAdapt(refCache));
         }
         else
         {
             return(typedObject.defaultAdapt());
         }
     }
 }
Пример #3
0
        public static object FromBytes(byte[] bytes, int type, bool doNotAdapt)
        {
            switch (type)
            {
            case AMF0:
            case AMF3:
                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    using (FlashorbBinaryReader reader = new FlashorbBinaryReader(stream))
                    {
                        IAdaptingType adpatingType = Weborb.Protocols.Amf.RequestParser.readData(reader, type == AMF0 ? 0 : 3);

                        if (doNotAdapt)
                        {
                            return(adpatingType);
                        }
                        else
                        {
                            return(adpatingType.defaultAdapt());
                        }
                    }
                }

            case JSON:
                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);

                    using (JsonTextReader jsonReader = new JsonTextReader(streamReader))
                    {
                        jsonReader.Read();
                        IAdaptingType jsonType = Weborb.Protocols.JsonRPC.RequestParser.Read(jsonReader);

                        if (doNotAdapt)
                        {
                            return(jsonType);
                        }
                        else
                        {
                            return(jsonType.defaultAdapt());
                        }
                    }
                }

#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
            case WOLF:

                using (MemoryStream stream = new MemoryStream(bytes))
                {
                    Weborb.Protocols.Wolf.RequestParser parser = Weborb.Protocols.Wolf.RequestParser.GetInstance();
                    Request requestObj = parser.Parse(stream);
                    return(requestObj.getRequestBodyData());
                }
                break;
#endif
            default:
                throw new Exception("Unknown formatting type");
            }
        }
Пример #4
0
        internal static void ReportObjectUnderFlow(object obj, System.Collections.IDictionary props)
        {
            IDictionary <string, object> properties = new Dictionary <string, object>();

            foreach (object key in props.Keys)
            {
                IAdaptingType adaptingType = (IAdaptingType)props[key];
                properties[(string)key] = adaptingType.defaultAdapt();
            }

            objectStore.Add(obj, properties);
        }
        public new void ResponseHandler(AsyncMessage asyncMessage)
        {
            IAdaptingType[] bodys = asyncMessage.GetBody();
            foreach (IAdaptingType adaptingType in bodys)
            {
                object message = adaptingType.defaultAdapt();
                base.ResponseHandler(message);
            }
            return;

#if !(FULL_BUILD)
            IAdaptingType body = (IAdaptingType)asyncMessage.body;
#else
            IAdaptingType body = (IAdaptingType)((object[])(asyncMessage.body.body))[0];
#endif
            object adaptedMessage = body.defaultAdapt();
            base.ResponseHandler(adaptedMessage);
        }
Пример #6
0
        public static object FromBytes(byte[] bytes, int type, bool doNotAdapt)
        {
#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
            if (type == AMF0 || type == AMF3)
            {
#endif
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                using (FlashorbBinaryReader reader = new FlashorbBinaryReader(stream))
                {
                    IAdaptingType adpatingType = Weborb.Protocols.Amf.RequestParser.readData(reader, type == AMF0 ? 0 : 3);

                    if (doNotAdapt)
                    {
                        return(adpatingType);
                    }
                    else
                    {
                        return(adpatingType.defaultAdapt());
                    }
                }
            }
#if (!UNIVERSALW8 && !SILVERLIGHT && !PURE_CLIENT_LIB && !WINDOWS_PHONE8)
        }

        else
        {
            using (MemoryStream stream = new MemoryStream(bytes))
            {
                Weborb.Protocols.Wolf.RequestParser parser = Weborb.Protocols.Wolf.RequestParser.GetInstance();
                Request requestObj = parser.Parse(stream);
                return(requestObj.getRequestBodyData());
            }
        }
#endif
        }
Пример #7
0
        internal static Object AsObject(AnonymousObject obj, String key)
        {
            IAdaptingType adaptingType = (IAdaptingType)obj.Properties[key];

            return(adaptingType == null ? null : adaptingType.defaultAdapt());
        }
Пример #8
0
        public Object createObject(IAdaptingType iAdaptingType)
        {
            if (iAdaptingType is NamedObject)
            {
                iAdaptingType = ((NamedObject)iAdaptingType).TypedObject;
            }

            if (iAdaptingType.GetType() == typeof(NullType))
            {
                return(null);
            }

            if (iAdaptingType is AnonymousObject)
            {
                Dictionary <object, object> properties = (Dictionary <object, object>)iAdaptingType.defaultAdapt();
                String geoJson = (String)properties["geoJson"];

                if (geoJson == null)
                {
                    return(null);
                }

                String   geomClass = (String)properties["geomClass"];
                int      srsId     = (int)properties["srsId"];
                Geometry geometry  = new GeometryDTO(geomClass, srsId, geoJson).ToGeometry <Geometry>();

                return(geometry);
            }
            else
            {
                throw new System.Exception("Unknown type");
            }
        }
Пример #9
0
 public object defaultAdapt()
 {
     return(Object != null?Object.defaultAdapt() : null);
 }