/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 2.0.12
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace SLNet {

using System;
using System.Runtime.InteropServices;

public class FileProgressStruct : IDisposable {
  private HandleRef swigCPtr;
  protected bool swigCMemOwn;

  internal FileProgressStruct(IntPtr cPtr, bool cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(FileProgressStruct obj) {

    if (obj != null)
    {
	if (obj.firstDataChunkIsCached)
        {
  	     	obj.SetFirstDataChunk(obj.firstDataChunk, obj.firstDataChunk.Length);
 	}
  	if (obj.iriDataChunkIsCached)
        {
		obj.SetIriDataChunk(obj.iriDataChunk, obj.iriDataChunk.Length);
	}
	obj.firstDataChunkIsCached=false;
	obj.iriDataChunkIsCached=false;
    }

    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~FileProgressStruct() {
    Dispose();
  }

  public virtual void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          SLikeNetPINVOKE.delete_FileProgressStruct(swigCPtr);
        }
        swigCPtr = new HandleRef(null, IntPtr.Zero);
      }
      GC.SuppressFinalize(this);
    }
  }

    private bool firstDataChunkIsCached = false;
    private byte[] firstDataChunkCache;
    private bool iriDataChunkIsCached = false;
    private byte[] iriDataChunkCache;

  public OnFileStruct onFileStruct {
    set {
      SLikeNetPINVOKE.FileProgressStruct_onFileStruct_set(swigCPtr, OnFileStruct.getCPtr(value));
    } 
    get {
      IntPtr cPtr = SLikeNetPINVOKE.FileProgressStruct_onFileStruct_get(swigCPtr);
      OnFileStruct ret = (cPtr == IntPtr.Zero) ? null : new OnFileStruct(cPtr, false);
      return ret;
    } 
  }

  public uint partCount {
    set {
      SLikeNetPINVOKE.FileProgressStruct_partCount_set(swigCPtr, value);
    } 
    get {
      uint ret = SLikeNetPINVOKE.FileProgressStruct_partCount_get(swigCPtr);
      return ret;
    } 
  }

  public uint partTotal {
    set {
      SLikeNetPINVOKE.FileProgressStruct_partTotal_set(swigCPtr, value);
    } 
    get {
      uint ret = SLikeNetPINVOKE.FileProgressStruct_partTotal_get(swigCPtr);
      return ret;
    } 
  }

  public uint dataChunkLength {
    set {
      SLikeNetPINVOKE.FileProgressStruct_dataChunkLength_set(swigCPtr, value);
    } 
    get {
      uint ret = SLikeNetPINVOKE.FileProgressStruct_dataChunkLength_get(swigCPtr);
      return ret;
    } 
  }

  public byte[] firstDataChunk {
	set 
	{
	    	firstDataChunkCache=value;
		firstDataChunkIsCached = true;
		SetFirstDataChunk (value, value.Length);    
	}
get
        {
            byte[] returnArray;
            if (!firstDataChunkIsCached)
            {
                IntPtr cPtr = SLikeNetPINVOKE.FileProgressStruct_firstDataChunk_get (swigCPtr);
                int len = (int) dataChunkLength;
		if (len<=0)
		{
			return null;
		}
                returnArray = new byte[len];
                byte[] marshalArray = new byte[len];
                Marshal.Copy(cPtr, marshalArray, 0, len);
                marshalArray.CopyTo(returnArray, 0);
                firstDataChunkCache = returnArray;
                firstDataChunkIsCached = true;
            }
            else
            {
                returnArray = firstDataChunkCache;
            }
            return returnArray;
        }
  }

  public byte[] iriDataChunk {
	set 
	{
	    	iriDataChunkCache=value;
		iriDataChunkIsCached = true;
		SetIriDataChunk (value, value.Length);    
	}
get
        {
            byte[] returnArray;
            if (!iriDataChunkIsCached)
            {
                IntPtr cPtr = SLikeNetPINVOKE.FileProgressStruct_iriDataChunk_get (swigCPtr);
                int len = (int) dataChunkLength;
		if (len<=0)
		{
			return null;
		}
                returnArray = new byte[len];
                byte[] marshalArray = new byte[len];
                Marshal.Copy(cPtr, marshalArray, 0, len);
                marshalArray.CopyTo(returnArray, 0);
                iriDataChunkCache = returnArray;
                iriDataChunkIsCached = true;
            }
            else
            {
                returnArray = iriDataChunkCache;
            }
            return returnArray;
        }
  }

  public uint iriWriteOffset {
    set {
      SLikeNetPINVOKE.FileProgressStruct_iriWriteOffset_set(swigCPtr, value);
    } 
    get {
      uint ret = SLikeNetPINVOKE.FileProgressStruct_iriWriteOffset_get(swigCPtr);
      return ret;
    } 
  }

  public SystemAddress senderSystemAddress {
    set {
      SLikeNetPINVOKE.FileProgressStruct_senderSystemAddress_set(swigCPtr, SystemAddress.getCPtr(value));
    } 
    get {
      IntPtr cPtr = SLikeNetPINVOKE.FileProgressStruct_senderSystemAddress_get(swigCPtr);
      SystemAddress ret = (cPtr == IntPtr.Zero) ? null : new SystemAddress(cPtr, false);
      return ret;
    } 
  }

  public RakNetGUID senderGuid {
    set {
      SLikeNetPINVOKE.FileProgressStruct_senderGuid_set(swigCPtr, RakNetGUID.getCPtr(value));
    } 
    get {
      IntPtr cPtr = SLikeNetPINVOKE.FileProgressStruct_senderGuid_get(swigCPtr);
      RakNetGUID ret = (cPtr == IntPtr.Zero) ? null : new RakNetGUID(cPtr, false);
      return ret;
    } 
  }

  public bool allocateIrIDataChunkAutomatically {
    set {
      SLikeNetPINVOKE.FileProgressStruct_allocateIrIDataChunkAutomatically_set(swigCPtr, value);
    } 
    get {
      bool ret = SLikeNetPINVOKE.FileProgressStruct_allocateIrIDataChunkAutomatically_get(swigCPtr);
      return ret;
    } 
  }

  public FileProgressStruct() : this(SLikeNetPINVOKE.new_FileProgressStruct(), true) {
  }

  private void SetFirstDataChunk(byte[] inByteArray, int numBytes) {
    SLikeNetPINVOKE.FileProgressStruct_SetFirstDataChunk(swigCPtr, inByteArray, numBytes);
  }

  private void SetIriDataChunk(byte[] inByteArray, int numBytes) {
    SLikeNetPINVOKE.FileProgressStruct_SetIriDataChunk(swigCPtr, inByteArray, numBytes);
  }

}

}
