public static string ToJson <T>(T[] array, bool prettyPrint) { ArrayWrapper <T> wrapper = new ArrayWrapper <T>(); wrapper.Generations = array; return(JsonUtility.ToJson(wrapper, prettyPrint)); }
public static ArrayWrapper Create(string[] array) { ArrayWrapper wrapper = new ArrayWrapper(); wrapper.array = array; return(wrapper); }
public override void Write(object obj, ES2Writer writer) { ArrayWrapper data = (ArrayWrapper)obj; // Add your writer.Write calls here. writer.Write(data.array); }
private void AddEditorCache(ref PolygonParameters p, List <Vector2[]> list) { CacheKey key = new CacheKey(); key.Texture = p.Texture; key.Rect = p.Rect; CacheEntry e = new CacheEntry(); e.Key = key; e.Value = new ListWrapper(); e.Value.List = new List <ArrayWrapper>(); foreach (Vector2[] v in list) { ArrayWrapper w = new ArrayWrapper(); w.Array = v; e.Value.List.Add(w); } for (int i = 0; i < editorCache.Count; i++) { if (editorCache[i].Key.Equals(key)) { editorCache.RemoveAt(i); editorCache.Insert(i, e); return; } } editorCache.Add(e); }
public override void Read(ES2Reader reader, object c) { ArrayWrapper data = (ArrayWrapper)c; // Add your reader.Read calls here to read the data into the object. data.array = reader.ReadArray <System.String>(); }
public override object Read(ES2Reader reader) { ArrayWrapper data = new ArrayWrapper(); Read(reader, data); return(data); }
static void Main() { ArrayWrapper wrapper = new ArrayWrapper(new[] { "this", "is", "a", "test" }); string strValue = wrapper[2]; // "a" Console.Write(strValue); }
protected override void CommitWrite(DataChanges proposedChanges) { if (proposedChanges != null && proposedChanges.HasData) { if (getRecentDataCalled) { array = copyArray; } else { int n = proposedChanges.Data.Count; if (copyArray != null) { if (array.Data != null) { copyArray.PutData(null, array.Data); } array = copyArray; } for (int i = 0; i < n; i++) { DataPiece piece = proposedChanges.Data[i]; array.PutData(piece.Origin, piece.Data); } } } recentChanges = null; getRecentDataCalled = false; }
public static string ArrayToJson <T>(T[] array) { ArrayWrapper <T> wrapper = new ArrayWrapper <T>(); wrapper.Items = array; return(JsonUtility.ToJson(wrapper)); }
public static string ToJson <T>(T[] array, bool prettyPrint) { ArrayWrapper <T> arrayWrapper = new ArrayWrapper <T>(); arrayWrapper.Objects = array; return(JsonUtility.ToJson(arrayWrapper, prettyPrint)); }
public IEnumerator UploadDate() { Debug.Log("Uploading date..."); Config.currentChildDatesCalendarList.Add(ArrayWrapper.Create(new string[] { memoryDay, memoryMonth, memoryYear })); ES2Web web = new ES2Web(myURL + "&tag=memoriesDates"); yield return(StartCoroutine(web.Upload(Config.currentChildDatesCalendarList))); if (web.isError) { // Enter your own code to handle errors here. Debug.LogError(web.errorCode + ":" + web.error); } if (web.isDone) { Debug.Log("New memoryDate uploaded!"); StartCoroutine("UploadText"); } }
public static string ToJson <T>(T[] array) { ArrayWrapper <T> arrayWrapper = new ArrayWrapper <T>(); arrayWrapper.Objects = array; return(JsonUtility.ToJson(arrayWrapper)); }
protected override void BeginWriteTransaction(DataChanges changes) { if (changes == null || changes.Shape == null) { return; } if (changes.Shape.Length != Rank) { throw new Exception("Changes has wrong shape"); } copyArray = null; recentChanges = changes; getRecentDataCalled = false; bool needEnlarge = false; int n = Rank; int[] shape = array.GetShape(); for (int i = 0; i < n; i++) { if (changes.Shape[i] > shape[i]) { needEnlarge = true; break; } } if (needEnlarge) { copyArray = new ArrayWrapper(n, TypeOfData); copyArray.Data = Array.CreateInstance(copyArray.DataType, changes.Shape); } }
public void ConcatenatedIteratedTest() { Integer[] array1 = { MakeIntegerStackItem(1), MakeIntegerStackItem(7), MakeIntegerStackItem(23) }; Integer[] array2 = { MakeIntegerStackItem(8), MakeIntegerStackItem(47) }; ArrayWrapper it1 = new ArrayWrapper(array1); ArrayWrapper it2 = new ArrayWrapper(array2); ConcatenatedIterator uut = new ConcatenatedIterator(it1, it2); AssertionExtensions.Should((bool)uut.Next()).Be(true); uut.Key().Should().Be(MakeIntegerStackItem(0)); uut.Value().Should().Be(array1[0]); AssertionExtensions.Should((bool)uut.Next()).Be(true); uut.Key().Should().Be(MakeIntegerStackItem(1)); uut.Value().Should().Be(array1[1]); AssertionExtensions.Should((bool)uut.Next()).Be(true); uut.Key().Should().Be(MakeIntegerStackItem(2)); uut.Value().Should().Be(array1[2]); AssertionExtensions.Should((bool)uut.Next()).Be(true); uut.Key().Should().Be(MakeIntegerStackItem(0)); uut.Value().Should().Be(array2[0]); AssertionExtensions.Should((bool)uut.Next()).Be(true); uut.Key().Should().Be(MakeIntegerStackItem(1)); uut.Value().Should().Be(array2[1]); AssertionExtensions.Should((bool)uut.Next()).Be(false); }
public IEnumerator UploadChildNames() { Debug.Log("Starting uploading names..."); List <ArrayWrapper> childNamesList = Config.childNames; childNamesList.Add(ArrayWrapper.Create(new string[] { nameUIInput.value, //Name of the file nameUIInput.value, //Current child name })); //childNamesList.Add (nameUIInput.value); ES2Web web = new ES2Web(myURL + "&tag=names"); yield return(StartCoroutine(web.Upload(childNamesList))); if (web.isError) { // Enter your own code to handle errors here. Debug.LogError(web.errorCode + ":" + web.error); } if (web.isDone) { Debug.Log("New names uploaded!"); StartCoroutine("UploadChildPhotos"); } }
public static string ToJsonArray <T>(T[] _array) { ArrayWrapper <T> wrapper = new ArrayWrapper <T>(); wrapper.Array = _array; return(JsonUtility.ToJson(wrapper, true)); }
public static T[] FromJsonArray <T>(string _rawJsonContent) { // Once you use ToJsonArray to serialize, you dont need to append the prefix yourself. //string jsonContent = "{ \"Array\": " + _rawJsonContent + "}"; ArrayWrapper <T> wrapper = JsonUtility.FromJson <ArrayWrapper <T> >(_rawJsonContent); return(wrapper.Array); }
public void List_is_not_null___OK() { int[] array = { 0, 1, 2 }; var actual = new ArrayWrapper <int>(array); Assert.IsNotNull(actual); }
private void RoundTrip <T>(ref T[] commitments) where T : IBitcoinSerializable, new() { RoundtripJson(ref commitments); var a = new ArrayWrapper <T>(commitments); Roundtrip(ref a); commitments = a.Elements; }
public void ArrayForPreDecrement(ArrayWrapper <Action> arrayWrapper) { var actions = arrayWrapper.Array; for (var i = actions.Length; i-- > 0;) { //actions[i](); } }
public void ArrayForPostDecrement(ArrayWrapper <Action> arrayWrapper) { var actions = arrayWrapper.Array; for (var i = actions.Length - 1; i > 0; i--) { //actions[i](); } }
public void Get___OK() { int[] array = { 0, 1, 2 }; var sut = new ArrayWrapper <int>(array); int actual = sut[1]; Assert.AreEqual(array[1], actual); }
public void Set___OK() { int[] array = { 0, 1, 2 }; var sut = new ArrayWrapper <int>(array); sut[2] = 42; Assert.AreEqual(42, array[2]); }
public void TestGeneratorAndDispose() { ArrayWrapper arrayWrapper = new ArrayWrapper(new List <StackItem>()); Assert.IsNotNull(arrayWrapper); Action action = () => arrayWrapper.Dispose(); action.Should().NotThrow <Exception>(); }
public static T[] FromJsonArray <T>(string json) { ArrayWrapper <T> wrapper = JsonUtility.FromJson <ArrayWrapper <T> >(json); if (wrapper == null) { return(null); } return(wrapper.Generations); }
public void Data_given_as_ArrayWrapper___OK() { var sut = new SwingingDoorCompression(1d); var data = new ArrayWrapper <DataPoint>(RawDataForTrend().ToArray()); var expected = ExpectedForTrend().ToList(); var actual = sut.Process(data).ToArray(); CollectionAssert.AreEqual(expected, actual); }
private static bool Enumerator_Create(ApplicationEngine engine) { if (engine.CurrentContext.EvaluationStack.Pop() is VMArray array) { IEnumerator enumerator = new ArrayWrapper(array); engine.CurrentContext.EvaluationStack.Push(StackItem.FromInterface(enumerator)); return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="sds"></param> /// <param name="name"></param> /// <param name="dims"></param> /// <param name="wrapper"></param> protected MemoryVariable(DataSet sds, string name, string[] dims, ArrayWrapper wrapper) : base(sds, name, dims) { if (wrapper == null) { throw new ArgumentNullException("wrapper"); } this.array = wrapper; Initialize(); }
public ScrapCommandArgs([NotNull] IEnumerable <TechObject> objects) { if (objects == null) { throw new ArgumentNullException("objects"); } _objects = new ArrayWrapper <TechObject>(objects.ToArray()); SetInitialScrapValue(); }
public void TestNext() { List <StackItem> list = new List <StackItem>(); ArrayWrapper arrayWrapper = new ArrayWrapper(list); Assert.AreEqual(false, arrayWrapper.Next()); StackItem stackItem = new Integer(0); list.Add(stackItem); Assert.AreEqual(true, arrayWrapper.Next()); }
/// <summary> /// Put complex types with array property /// </summary> /// <param name='operations'> /// The operations group for this extension method /// </param> /// <param name='complexBody'> /// Please put an array with 4 items: "1, 2, 3, 4", "", null, "&S#$(*Y", /// "The quick brown fox jumps over the lazy dog" /// </param> public static void PutValid(this IArray operations, ArrayWrapper complexBody) { Task.Factory.StartNew(s => ((IArray)s).PutValidAsync(complexBody), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// Test explicitly required array. Please put a valid array-wrapper with /// 'value' = null and the client library should throw before the request is /// sent. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='bodyParameter'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task<Error> PostRequiredArrayPropertyAsync( this IExplicitModel operations, ArrayWrapper bodyParameter, CancellationToken cancellationToken = default(CancellationToken)) { HttpOperationResponse<Error> result = await operations.PostRequiredArrayPropertyWithHttpMessagesAsync(bodyParameter, null, cancellationToken).ConfigureAwait(false); return result.Body; }
/// <summary> /// Test explicitly required array. Please put a valid array-wrapper with /// 'value' = null and the client library should throw before the request is /// sent. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='bodyParameter'> /// </param> public static Error PostRequiredArrayProperty(this IExplicitModel operations, ArrayWrapper bodyParameter) { return Task.Factory.StartNew(s => ((IExplicitModel)s).PostRequiredArrayPropertyAsync(bodyParameter), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public override object Read(ES2Reader reader) { ArrayWrapper data = new ArrayWrapper(); Read(reader, data); return data; }
public static StreamStructCachedArrayWrapper<StereoShortSoundSample> ParseWavData(Stream Stream) { StreamStructCachedArrayWrapper<StereoShortSoundSample> DecodedSamples = null; var RiffWaveReader = new RiffWaveReader(); WavFormatStruct WavFormat; RiffWaveReader.HandleChunk += (ChunkType, ChunkStream) => { switch (ChunkType) { case "fmt ": WavFormat = ChunkStream.ReadStruct<WavFormatStruct>(); break; case "data": #if false DecodedSamples = new ArrayWrapper<StereoShortSoundSample>(PointerUtils.ByteArrayToArray<StereoShortSoundSample>(ChunkStream.ReadAll())); #else DecodedSamples = ChunkStream.ConvertToStreamStructCachedArrayWrapper<StereoShortSoundSample>(16 * 1024); #endif break; default: throw (new NotImplementedException(String.Format("Can't handle chunk '{0}'", ChunkType))); } }; RiffWaveReader.Parse(Stream); //new WaveStream().WriteWave(@"c:\temp\3.wav", DecodedData); //Console.WriteLine("DecodedSamples: {0}", DecodedSamples.Length); //Console.WriteLine("EndSample: {0}", Fact.EndSample); //if (Fact.EndSample == 0) //{ // Fact.EndSample = DecodedSamples.Length / 2; //} //Console.ReadKey(); return DecodedSamples; }
public static ArrayWrapper Create(string[] array) { ArrayWrapper wrapper = new ArrayWrapper(); wrapper.array = array; return wrapper; }
/// <summary> /// Put complex types with array property /// </summary> /// <param name='operations'> /// The operations group for this extension method /// </param> /// <param name='complexBody'> /// Please put an array with 4 items: "1, 2, 3, 4", "", null, "&S#$(*Y", /// "The quick brown fox jumps over the lazy dog" /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public static async Task PutValidAsync( this IArray operations, ArrayWrapper complexBody, CancellationToken cancellationToken = default(CancellationToken)) { await operations.PutValidWithHttpMessagesAsync(complexBody, null, cancellationToken).ConfigureAwait(false); }