public static void AddTypeWriter( Type mappedType, ITypeWriter writer )
      {
      //if( Weborb.Util.License.LicenseManager.GetInstance().IsStandardLicense() )
      //    throw new Exception( "cannot register custom serializers, this feature is available in WebORB Professional Edition" );

      writers[ mappedType ] = writer;
      }
        public void Add(string @namespace, string name, ITypeWriter typeWriterBase)
        {
            if (name.ShouldIgnoreTypeByName())
                return;

            var fullname = @namespace + "." + name;


            // HACK:
            // Types in here are causing some issues - removing for now - will work on later
            if (fullname.StartsWith("Windows.UI.Input.Inking") ||
                false)
            {
                return;
            }

            if (!types.ContainsKey(fullname))
            {
                types.Add(fullname, typeWriterBase);
            }
        }
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(ActualOnly);
 }
Exemple #4
0
 public NullableTypeWriter(ITypeWriter complexTypeWriter, ITypeWriter nullWriter)
 {
     this.complexTypeWriter = complexTypeWriter;
     this.nullWriter        = nullWriter;
 }
 public void setContextWriter( ITypeWriter writer )
 {
     this.contextWriter = writer;
 }
Exemple #6
0
 public void addCachedWriter(Type type, ITypeWriter typeWriter)
 {
     cachedWriters[type] = typeWriter;
 }
 protected override void SerializeResponseBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(ServerInfoList);
 }
Exemple #8
0
 protected override void SerializeResponseBody(ITypeWriter typeWriter)
 {
 }
Exemple #9
0
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
 }
 protected abstract void SerializeBody(ITypeWriter typeWriter);
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(Secret);
 }
Exemple #12
0
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
     typeWriter.WriteDictionary(MatchMakingProperties, typeWriter.Write);
 }
 public void Serialize(ITypeWriter typeWriter)
 {
     typeWriter.Write(OperationCode);
     SerializeBody(typeWriter);
 }
Exemple #14
0
 public TypeHierarchyWriter(ITypeWriter typeWriter, TextWriter writer)
 {
     _typeWriter = typeWriter;
     _writer     = writer;
 }
 protected override void SerializeBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(SessionId);
     SerializeRequestBody(typeWriter);
 }
Exemple #16
0
        public void write(object obj, IProtocolFormatter writer)
        {
            Array arrayObj = null;

            if (obj is IWebORBArray)
            {
                IEnumerator en = ((IWebORBArray)obj).GetEnumerator();
                arrayObj = new object[((IWebORBArray)obj).Count];

                int i = 0;
                while (en.MoveNext())
                {
                    arrayObj.SetValue(en.Current, i++);
                }
            }
            else
            {
                //TODO: test out this cast!
                arrayObj = (Array)obj;
            }

            if (obj.GetType().IsAssignableFrom(typeof(Byte[])))
            {
                Byte[] byteArray = new byte[arrayObj.Length];

                for (int i = 0; i < arrayObj.Length; i++)
                {
                    byteArray[i] = (Byte)arrayObj.GetValue(i);
                }

                writer.WriteByteArray(byteArray);
                return;
            }

            if (arrayObj.Rank > 1)
            {
                multiDimArrayWriter.write(arrayObj, writer);
                return;
            }

            writer.BeginWriteArray(arrayObj.Length);

            bool genericArray = arrayObj.GetType().GetElementType().BaseType == null;

            if (genericArray)
            {
                for (int i = 0; i < arrayObj.Length; i++)
                {
                    //Log.log( "REFCACHE", "WRITING ARRAY ELEMENT " + i );
                    object      value      = arrayObj.GetValue(i);
                    ITypeWriter typeWriter = MessageWriter.getWriter(value, writer);
                    typeWriter.write(value, writer);
                    //Log.log( "REFCACHE", "DONE WRITING ARRAY ELEMENT " + i );
                }
            }
            else
            {
                ITypeWriter typeWriter    = null;
                ITypeWriter contextWriter = null;


                for (int i = 0; i < arrayObj.Length; i++)
                {
                    object value = arrayObj.GetValue(i);

                    if (contextWriter == null)
                    {
                        typeWriter    = MessageWriter.getWriter(value, writer);
                        contextWriter = writer.getContextWriter();
                    }
                    else
                    {
                        writer.setContextWriter(contextWriter);
                    }

                    typeWriter.write(value, writer);
                }
            }

            writer.EndWriteArray();
        }
 public void Serialize(ITypeWriter typeWriter)
 {
     typeWriter.Write(Data1);
     typeWriter.Write(Data2);
     typeWriter.Write(Data3);
 }
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(RoomId);
 }
Exemple #19
0
 public DateWriter(bool isReferenceable)
 {
     referenceWriter      = new DateReferenceWriter();
     this.isReferenceable = isReferenceable;
 }
Exemple #20
0
 protected override void SerializeBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(Uri);
 }
Exemple #21
0
 public DateWriter( bool isReferenceable )
 {
   referenceWriter = new DateReferenceWriter();
   this.isReferenceable = isReferenceable;
 }
 public void Serialize(ITypeWriter typeWriter)
 {
     typeWriter.Write(Id);
     SerializeBody(typeWriter);
 }
        public void WriteObject(string className, IDictionary objectFields, IProtocolFormatter writer)
        {
            IEnumerator      en            = objectFields.Keys.GetEnumerator();
            V3ReferenceCache cache         = (V3ReferenceCache)writer.GetReferenceCache();
            String           traitsClassId = className;

            List <String> toRemove = new List <String>();

            while (en.MoveNext())
            {
                String fieldName = en.Current.ToString();
                object obj       = objectFields[fieldName];

                if (obj != null && obj is ICollection && ((ICollection)obj).Count == 0)
                {
                    toRemove.Add(fieldName);
                    continue;
                }

                if (obj != null && obj.GetType().IsArray&& ((Object[])obj).Length == 0)
                {
                    toRemove.Add(fieldName);
                    continue;
                }
            }

            foreach (Object key in toRemove)
            {
                objectFields.Remove(key);
            }

            en = objectFields.Keys.GetEnumerator();

            if (traitsClassId == null)
            {
                StringBuilder sb = new StringBuilder();

                while (en.MoveNext())
                {
                    sb.Append(en.Current.ToString());
                    sb.Append("-");
                }

                traitsClassId = sb.ToString();
                en.Reset();
            }

            if (cache.HasTraits(traitsClassId))
            {
                writer.DirectWriteBytes(new byte[] { (byte)Datatypes.OBJECT_DATATYPE_V3 });
                int    traitId = (int)cache.GetTraitsId(traitsClassId);
                byte[] bytes   = FlashorbBinaryWriter.GetVarIntBytes(0x1 | traitId << 2);
                writer.DirectWriteBytes(bytes);
            }
            else
            {
                writer.BeginWriteNamedObject(className, objectFields.Count);

                if (className == null)
                {
                    cache.AddToTraitsCache(traitsClassId);
                }

                while (en.MoveNext())
                {
                    string fieldName = en.Current.ToString();

                    if (Log.isLogging(LoggingConstants.DEBUG))
                    {
                        Log.log(LoggingConstants.DEBUG, "serializing property/field : " + fieldName);
                    }

                    writer.WriteFieldName(fieldName);
                }

                en.Reset();
            }

            while (en.MoveNext())
            {
                Object fieldName = en.Current;

                if (Log.isLogging(LoggingConstants.DEBUG))
                {
                    Log.log(LoggingConstants.DEBUG, "serializing property/field : " + fieldName);
                }

                //writer.BeginWriteFieldValue();

                //try
                //{
                //MessageWriter.writeObject( objectFields[ fieldName ], writer );
                //Log.log( "REFCACHE", "WRITING FIELD " + fieldName );
                object obj = objectFields[fieldName];

                if (obj != null && obj is ICollection && ((ICollection)obj).Count == 0)
                {
                    continue;
                }

                if (obj != null && obj.GetType().IsArray&& ((Object[])obj).Length == 0)
                {
                    continue;
                }

                ITypeWriter typeWriter = MessageWriter.getWriter(obj, writer);
                typeWriter.write(obj, writer);
                //Log.log( "REFCACHE", "DONE WRITING FIELD " + fieldName );
                //}
                //catch( Exception exception )
                //{
                //	if( Log.isLogging( LoggingConstants.ERROR ) )
                //		Log.log( LoggingConstants.ERROR, "unable to serialize object's field " + fieldName, exception );
                //}
                //finally
                //{
                //	writer.EndWriteFieldValue();
                //}
            }

            writer.EndWriteNamedObject();
        }
 protected override void SerializeResponseBody(ITypeWriter typeWriter)
 {
     typeWriter.WriteEntity(JoinInfo);
 }
Exemple #25
0
 protected override void SerializeBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(ChangeId);
 }
Exemple #26
0
 protected override void SerializeRequestBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(ServerIdentity);
 }
 protected override void SerializeResponseBody(ITypeWriter typeWriter)
 {
     typeWriter.Write(CreatedDate);
     typeWriter.Write((byte)State);
 }
 public void addCachedWriter( Type type, ITypeWriter typeWriter )
 {
     cachedWriters[ type ] = typeWriter;
 }
Exemple #29
0
 public void setContextWriter(ITypeWriter writer)
 {
     this.contextWriter = writer;
 }