public static void setParser(IJSONParser parser) { if (_parser != null) { throw new PinningException("IJSONParser interface has already been initialized."); } _parser = parser; }
public JSONDocument(IDocument inner, IJSONParser parser) { if (parser == null) { throw new StorageException("A JSON parser is required when creating a JSONDocument."); } this.inner = inner; this.parser = parser; }
public AssetPinset(string name, IJSONParser parser) { AssetPinset assetPinset = this; if (parser == null) { throw new HTTPException("JSON parser is required for AssetPinset."); } UnityThreadHelper.Dispatcher.Dispatch(delegate { assetPinset.loadPinsetConfiguration(name, parser); }); }
public void TestNewHostCorrectNoOfColons() { uut = new NewHostParser(); Host testHost = new Host(); var props = testHost.GetType().GetProperties(); var noOfProps = props.Length; var parsed = uut.ParsedData(testHost); var noOfColons = parsed.Split(':').Length - 1; Assert.That(noOfProps, Is.EqualTo(noOfColons)); }
public IJSONDocument getJSONDocument(string specification) { IJSONParser parser = factory.getParser(); if (parser == null) { throw new StorageException("No JSON parser available for document creation."); } IDocument fileDocument = getFileDocument(specification); if (fileDocument == null) { return(null); } return(new JSONDocument(fileDocument, parser)); }
public void TestPhotoParser() { uut = new PhotoParser(); var testPhoto = new PhotoToServer { Bytes = new byte[1234], Pin = "testpin" }; var parsed = uut.ParsedData(testPhoto); var c = new TestContains(parsed.Contains); Assert.That(c("pictureString") && c(Convert.ToBase64String(new byte[1234])) && c("eventPin") && c("testpin")); }
public void TestGuestParser() { uut = new GuestParser(); var testGuest = new Guest { Pin = "testpin", Username = "******" }; var parsed = uut.ParsedData(testGuest); var c = new TestContains(parsed.Contains); Assert.That(c("Pin") && c("testpin") && c("Name") && c("testusername")); }
public void TestHostParser() { uut = new HostParser(); var testHost = new Host { Password = "******", Email = "testemail", Name = "testname" }; var parsed = uut.ParsedData(testHost); var c = new TestContains(parsed.Contains); Assert.That(c("Password") && c("testpassword") && c("UserName") && c("testemail")); }
private void loadPinsetConfiguration(string name, IJSONParser parser) { content = Resources.Load(name) as TextAsset; pinningInfo = new Dictionary <string, IList <IPinningInfo> >(); hostInfo = new Dictionary <string, IHostInfo>(); try { if (!parser.Parse(content.text)) { return; } IDictionary <string, object> dictionary = parser.AsDictionary(); IDictionary <string, object> dictionary2 = (IDictionary <string, object>)dictionary["pinset"]; if (dictionary2 != null) { foreach (KeyValuePair <string, object> item in dictionary2) { string key = item.Key; IList <IPinningInfo> list = new List <IPinningInfo>(); pinningInfo[key] = list; IEnumerable enumerable = (IEnumerable)item.Value; foreach (object item2 in enumerable) { list.Add(new PinningInfo((IDictionary <string, object>)item2)); Debug.Log("Added " + key + " : " + item2.ToString() + " to pinset"); } } } IDictionary <string, object> dictionary3 = (IDictionary <string, object>)dictionary["hosts"]; if (dictionary3 == null) { return; } foreach (KeyValuePair <string, object> item3 in dictionary3) { string key = item3.Key; hostInfo[key] = new HostInfo((IDictionary <string, object>)item3.Value); } } catch (Exception ex) { Debug.LogError("Unable to parse pinset." + ex.Message); Debug.LogException(ex); } }
public void TestNewHostParser() { uut = new NewHostParser(); Host testHost = new Host { Email = "testmail", Name = "testname", Password = "******" }; var output = uut.ParsedData(testHost); var c = new TestContains(output.Contains); Assert.That(c("Email") && c("testmail") && c("Name") && c("testname") && c("Password") && c("testpassword")); }
public ImportJSONCommand(IJSONParser jsonParser, IMovieService movieService, IStarService starService) { if (jsonParser == null) { throw new ArgumentNullException("JSON parser cannnot be null."); } if (movieService == null) { throw new ArgumentNullException("Movie service cannnot be null."); } if (starService == null) { throw new ArgumentNullException("Star service cannnot be null."); } this.jsonParser = jsonParser; this.movieService = movieService; this.starService = starService; }
public void TestNewEventParser() { uut = new NewEventParser(); var testEvent = new EventModel { Description = "testdescription", EndDate = DateTime.MinValue, Location = "testlocation", Name = "testname", StartDate = DateTime.MinValue }; var parsed = uut.ParsedData(testEvent); var c = new TestContains(parsed.Contains); Assert.That(c("Description") && c("testdescription") && c("EndDate") && c(DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ss")) && c("StartDate") && c(DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ss")) && c("Location") && c("testlocation") && c("Name") && c("testname")); }
public void TestGenerateParserFactory(DataType d, IJSONParser pars) { IJSONParser testPars = ParserFactory.Generate(d); Assert.That(testPars.GetType(), Is.EqualTo(pars.GetType())); }
public DefaultPinsetFactory(IStorage storage, IJSONParser parser) { this.storage = storage; this.parser = parser; loadDefaultPinset(); }
private FileSystemStorageFactory(IJSONParser parser) { this.parser = parser; }