Пример #1
0
        protected override void WriteElements(IWriteContext context, object obj, ArrayInfo
                                              info)
        {
            IEnumerator objects = AllElements(Container(context), obj);

            if (HasNullBitmap(info))
            {
                BitMap4         nullBitMap       = new BitMap4(info.ElementCount());
                IReservedBuffer nullBitMapBuffer = context.Reserve(nullBitMap.MarshalledLength());
                int             currentElement   = 0;
                while (objects.MoveNext())
                {
                    object current = objects.Current;
                    if (current == null)
                    {
                        nullBitMap.SetTrue(currentElement);
                    }
                    else
                    {
                        context.WriteObject(DelegateTypeHandler(), current);
                    }
                    currentElement++;
                }
                nullBitMapBuffer.WriteBytes(nullBitMap.Bytes());
            }
            else
            {
                while (objects.MoveNext())
                {
                    context.WriteObject(DelegateTypeHandler(), objects.Current);
                }
            }
        }
Пример #2
0
 protected virtual void WriteElements(IWriteContext context, object obj, ArrayInfo
                                      info)
 {
     if (HandleAsByteArray(obj))
     {
         context.WriteBytes((byte[])obj);
     }
     else
     {
         // byte[] performance optimisation
         if (HasNullBitmap(info))
         {
             BitMap4 nullItems = NullItemsMap(ArrayReflector(Container(context)), obj);
             WriteNullBitmap(context, nullItems);
             for (int i = 0; i < info.ElementCount(); i++)
             {
                 if (!nullItems.IsTrue(i))
                 {
                     context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
                 }
             }
         }
         else
         {
             for (int i = 0; i < info.ElementCount(); i++)
             {
                 context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
             }
         }
     }
 }
Пример #3
0
		private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair
			 handlers)
		{
			IEnumerator elements = map.GetEnumerator();
			while (elements.MoveNext())
			{
				DictionaryEntry entry = (DictionaryEntry)elements.Current;
				context.WriteObject(handlers._keyHandler, entry.Key);
				context.WriteObject(handlers._valueHandler, entry.Value);
			}
		}
		private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair
			 handlers)
		{
			IEnumerator elements = map.Keys.GetEnumerator();
			while (elements.MoveNext())
			{
				object key = elements.Current;
				context.WriteObject(handlers._keyHandler, key);
				context.WriteObject(handlers._valueHandler, map[key]);
			}
		}
Пример #5
0
        private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair
                                   handlers)
        {
            IEnumerator elements = map.Keys.GetEnumerator();

            while (elements.MoveNext())
            {
                object key = elements.Current;
                context.WriteObject(handlers._keyHandler, key);
                context.WriteObject(handlers._valueHandler, map[key]);
            }
        }
Пример #6
0
        private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair
                                   handlers)
        {
            IEnumerator elements = map.GetEnumerator();

            while (elements.MoveNext())
            {
                DictionaryEntry entry = (DictionaryEntry)elements.Current;
                context.WriteObject(handlers._keyHandler, entry.Key);
                context.WriteObject(handlers._valueHandler, entry.Value);
            }
        }
Пример #7
0
 private void WriteObject(IWriteContext context, ITypeHandler4 typeHandler, object
                          obj)
 {
     if (IsPlainObject(obj))
     {
         context.WriteObject(new PlainObjectHandler(), obj);
         return;
     }
     if (Handlers4.UseDedicatedSlot(context, typeHandler))
     {
         context.WriteObject(obj);
     }
     else
     {
         typeHandler.Write(context, obj);
     }
 }
Пример #8
0
        private static void WriteElements(IWriteContext context, IEnumerable enumerable, ITypeHandler4 elementHandler)
        {
            IEnumerator elements = enumerable.GetEnumerator();

            while (elements.MoveNext())
            {
                context.WriteObject(elementHandler, elements.Current);
            }
        }
Пример #9
0
		private void WriteElements(IWriteContext context, ICollection collection, ITypeHandler4
			 elementHandler)
		{
			IEnumerator elements = collection.GetEnumerator();
			while (elements.MoveNext())
			{
				context.WriteObject(elementHandler, elements.Current);
			}
		}
Пример #10
0
        private void WriteElements(IWriteContext context, ICollection collection, ITypeHandler4
                                   elementHandler)
        {
            var elements = collection.GetEnumerator();

            while (elements.MoveNext())
            {
                context.WriteObject(elementHandler, elements.Current);
            }
        }
Пример #11
0
		private void WriteObject(IWriteContext context, ITypeHandler4 typeHandler, object
			 obj)
		{
			if (IsPlainObject(obj))
			{
				context.WriteObject(new PlainObjectHandler(), obj);
				return;
			}
			if (Handlers4.UseDedicatedSlot(context, typeHandler))
			{
				context.WriteObject(obj);
			}
			else
			{
				typeHandler.Write(context, obj);
			}
		}
Пример #12
0
		public void Write(IWriteContext context, object obj)
		{
			context.WriteObject(TypeHandler(), new PSObjectWrapper((PSObject)obj));
		}
Пример #13
0
		protected virtual void WriteElements(IWriteContext context, object obj, ArrayInfo
			 info)
		{
			if (HandleAsByteArray(obj))
			{
				context.WriteBytes((byte[])obj);
			}
			else
			{
				// byte[] performance optimisation
				if (HasNullBitmap(info))
				{
					BitMap4 nullItems = NullItemsMap(ArrayReflector(Container(context)), obj);
					WriteNullBitmap(context, nullItems);
					for (int i = 0; i < info.ElementCount(); i++)
					{
						if (!nullItems.IsTrue(i))
						{
							context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
						}
					}
				}
				else
				{
					for (int i = 0; i < info.ElementCount(); i++)
					{
						context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
					}
				}
			}
		}
Пример #14
0
 public void Write(IWriteContext context, object obj)
 {
     context.WriteObject(TypeHandler(), new PSObjectWrapper((PSObject)obj));
 }
Пример #15
0
		private static void WriteElements(IWriteContext context, IEnumerable enumerable, ITypeHandler4 elementHandler)
		{
			IEnumerator elements = enumerable.GetEnumerator();
			while (elements.MoveNext())
			{
				context.WriteObject(elementHandler, elements.Current);
			}
		}
Пример #16
0
 protected override void WriteElements(IWriteContext context, object obj, ArrayInfo
     info)
 {
     var objects = AllElements(Container(context), obj);
     if (HasNullBitmap(info))
     {
         var nullBitMap = new BitMap4(info.ElementCount());
         var nullBitMapBuffer = context.Reserve(nullBitMap.MarshalledLength());
         var currentElement = 0;
         while (objects.MoveNext())
         {
             var current = objects.Current;
             if (current == null)
             {
                 nullBitMap.SetTrue(currentElement);
             }
             else
             {
                 context.WriteObject(DelegateTypeHandler(), current);
             }
             currentElement++;
         }
         nullBitMapBuffer.WriteBytes(nullBitMap.Bytes());
     }
     else
     {
         while (objects.MoveNext())
         {
             context.WriteObject(DelegateTypeHandler(), objects.Current);
         }
     }
 }