private void SacuvajIzmene(object sender, RoutedEventArgs e) { var listaSalon = Projekat.Instance.Saloni; switch (operacija) { case Operacija.DODAVANJE: break; case Operacija.IZMENA: foreach (var s in listaSalon) { if (s.Id == salon.Id) { s.Naziv = salon.Naziv; s.Adresa = salon.Adresa; s.Telefon = salon.Telefon; s.Email = salon.Email; s.InternetAdresa = salon.InternetAdresa; s.PIB = salon.PIB; s.MaticniBroj = salon.MaticniBroj; s.ZiroRacun = salon.ZiroRacun; break; } } break; default: break; } GenericSerializer.Serialize("salon.xml", listaSalon); Close(); }
public void GenericSerializer_DeSerializeLoanTypesSerializable_AreSame() { GenericSerializer gs = new GenericSerializer(); var lts = gs.Deserialize <LoanTypesSerializable>("LoanTypes.xml"); Assert.AreSame(lts, new LoanTypesSerializable()); }
private void Copy() { CopiedShapes.Clear(); CopiedLines.Clear(); foreach (IShape i in Selected) { foreach (LineViewModel l in Lines) { // Copy the line if it is originating from a shape. if (l.From.Shape.ID == i.ID) { foreach (IShape j in Selected) { if (l.To.Shape.ID == j.ID) { CopiedLines.Add(l); } } } } CopiedShapes.Add(i); } _memoryOfCopy = GenericSerializer.SerializeToXMLInMemory(saving(CopiedShapes, CopiedLines)); PasteCommand.RaiseCanExecuteChanged(); }
public void DeserializeConflictResolutionRuleCollection() { using (TfsMigrationConsolidatedDBEntities context = TfsMigrationConsolidatedDBEntities.CreateInstance()) { var rules = from r in context.ConfigConflictResolutionRuleSet select r; SerializableConflictResolutionRuleCollection collection = new SerializableConflictResolutionRuleCollection(); var serializer = new GenericSerializer <SerializableConflictResolutionRuleCollection>(); foreach (ConfigConflictResolutionRule rule in rules) { SerializableConflictResolutionRule serializableRule = new SerializableConflictResolutionRule(rule); collection.AddRule(serializableRule); } string serializedText = serializer.Serialize(collection); var ruleSerializer = new GenericSerializer <SerializableConflictResolutionRule>(); var newCollection = serializer.Deserialize(serializedText); foreach (var serializableRule in newCollection.Rules) { Trace.WriteLine("============================"); string ruleText = ruleSerializer.Serialize(serializableRule); Trace.WriteLine(ruleText); } } }
private static void IzmenaKorisnika() { Korisnik trazeniKorisnik = null; string userTrazenogKorisnika = ""; var korisnici = Projekat.Instance.Korisnik; do { Console.WriteLine("Unesite user korisnika kojeg zelite da izmenite"); userTrazenogKorisnika = Console.ReadLine(); foreach (var s in korisnici) { if (s.KorisnickoIme == userTrazenogKorisnika) { trazeniKorisnik = s; } } } while (trazeniKorisnik == null); Console.WriteLine("Unesite ime: "); trazeniKorisnik.Ime = Console.ReadLine(); Console.WriteLine("Unesite prezime: "); trazeniKorisnik.Prezime = Console.ReadLine(); Console.WriteLine("Unesite novu sifru: "); trazeniKorisnik.Lozinka = Console.ReadLine(); GenericSerializer.Serialize <Korisnik>("korisnik.xml", korisnici); KorisniciMeni(); }
private void Sacuvaj_Click(object sender, RoutedEventArgs e) { var lista = Projekat.Instance.Akcija; double cijenaN = 0; for (int i = 0; i < akcija.NamjestajNaAkciji.Count; i++) { cijenaN += akcija.NamjestajNaAkciji[i].Cijena; } if (operacija == Operacija.DODAVANJE) { akcija.Id = lista.Count + 1; foreach (var item in akcija.NamjestajNaAkciji) { item.AkcijskaCijena = item.Cijena - ((item.Cijena * akcija.Popust) / 100); Namjestaj.Update(item); } Akcija.Create(akcija); } Akcija.Update(akcija); GenericSerializer.Serialize("akcija.xml", lista); Close(); }
private static void DodavanjeNovogSalona() { var lista = Projekat.Instance.Salon; Console.WriteLine("===Dodavanje novog salona==="); var noviSalon = new Salon(); noviSalon.Id = lista.Count + 1; Console.WriteLine("Unesite naziv: "); noviSalon.Naziv = Console.ReadLine(); Console.WriteLine("Unesite adresu: "); noviSalon.Adresa = Console.ReadLine(); Console.WriteLine("Unesite telefon: "); noviSalon.Telefon = Console.ReadLine(); Console.WriteLine("Unesite email: "); noviSalon.Email = Console.ReadLine(); Console.WriteLine("Unesite sajt: "); noviSalon.Sajt = Console.ReadLine(); Console.WriteLine("Unesite pib: "); noviSalon.PIB = int.Parse(Console.ReadLine()); Console.WriteLine("Unesite maticni broj: "); noviSalon.MaticniBroj = int.Parse(Console.ReadLine()); Console.WriteLine("Unesite broj ziro racuna: "); noviSalon.ZiroRacun = Console.ReadLine(); lista.Add(noviSalon); GenericSerializer.Serialize <Salon>("salon.xml", lista); SalonMeni(); }
public static SqlToGraphiteConfig SerialiseDeserialise(SqlToGraphiteConfig hh) { var genericSerializer = new GenericSerializer(Global.GetNameSpace()); var xml = genericSerializer.Serialize<SqlToGraphiteConfig>(hh); var sqlToGraphiteConfig = genericSerializer.Deserialize<SqlToGraphiteConfig>(xml); return sqlToGraphiteConfig; }
private static void DodavanjeNovogTipa() { Console.WriteLine("====Dodavanje novog tipa namestaja===="); var lista = Projekat.Instance.Tip; var noviTip = new TipNamestaja(); noviTip.Id = lista.Count + 1; Console.WriteLine("Unesite naziv novog tipa namestaja: "); noviTip.Naziv = Console.ReadLine(); /* * string nazivTipaNamestaja = ""; * TipNamestaja trazeniTipNamestaja = null; * * do * { * Console.WriteLine("Unesite tip namestaja: "); * nazivTipaNamestaja = Console.ReadLine(); * foreach (var tipNamestaja in tipnamestaja) * { * if (tipNamestaja.Naziv == nazivTipaNamestaja) * { * trazeniTipNamestaja = tipNamestaja; * } * } * } while (trazeniTipNamestaja == null); * noviNamestaj.TipNamestaja = trazeniTipNamestaja; */ lista.Add(noviTip); GenericSerializer.Serialize <TipNamestaja>("tip.xml", lista); MeniZaTipNamestaja(); }
private static void IzmenaTipaNamestaja() { TipNamestaja trazeniTip = null; string nazivTrazenogTipa = ""; var tipovinamestaja = Projekat.Instance.Tip; do { Console.WriteLine("Unesite naziv tipa namestaja koji zelite da izmenite: "); nazivTrazenogTipa = Console.ReadLine(); foreach (var tip in tipovinamestaja) { if (tip.Naziv == nazivTrazenogTipa) { trazeniTip = tip; } } } while (trazeniTip == null); Console.WriteLine("Unesite novi naziv tipa namestaja: "); trazeniTip.Naziv = Console.ReadLine(); GenericSerializer.Serialize <TipNamestaja>("tip.xml", tipovinamestaja); MeniZaTipNamestaja(); }
private static void IzmenaNamestaja() { Namestaj trazeniNamestaj = null; string nazivTrazenogNamestaja = ""; var namestaji = Projekat.Instance.Namestaj; do { Console.WriteLine("Unesite naziv namestaja koji zelite da menjate: "); nazivTrazenogNamestaja = Console.ReadLine(); foreach (var nam in namestaji) { if (nam.Naziv == nazivTrazenogNamestaja) { trazeniNamestaj = nam; } } } while (trazeniNamestaj == null); Console.WriteLine("Unesite novi naziv namestaja: "); trazeniNamestaj.Naziv = Console.ReadLine(); Console.WriteLine("Unesite novu cenu namestaja: "); trazeniNamestaj.Cena = double.Parse(Console.ReadLine()); GenericSerializer.Serialize <Namestaj>("namestaj.xml", namestaji); IspisiMeniNamestaja(); }
// Writer public static void JsonSerializer(Jboy.JsonWriter writer, object instance) { GenericSerializer.WriteJSONClassInstance <GuildMember>(writer, (GuildMember)instance, null, new HashSet <string>() { "name" }); }
private Projekat() { TipNamestaja = GenericSerializer.Deserialize <TipNamestaja>("tip_namestaja.xml"); Akcije = GenericSerializer.Deserialize <Akcija>("akcije.xml"); Korisnici = GenericSerializer.Deserialize <Korisnik>("korisnici.xml"); DodatneUsluge = GenericSerializer.Deserialize <DodatnaUsluga>("dodatne_usluge.xml"); }
private void SaveSettings() { GenericSerializer.Serialize <TsManagerSettings>(_settings, TsGlobalConst.GetSettingsFile(), _logicLoader.GetLogicSettingsTypes()); _modified = false; SettingsControlsEnabled(); }
private static void IzmenaUsluge() { DodatnaUsluga trazenaUsluga = null; string nazivTrazeneUsluge = ""; var usluge = Projekat.Instance.DodatnaUsluga; do { Console.WriteLine("Unesite naziv usluge koji zelite da izmenite"); nazivTrazeneUsluge = Console.ReadLine(); foreach (var s in usluge) { if (s.Usluga == nazivTrazeneUsluge) { trazenaUsluga = s; } } } while (trazenaUsluga == null); Console.WriteLine("Unesite naziv usluge: "); trazenaUsluga.Usluga = Console.ReadLine(); Console.WriteLine("Unesite cenu usluge: "); trazenaUsluga.Cena = int.Parse(Console.ReadLine()); GenericSerializer.Serialize <DodatnaUsluga>("dodatna_usluga.xml", usluge); UslugeMeni(); }
private void LoadSettings() { _settings = GenericSerializer.Deserialize <TsManagerSettings>( TsGlobalConst.GetSettingsFile(), false, _logicLoader.GetLogicSettingsTypes()); _modified = false; SettingsControlsEnabled(); }
static void Main(string[] args) { //SerializeSampleCoverage(@"C:\Temp\Ace.ClientCoverageReport.xml"); //var rootSample = GenericSerializer.DeserializeFilePath<CodeCoverage.CoverageDtos.Root>(@"C:\Temp\Ace.ClientCoverageReport.xml"); var rootSample = GenericSerializer.DeserializeFilePath <CodeCoverage.CoverageDtos.Root>(@"C:\Temp\CodeCoveage\Ace.Server\2016.08.10.AceServerCodeCoverage.xml"); var abc = GenericSerializer.DeserializeFilePath <Root>(@"C:\Temp\Ace.ClientCoverageReport.xml"); //foreach (var project in abc.Project) //{ // foreach (var projectNamespace in project.Namespace) // { // foreach (var namespaceType in projectNamespace.Type) // { // foreach (var method in namespaceType.Method) // { // } // foreach (var property in namespaceType.Property) // { // } // } // } //} }
public MessagePackSerializer <TObject> BuildSerializerInstance(SerializationContext context) { var genericSerializer = GenericSerializer.Create <TObject>(context); if (genericSerializer != null) { return(genericSerializer); } var codeGenerationContext = this.CreateCodeGenerationContextForSerializerCreation(context); if (typeof(TObject).GetIsEnum()) { this.BuildEnumSerializer(codeGenerationContext); Func <SerializationContext, MessagePackSerializer <TObject> > constructor = this.CreateEnumSerializerConstructor(codeGenerationContext); if (constructor != null) { var serializer = constructor(context); #if DEBUG Contract.Assert(serializer != null); #endif if (!context.Serializers.Register(serializer)) { serializer = context.Serializers.Get <TObject>(context); #if DEBUG Contract.Assert(serializer != null); #endif } return(serializer); } } else { this.BuildSerializer(codeGenerationContext); Func <SerializationContext, MessagePackSerializer <TObject> > constructor = this.CreateSerializerConstructor(codeGenerationContext); if (constructor != null) { var serializer = constructor(context); #if DEBUG Contract.Assert(serializer != null); #endif if (!context.Serializers.Register(serializer)) { serializer = context.Serializers.Get <TObject>(context); #if DEBUG Contract.Assert(serializer != null); #endif } return(serializer); } } throw SerializationExceptions.NewTypeCannotSerialize(typeof(TObject)); }
public CyclicLinkConflictDetails(ConflictDetailsProperties detailsProperties) { string sourceItemId, targetItemId, linkType, closure; if (detailsProperties.Properties.TryGetValue( TFSCyclicLinkConflictType.ConflictDetailsKey_SourceWorkItemID, out sourceItemId) && detailsProperties.Properties.TryGetValue( TFSCyclicLinkConflictType.ConflictDetailsKey_TargetWorkItemID, out targetItemId) && detailsProperties.Properties.TryGetValue( TFSCyclicLinkConflictType.ConflictDetailsKey_LinkType, out linkType) && detailsProperties.Properties.TryGetValue( TFSCyclicLinkConflictType.ConflictDetailsKey_LinkClosure, out closure)) { this.SourceWorkItemID = sourceItemId; this.TargetWorkItemID = targetItemId; this.LinkTypeReferenceName = linkType; GenericSerializer <List <LinkDescription> > serializer = new GenericSerializer <List <LinkDescription> >(); if (string.IsNullOrEmpty(closure)) { this.LinkReferenceClosure = new List <LinkDescription>(); } else { this.LinkReferenceClosure = serializer.Deserialize(closure); } } else { throw new ArgumentException("detailsProperties do not contain all expected values for the conflict type"); } }
/// <summary> /// Загрузка параметров формы /// </summary> private void LoadFormSettings() { _formSettings = GenericSerializer.Deserialize <ConfiguratorFormSettings>( DeviceManager.GetDeviceManagerDirectory() + "\\Configurator.xml"); Location = _formSettings.Location; Size = _formSettings.Size; propertyGrid.Height = _formSettings.PropertiesHeight; pnlConfig.Width = _formSettings.ConfigWidth; splitContainer1.SplitterDistance = _formSettings.DetailedViewHeight; _eventsViewLink = new ListedEventsViewLink(lvLog, _formSettings.Filter, _formSettings.Columns, true); _eventsViewLink.AddCommandItem(miRefresh, EventsViewCommand.Update); _eventsViewLink.AddCommandItem(btnRefresh, EventsViewCommand.Update); _eventsViewLink.AddCommandItem(cmiRefresh, EventsViewCommand.Update); _eventsViewLink.AddCommandItem(miDetails, EventsViewCommand.Details); _eventsViewLink.AddCommandItem(miFilter, EventsViewCommand.Filter); _eventsViewLink.AddCommandItem(btnFilter, EventsViewCommand.Filter); _eventsViewLink.AddCommandItem(cmiFilter, EventsViewCommand.Filter); _eventsViewLink.AddDetailedViewControl(textBox1); _eventsViewLink.SourceConnector = new LogConnector(tsslEventsReloadProgress); _eventsViewLink.Update(); _srvMonitor = new ServiceMonitor("POSDeviceManager", 500); _srvMonitor.AppendStatus(lbSvcStatus, "Text"); _srvMonitor.AppendEnabledWhenStarted(btnSvcStop, false); _srvMonitor.AppendEnabledWhenStarted(miSvcStop, false); _srvMonitor.AppendEnabledWhenStarted(miSvcRestart, true); _srvMonitor.AppendEnabledWhenStopped(btnSvcStart); _srvMonitor.AppendEnabledWhenStopped(miSvcStart); _srvMonitor.StartMonitor(); }
private static void IzmenaNamestaja() { Namestaj trazeniNamestaj = null; int iDTrazenogNamestaja = 0; var nam = Projekat.Instance.Namestaj; do { Console.WriteLine("Unesite id namestaja: "); iDTrazenogNamestaja = int.Parse(Console.ReadLine()); foreach (var namestaj in nam) { if (namestaj.Id == iDTrazenogNamestaja) { trazeniNamestaj = namestaj; } } } while (trazeniNamestaj == null); Console.WriteLine("Unesite novi naziv namestaja: "); trazeniNamestaj.Naziv = Console.ReadLine(); Console.WriteLine("Unesite novu cenu namestaja: "); trazeniNamestaj.JedinicnaCena = double.Parse(Console.ReadLine()); GenericSerializer.Serialize <Namestaj>("namestaj.xml", nam); IspisiMeniNamestaja(); }
private static void IzmenaTipaNamestaja() { TipNamestaja trazeniTipNamestaj = null; int iDTrazenogTipaNamestaja = 0; var tip = Projekat.Instance.TipNamestaja; do { Console.WriteLine("Unesite id tipa namestaja: "); iDTrazenogTipaNamestaja = int.Parse(Console.ReadLine()); foreach (var tipNamestaja in tip) { if (tipNamestaja.Id == iDTrazenogTipaNamestaja) { trazeniTipNamestaj = tipNamestaja; } } } while (trazeniTipNamestaj == null); Console.WriteLine("Unesite novi naziv namestaja: "); trazeniTipNamestaj.Naziv = Console.ReadLine(); GenericSerializer.Serialize <TipNamestaja>("tipoviNamestaja.xml", tip); IspisiMeniTipaNamestaja(); }
public void ShouldNotDeSerializeWithFirstParameterNullAndSecondParameterValid() { string dummy = null; Type[] types = { }; GenericSerializer.Deserialize <SerializableType>(dummy, types); }
protected T ReadObject <T>(byte[] bytes, int offset, int count) { byte[] tmpbuf = new byte[count]; Buffer.BlockCopy(bytes, offset, tmpbuf, 0, count); return(GenericSerializer.GetObject <T>(tmpbuf)); }
private void btnApply_Click(object sender, EventArgs e) { if (radStartupMaximized.Checked) { prefs.Startup.Method = StartupMethod.Maximized; } else if (radStartupMinimized.Checked) { prefs.Startup.Method = StartupMethod.Minimized; } else { prefs.Startup.Method = StartupMethod.Disabled; } RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (prefs.Startup.Method != StartupMethod.Disabled) { key.SetValue("Countdown", "\"" + Application.ExecutablePath + "\" /startup"); } else if (key.GetValue("Countdown") != null) { key.DeleteValue("Countdown"); } key.Close(); prefs.Cycle.Enabled = chkCycleEnabled.Checked; prefs.Cycle.Interval = (int)numCycleInterval.Value * 1000; GenericSerializer.SerializeXML <Preferences>("Countdown.prefs", prefs); btnApply.Enabled = false; }
public void ShouldNotDeSerializeWithBothParameterNull() { string dummy = null; Type[] types = null; GenericSerializer.Deserialize <SerializableType>(dummy, types); }
private static void IspisiGlavniMeni() { int izbor = 0; do { Console.WriteLine("====GLAVNI MENI===="); Console.WriteLine("1. Rad sa namestajem"); Console.WriteLine("2. Rad sa tipom namestaja"); Console.WriteLine("0. Izlaz iz aplikacije"); izbor = int.Parse(Console.ReadLine()); } while (izbor < 0 || izbor > 2); switch (izbor) { case 1: IspisiMeniNamestaja(); break; case 2: IspisiMeniTipaNamestaja(); break; case 0: GenericSerializer.Serialize <Namestaj>(filename, lista); Environment.Exit(0); break; default: break; } }
private DataPacket PassThrough(DataPacket item) { Type modelType = Type.GetType(item.Typename); if (modelType == null) { item.SetError(500, String.Format("Could not resolve the type: '{0}'", item.Typename)); } else { Type contracts = typeof(IDataRequestService); MethodInfo dataRequestContracts = contracts.GetMethod(item.ModelAction.ToString()); MethodInfo standardContractMethod = dataRequestContracts.MakeGenericMethod(modelType); var mT = typeof(Message <>); var closedModel = mT.MakeGenericType(new Type[] { modelType }); dynamic message = Activator.CreateInstance(closedModel, item.Items); message.Criterion = item.Criteria; if (verbsWithModel.Contains(item.ModelAction) && item.Buffer != null) { object model = GenericSerializer.ByteArrayToItem(item.Buffer); //var m = Convert.ChangeType(model, modelType); message.TryAdd(model); //message.Content.Insert(0, m); } InvokeStandardContract(DataService, standardContractMethod, new object[1] { message }, item); } return(item); }
private static void InitializeDbConfig() { _DbConfigs = new Common.Db.DbConfigCollection(); try { if (System.IO.Directory.Exists(eXtensibleConfig.DbConfigs)) { var candidates = System.IO.Directory.GetFiles(eXtensibleConfig.DbConfigs, "*.dbconfig.xml"); if (candidates != null && candidates.Length > 0) { foreach (var candidate in candidates) { try { var config = GenericSerializer.ReadGenericItem <XF.Common.Db.DbConfig>(candidate); _DbConfigs.Add(config); } catch (Exception ex) { string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; var props = eXtensibleConfig.GetProperties(); EventWriter.WriteError(message, SeverityType.Critical, "DataAccess", props); } } } } } catch (Exception ex) { string s = ex.Message; } }
public CyclicLinkConflictDetails GetConflictDetails(MigrationConflict conflict) { if (!conflict.ConflictType.ReferenceName.Equals(this.ReferenceName)) { throw new InvalidOperationException(); } if (string.IsNullOrEmpty(conflict.ConflictDetails)) { throw new ArgumentNullException("conflict.ConflictDetails"); } try { // V2 conflict details, i.e. using property bag return(new CyclicLinkConflictDetails(conflict.ConflictDetailsProperties)); } catch (Exception) { GenericSerializer <InvalidWorkItemLinkDetails> serializer = new GenericSerializer <InvalidWorkItemLinkDetails>(); InvalidWorkItemLinkDetails baseDetails = serializer.Deserialize(conflict.ConflictDetails) as InvalidWorkItemLinkDetails; return(new CyclicLinkConflictDetails(baseDetails.SourceWorkItemID, baseDetails.TargetWorkItemID, baseDetails.LinkTypeReferenceName, null)); } }
public void ShouldNotDeSerializeWithInvalidParameters4() { string dummy = "dummy"; Type[] types = null; GenericSerializer.Deserialize <SerializableType>(dummy, types); }
public SqlToGraphiteConfig(IAssemblyResolver assemblyResolver, ILog log) { this.log = log; var job = new JobImpl(); jobTypes = assemblyResolver.ResolveTypes(job); //JobTypes = GetJobTypes().ToArray(); clientTypes = GetClientTypes().ToArray(); this.Jobs = new List<Job>(); this.Clients = new ListOfUniqueType<Client>(); this.Hosts = new List<Host>(); this.Templates = new List<Template>(); this.genericSerializer = new GenericSerializer(Global.GetNameSpace()); }
public SqlToGraphiteConfig() { var job = new JobImpl(); this.WireUpLog4Net(); var assemblyResolver = new AssemblyResolver(new DirectoryImpl(), log); jobTypes = assemblyResolver.ResolveTypes(job); alljobtypes = assemblyResolver.ResolveAllTypes(job); //JobTypes = GetJobTypes().ToArray(); clientTypes = GetClientTypes().ToArray(); this.Jobs = new List<Job>(); this.Clients = new ListOfUniqueType<Client>(); this.Hosts = new List<Host>(); this.Templates = new List<Template>(); this.genericSerializer = new GenericSerializer(Global.GetNameSpace()); }
public static TaskManager CreateTaskManager(SqlToGraphiteSection configuration) { var cacheLength = new TimeSpan(0, configuration.ConfigCacheLengthMinutes, 0); var stop = new Stop(); var directoryImpl = new DirectoryImpl(); var assemblyResolver = new AssemblyResolver(directoryImpl, log); IEncryption encryption = new Encryption(); IDataClientFactory dataClientFactory = new DataClientFactory(log, assemblyResolver, encryption); IGraphiteClientFactory graphiteClientFactory = new GraphiteClientFactory(log); var configReader = new ConfigHttpReader(configuration.ConfigUri, configuration.ConfigUsername, configuration.ConfigPassword); var cache = new Cache(cacheLength, log); var sleeper = new Sleeper(); var genericSer = new GenericSerializer(Global.GetNameSpace()); var cr = new ConfigRepository(configReader, cache, sleeper, log, configuration.MinutesBetweenRetryToGetConfigOnError, genericSer); var configMapper = new ConfigMapper(configuration.Hostname, stop, dataClientFactory, graphiteClientFactory, log, cr); var roleConfigFactory = new RoleConfigFactory(); var environment = new Environment(); var taskSetBuilder = new TaskSetBuilder(); var configController = new ConfigController(configMapper, log, cr, roleConfigFactory, environment, taskSetBuilder); return new TaskManager(log, configController, configuration.ConfigUri, stop, sleeper, configuration.CheckConfigUpdatedEveryMinutes); }
public void Should_read_config_One_job_sucessfully_with_unknownplugin() { IGenericSerializer gs = new GenericSerializer(Global.GetNameSpace()); repository = new ConfigRepository(this.reader, this.cache, this.sleep, this.log, this.sleepTime, this.configPersister, gs); reader.Expect(x => x.GetXml()).Return(Resources.UnknownPlugin); cache.Expect(x => x.HasExpired()).Return(true).Repeat.Once(); //Test repository.Load(); //Assert List<Job> jobs = repository.GetJobs(); Assert.That(jobs.Count, Is.EqualTo(1)); Assert.That(jobs[0].GetType().Name, Is.EqualTo("WmiClient")); genericSerializer.VerifyAllExpectations(); }
public void WriteXml(XmlWriter writer) { foreach (var key in this.Properties.Keys) { writer.WriteStartElement("entry"); writer.WriteStartElement("key"); writer.WriteName(key); writer.WriteEndElement(); var value = this.Properties[key]; // Configure serializer behavior for element and attributes var genericSerializer = new GenericSerializer(); genericSerializer.AddAttributeObjectBinding( new XmlAttribute(typeof(Details), "xmlns:xsi", ScenarioDocuXMLFileUtil.SchemaInstanceNamespace)); // Prepare elment and attribute names genericSerializer.AddAttributeObjectBinding(new XmlAttribute(typeof(Details), "xsi:type", "details")); genericSerializer.AddElementObjectBinding(new XmlElement(typeof(Details), "value"), typeof(Details)); genericSerializer.AddElementObjectBinding( new XmlElement(typeof(ObjectDescription), "value"), typeof(ObjectDescription)); genericSerializer.AddElementObjectBinding( new XmlElement(typeof(ObjectReference), "value"), typeof(ObjectReference)); genericSerializer.AddElementObjectBinding( new XmlElement(typeof(ObjectList<>), "value"), typeof(ObjectList<>)); // Prepare xml tags genericSerializer.AddXmlTag( new XmlTag( new XmlElement(typeof(ObjectTreeNode<object>), "value"), new List<XmlAttribute> { new XmlAttribute( "xmlns:xsi", ScenarioDocuXMLFileUtil.SchemaInstanceNamespace), new XmlAttribute("xsi:type", "objectTreeNode") }, typeof(ObjectTreeNode<object>)), typeof(ObjectTreeNode<object>)); genericSerializer.SuppressProperties = false; genericSerializer.DetailElementName = "value"; genericSerializer.SerializeDetails(writer, value); writer.WriteEndElement(); } }
public void Initialise(string path) { log = LogManager.GetLogger("log"); log4net.Config.XmlConfigurator.Configure(); var sleepTime = 0; assemblyResolver = new AssemblyResolver(new DirectoryImpl(), log); var config = new SqlToGraphiteConfig(assemblyResolver, log); encryption = new Encryption(); var reader = new ConfigHttpReader(path, "", ""); var cache = new Cache(new TimeSpan(0, 0, 1, 0), log); var sleep = new Sleeper(); var genericSerializer = new GenericSerializer(Global.GetNameSpace()); var configPersister = new ConfigPersister(new ConfigFileWriter(path), genericSerializer); repository = new ConfigRepository(reader, cache, sleep, this.log, sleepTime, configPersister, genericSerializer); }