Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SaveStreamData"/> class.
 /// </summary>
 /// <param name="streamLogger">A logger for the save stream</param>
 /// <param name="closeStream">A value indicating whether or not the stream should be closed</param>
 /// <param name="headers">The headers for the save stream request</param>
 internal SaveStreamData(IStreamLogger streamLogger, bool closeStream, IEnumerable <KeyValuePair <string, string> > headers)
 {
     ExceptionUtilities.CheckArgumentNotNull(streamLogger, "streamLogger");
     ExceptionUtilities.CheckArgumentNotNull(headers, "headers");
     this.StreamLogger = streamLogger;
     this.CloseStream  = closeStream;
     this.Headers      = headers;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SaveStreamData"/> class.
 /// </summary>
 /// <param name="streamLogger">A logger for the save stream</param>
 /// <param name="closeStream">A value indicating whether or not the stream should be closed</param>
 /// <param name="headers">The headers for the save stream request</param>
 internal SaveStreamData(IStreamLogger streamLogger, bool closeStream, IEnumerable<KeyValuePair<string, string>> headers)
 {
     ExceptionUtilities.CheckArgumentNotNull(streamLogger, "streamLogger");
     ExceptionUtilities.CheckArgumentNotNull(headers, "headers");
     this.StreamLogger = streamLogger;
     this.CloseStream = closeStream;
     this.Headers = headers;
 }
Esempio n. 3
0
        public static void init()
        {
            path = Application.persistentDataPath + "/Storage/logs/logs-" + System.DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".log";
            var dir = Path.GetDirectoryName(path);

            if (!Directory.Exists(dir))
            {
                DirectoryInfo di = Directory.CreateDirectory(dir);
                if (!di.Exists)
                {
                    return;
                }
            }

            //Debug.Log("Logger path: " + path);
            logger = Loggers.NewFileLogger("tag", path, TimeSpan.FromSeconds(30));
            write("sgffu.Log.Service::init()");
        }
Esempio n. 4
0
        /// <summary>
        /// Tracks a call to SetSaveStream
        /// </summary>
        /// <param name="data">The context data.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="name">The name of the stream or null to indicate the default stream.</param>
        /// <param name="saveStreamLogger">A logger for the save stream</param>
        /// <param name="closeStream">A value indicating whether or not to close the stream</param>
        /// <param name="headers">The headers for the request</param>
        public static void TrackSetSaveStream(this DataServiceContextData data, object entity, string name, IStreamLogger saveStreamLogger, bool closeStream, IEnumerable <KeyValuePair <string, string> > headers)
        {
            ExceptionUtilities.CheckArgumentNotNull(data, "data");
            ExceptionUtilities.CheckArgumentNotNull(saveStreamLogger, "saveStreamLogger");
            ExceptionUtilities.CheckArgumentNotNull(headers, "headers");

            EntityDescriptorData descriptorData;

            ExceptionUtilities.Assert(data.TryGetEntityDescriptorData(entity, out descriptorData), "Cannot set save stream on an entity that is not being tracked");

            StreamDescriptorData streamDescriptor;

            if (name == null)
            {
                if (descriptorData.State == EntityStates.Added)
                {
                    descriptorData.DefaultStreamState = EntityStates.Added;
                }
                else
                {
                    descriptorData.DefaultStreamState = EntityStates.Modified;
                }

                streamDescriptor = descriptorData.DefaultStreamDescriptor;
            }
            else
            {
                streamDescriptor = descriptorData.StreamDescriptors.SingleOrDefault(n => n.Name == name);
                if (streamDescriptor == null)
                {
                    streamDescriptor = descriptorData.CreateStreamDescriptorData(EntityStates.Modified, data.GetNextChangeOrder(), name);
                }
                else
                {
                    data.ChangeStateAndChangeOrder(streamDescriptor, EntityStates.Modified, data.GetNextChangeOrder());
                }
            }

            // we need to trap what the product reads from the stream to compare it against what is sent on the wire
            streamDescriptor.SaveStream = new SaveStreamData(saveStreamLogger, closeStream, headers);
        }
        /// <summary>
        /// Tracks a call to SetSaveStream
        /// </summary>
        /// <param name="data">The context data.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="name">The name of the stream or null to indicate the default stream.</param>
        /// <param name="saveStreamLogger">A logger for the save stream</param>
        /// <param name="closeStream">A valud indicating whether or not to close the stream</param>
        /// <param name="headers">The headers for the request</param>
        public static void TrackSetSaveStream(this DataServiceContextData data, object entity, string name, IStreamLogger saveStreamLogger, bool closeStream, IEnumerable<KeyValuePair<string, string>> headers)
        {
            ExceptionUtilities.CheckArgumentNotNull(data, "data");
            ExceptionUtilities.CheckArgumentNotNull(saveStreamLogger, "saveStreamLogger");
            ExceptionUtilities.CheckArgumentNotNull(headers, "headers");

            EntityDescriptorData descriptorData;
            ExceptionUtilities.Assert(data.TryGetEntityDescriptorData(entity, out descriptorData), "Cannot set save stream on an entity that is not being tracked");

            StreamDescriptorData streamDescriptor;
            if (name == null)
            {
                if (descriptorData.State == EntityStates.Added)
                {
                    descriptorData.DefaultStreamState = EntityStates.Added;
                }
                else
                {
                    descriptorData.DefaultStreamState = EntityStates.Modified;
                }

                streamDescriptor = descriptorData.DefaultStreamDescriptor;
            }
            else
            {
                streamDescriptor = descriptorData.StreamDescriptors.SingleOrDefault(n => n.Name == name);
                if (streamDescriptor == null)
                {
                    streamDescriptor = descriptorData.CreateStreamDescriptorData(EntityStates.Modified, data.GetNextChangeOrder(), name);
                }
                else
                {
                    data.ChangeStateAndChangeOrder(streamDescriptor, EntityStates.Modified, data.GetNextChangeOrder());
                }
            }

            // we need to trap what the product reads from the stream to compare it against what is sent on the wire
            streamDescriptor.SaveStream = new SaveStreamData(saveStreamLogger, closeStream, headers);
        }