示例#1
0
    public static string ToJson <T>(T[] array, bool prettyPrint)
    {
        ArrayWrapper <T> wrapper = new ArrayWrapper <T>();

        wrapper.Generations = array;
        return(JsonUtility.ToJson(wrapper, prettyPrint));
    }
示例#2
0
    public static ArrayWrapper Create(string[] array)
    {
        ArrayWrapper wrapper = new ArrayWrapper();

        wrapper.array = array;
        return(wrapper);
    }
示例#3
0
    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);
        }
示例#5
0
    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>();
    }
示例#6
0
    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);
    }
示例#8
0
 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;
 }
示例#9
0
        public static string ArrayToJson <T>(T[] array)
        {
            ArrayWrapper <T> wrapper = new ArrayWrapper <T>();

            wrapper.Items = array;
            return(JsonUtility.ToJson(wrapper));
        }
示例#10
0
    public static string ToJson <T>(T[] array, bool prettyPrint)
    {
        ArrayWrapper <T> arrayWrapper = new ArrayWrapper <T>();

        arrayWrapper.Objects = array;
        return(JsonUtility.ToJson(arrayWrapper, prettyPrint));
    }
示例#11
0
    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");
        }
    }
示例#12
0
    public static string ToJson <T>(T[] array)
    {
        ArrayWrapper <T> arrayWrapper = new ArrayWrapper <T>();

        arrayWrapper.Objects = array;
        return(JsonUtility.ToJson(arrayWrapper));
    }
示例#13
0
        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);
        }
示例#15
0
    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");
        }
    }
示例#16
0
        public static string ToJsonArray <T>(T[] _array)
        {
            ArrayWrapper <T> wrapper = new ArrayWrapper <T>();

            wrapper.Array = _array;
            return(JsonUtility.ToJson(wrapper, true));
        }
示例#17
0
        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);
        }
示例#18
0
        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;
        }
示例#20
0
        public void ArrayForPreDecrement(ArrayWrapper <Action> arrayWrapper)
        {
            var actions = arrayWrapper.Array;

            for (var i = actions.Length; i-- > 0;)
            {
                //actions[i]();
            }
        }
示例#21
0
        public void ArrayForPostDecrement(ArrayWrapper <Action> arrayWrapper)
        {
            var actions = arrayWrapper.Array;

            for (var i = actions.Length - 1; i > 0; i--)
            {
                //actions[i]();
            }
        }
示例#22
0
        public void Get___OK()
        {
            int[] array = { 0, 1, 2 };
            var   sut   = new ArrayWrapper <int>(array);

            int actual = sut[1];

            Assert.AreEqual(array[1], actual);
        }
示例#23
0
        public void Set___OK()
        {
            int[] array = { 0, 1, 2 };
            var   sut   = new ArrayWrapper <int>(array);

            sut[2] = 42;

            Assert.AreEqual(42, array[2]);
        }
示例#24
0
        public void TestGeneratorAndDispose()
        {
            ArrayWrapper arrayWrapper = new ArrayWrapper(new List <StackItem>());

            Assert.IsNotNull(arrayWrapper);
            Action action = () => arrayWrapper.Dispose();

            action.Should().NotThrow <Exception>();
        }
示例#25
0
    public static T[] FromJsonArray <T>(string json)
    {
        ArrayWrapper <T> wrapper = JsonUtility.FromJson <ArrayWrapper <T> >(json);

        if (wrapper == null)
        {
            return(null);
        }
        return(wrapper.Generations);
    }
示例#26
0
        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);
        }
示例#27
0
 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);
 }
示例#28
0
 /// <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();
 }
示例#29
0
        public ScrapCommandArgs([NotNull] IEnumerable <TechObject> objects)
        {
            if (objects == null)
            {
                throw new ArgumentNullException("objects");
            }

            _objects = new ArrayWrapper <TechObject>(objects.ToArray());

            SetInitialScrapValue();
        }
示例#30
0
        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());
        }
示例#31
0
 /// <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, "&amp;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;
	}
示例#35
0
                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;
                }
示例#36
0
	public static ArrayWrapper Create(string[] array)
	{
		ArrayWrapper wrapper = new ArrayWrapper();
		wrapper.array = array;
		return wrapper;
	}
示例#37
0
 /// <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, "&amp;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);
 }