static public bool ReprocessTillComplete <T>(this IEnumerable <T> item, TryProcess <T> process) { if (item != null) { int total_number = 0; int previous_total_number = 0; int number_failed = 0; int previous_number_failed = 0; do { previous_total_number = total_number; previous_number_failed = number_failed; number_failed = item.Count(i => process(i) == false, out total_number); } while (number_failed > 0 || total_number != previous_total_number); if (number_failed <= 0) { return(true); } } return(false); }
public MessageProcessor(Syncronizer s, TryProcess <Buffer> r) { message_queue = new List <Buffer>(); sequenced_message_queue = new Dictionary <int, Buffer>(); ordered_message_queue = new Dictionary <int, List <Buffer> >(); read_process = r; syncronizer = s; }
public void Touch(string label, TryProcess process, bool create_undo_state) { if (target_type.CanBeTreatedAs <UnityEngine.Object>()) { if (create_undo_state) { Undo.RecordObjects( objects.Convert <UnityEngine.Object>().ToArray(), label ); } if (process()) { objects .Convert <IEditSerializationCallbackReciever>() .Process(r => r.OnBeforeEditSerialize()); objects .Convert <ISerializationCallbackReceiver>() .Process(r => r.OnBeforeSerialize()); objects .Convert <UnityEngine.Object>() .Narrow(o => o.IsPrefabInstance()) .Process(o => PrefabUtility.RecordPrefabInstancePropertyModifications(o)); objects .Convert <UnityEngine.Object>() .Skip(o => o.IsSceneObject()) .Process(o => EditorUtility.SetDirty(o)); } if (create_undo_state) { Undo.FlushUndoRecordObjects(); } } else { if (parent != null) { parent.Touch(label, process, create_undo_state); } else { process(); } } }
static public bool ProcessOR <T>(this IEnumerable <T> item, TryProcess <T> process) { bool return_value = false; if (item != null) { foreach (T sub_item in item) { return_value |= process(sub_item); } } return(return_value); }
static public AttemptResult AttemptRead(this StreamSystem item, string path, TryProcess <Stream> process, long milliseconds = StreamSystem.DEFAULT_WAIT) { Stream stream; AttemptResult result = item.OpenStreamForReading(path, out stream, milliseconds); using (stream) { if (result.IsDesired()) { if (process(stream) == false) { result = AttemptResult.Failed; } } } return(result); }
static public bool ProcessTillComplete <T>(this IEnumerable <T> item, TryProcess <T> process) { if (item != null) { List <T> failed = new List <T>(item); do { failed.RemoveAll(delegate(T sub_item) { return(process(sub_item)); }); }while (failed.IsNotEmpty()); if (failed.IsEmpty()) { return(true); } } return(false); }
static public AttemptResult AttemptRead(this StreamSystemStream item, TryProcess <Stream> process, long milliseconds = StreamSystem.DEFAULT_WAIT) { return(item.GetStreamSystem().AttemptRead(item.GetPath(), process, milliseconds)); }
protected Message CreateMessage(MessageType type, NetDeliveryMethod delivery_method, TryProcess <Buffer> process) { bool is_valid = false; Message message = CreateMessage(type, delivery_method, delegate(Buffer buffer) { is_valid = process(buffer); }); if (is_valid) { return(message); } return(null); }
static public bool ProcessTillCompleteOrStagnated <T>(this IEnumerable <T> item, TryProcess <T> process) { if (item != null) { int old_count; List <T> failed = new List <T>(item); do { old_count = failed.Count; failed.RemoveAll(delegate(T sub_item) { return(process(sub_item)); }); }while (failed.IsNotEmpty() && old_count != failed.Count); if (failed.IsEmpty()) { return(true); } } return(false); }