public void ShouldNotDeSerializeWithInvalidParameters4()
        {
            string dummy = "dummy";

            Type[] types = null;
            GenericSerializer.Deserialize <SerializableType>(dummy, types);
        }
Ejemplo n.º 2
0
        /// <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();
        }
        TViewInstance FindOneById(string id, NpgsqlConnection connection, NpgsqlTransaction transaction)
        {
            using (var command = connection.CreateCommand())
            {
                if (transaction != null)
                {
                    command.Transaction = transaction;
                }

                command.Parameters.Add("id", NpgsqlDbType.Varchar, PrimaryKeySize).Value = id;
                command.CommandText = string.Format(@"select ""data"" from ""{0}"" where ""id"" = @id", _tableName);

                using (var reader = command.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        return(null);
                    }

                    var data     = reader["data"];
                    var jsonText = data.ToString();

                    return((TViewInstance)_serializer.Deserialize(jsonText));
                }
            }
        }
Ejemplo n.º 4
0
 private void LoadSettings()
 {
     _settings = GenericSerializer.Deserialize <TsManagerSettings>(
         TsGlobalConst.GetSettingsFile(), false, _logicLoader.GetLogicSettingsTypes());
     _modified = false;
     SettingsControlsEnabled();
 }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        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);
                }
            }
        }
Ejemplo n.º 7
0
        public void GenericSerializer_DeSerializeLoanTypesSerializable_AreSame()
        {
            GenericSerializer gs = new GenericSerializer();
            var lts = gs.Deserialize <LoanTypesSerializable>("LoanTypes.xml");

            Assert.AreSame(lts, new LoanTypesSerializable());
        }
Ejemplo n.º 8
0
        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");
            }
        }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
 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");
 }
        public void ShouldNotDeSerializeWithBothParameterNull()
        {
            string dummy = null;

            Type[] types = null;
            GenericSerializer.Deserialize <SerializableType>(dummy, types);
        }
        public void ShouldNotDeSerializeWithFirstParameterNullAndSecondParameterValid()
        {
            string dummy = null;

            Type[] types = { };
            GenericSerializer.Deserialize <SerializableType>(dummy, types);
        }
Ejemplo n.º 13
0
 public Projekat()
 {
     TipNamestaja  = Model.TipNamestaja.GetAll();
     Namestaj      = Model.Namestaj.GetAll();
     Akcije        = Akcija.GetAll();
     Korisnici     = Korisnik.GetAll();
     DodatneUsluge = DodatnaUsluga.GetAll();
     Salon         = Model.Salon.Get();
     Prodaja       = GenericSerializer.Deserialize <ProdajaNamestaja>("prodaje.xml");
 }
Ejemplo n.º 14
0
 private void LoadGUISettings()
 {
     _appSettings = GenericSerializer.Deserialize <TsManagerConfiguratorSettings>(
         TsGlobalConst.GetAppSettingsFile());
     Left   = _appSettings.Left;
     Top    = _appSettings.Top;
     Width  = _appSettings.Width;
     Height = _appSettings.Height;
     splitContainer3.SplitterDistance = _appSettings.Splitter1;
     splitContainer2.SplitterDistance = _appSettings.Splitter2;
 }
        public void ShouldDeSerializeASerializableType()
        {
            SerializableType type = new SerializableType();

            type.Field = 1;
            string typeRepresentation = GenericSerializer.Serialize <SerializableType>(type);

            SerializableType type1 = GenericSerializer.Deserialize <SerializableType>(typeRepresentation);

            Assert.AreEqual(type.Field, type1.Field, "Not Equal");
        }
Ejemplo n.º 16
0
        public IResponse <T, U> Deserialize <T, U>(DataPacket item) where T : class, new()
        {
            Message <T, U> data = null;

            if (item != null)
            {
                data = new Message <T, U>(item.Items);
                data.ActionResult = GenericSerializer.Deserialize <U>(item.Buffer);
            }
            return(data as IResponse <T, U>);
        }
        public void ShouldDeSerializeANotSerializableType()
        {
            NotSerializableType2 type = new NotSerializableType2();

            type.Field = new Hashtable();
            string typeRepresentation = GenericSerializer.Serialize <NotSerializableType2>(type);

            NotSerializableType2 type1 = GenericSerializer.Deserialize <NotSerializableType2>(typeRepresentation);

            Assert.IsNotNull(type1);
            Assert.AreEqual(type.Field.ToString(), type1.Field.ToString(), "Not Equal");
        }
        public void ShouldDeSerializeASerializableTypeWithOtherReferences()
        {
            Type[]            types = { typeof(SerializableType1) };
            SerializableType2 type  = new SerializableType2();
            SerializableType1 type1 = new SerializableType1();

            type1.Field1 = 1;
            type.Field   = type1;
            string typeRepresentation = GenericSerializer.Serialize <SerializableType2>(type, types);

            SerializableType2 type3 = GenericSerializer.Deserialize <SerializableType2>(typeRepresentation, types);

            Assert.AreEqual(type.Field.GetType(), type3.Field.GetType(), "Not Equal");
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Создает экземпляр класса
        /// </summary>
        /// <param name="eventLink">Интерфейс журнала событий</param>
        public TsManager(IEventLink eventLink)
        {
            if (eventLink == null)
            {
                throw new ArgumentNullException("eventLink");
            }

            // загружаем реализации логики работы СКУД
            _eventLink = eventLink;
            _eventLink.Post(TsGlobalConst.EventSource, "Загрузка реализаций логики работы СКУД");
            _logicLoader = new AMCSLogicLoader(TsGlobalConst.GetACMSLogicDirectory());

            // загрузка конфигурации
            _eventLink.Post(TsGlobalConst.EventSource, "Загрузка конфигурации менеджера");
            _settings = GenericSerializer.Deserialize <TsManagerSettings>(TsGlobalConst.GetSettingsFile(),
                                                                          false, _logicLoader.GetLogicSettingsTypes());
            _workers = new List <TsWorker>();

            // просматриваем конфигурацию и создаем по рабочему потоку для каждого турникета
            foreach (AMCSLogicSettings logicSettings in _settings.LogicSettings)
            {
                foreach (TsUnitSettings unitSettings in logicSettings.Units)
                {
                    try
                    {
                        // создаем реализацию логики работы СКУД и инициализируем ее параметры
                        IAMCSLogic logic = _logicLoader.CreateLogic(logicSettings.AcmsName);
                        logic.Settings = logicSettings.LogicSettings;

                        // создаем рабочий поток
                        TsWorker worker = new TsWorker(logic, unitSettings, _eventLink);
                        _eventLink.Post(TsGlobalConst.EventSource, string.Format(
                                            "Создан рабочий поток для турникета {0}, СКУД \"{1}\"",
                                            unitSettings, logicSettings.AcmsName));

                        // добавляем его в список
                        _workers.Add(worker);
                    }
                    catch (Exception e)
                    {
                        string checkPoint = string.Format(
                            "Создание рабочего потока для турникета {0}, СКУД \"{1}\"",
                            unitSettings, logicSettings.AcmsName);
                        _eventLink.Post(TsGlobalConst.EventSource, checkPoint, e);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public void TestSerializer()
        {
            DummyPersistanceObject foo = new DummyPersistanceObject()
            {
                Bar1 = 111, Bar2 = "hello"
            };
            DummyPersistanceObject foo2;

            using (MemoryStream ms = new MemoryStream()) {
                GenericSerializer <DummyPersistanceObject> .Serialize(foo, ms);

                ms.Position = 0;
                foo2        = GenericSerializer <DummyPersistanceObject> .Deserialize(ms);
            }
            Assert.AreEqual(foo, foo2);
        }
Ejemplo n.º 21
0
        public void TestProjectMappingInformationSerialization()
        {
            string stringResentation =
                GenericSerializer.Serialize <ProjectMappingInformation>(info);

            ProjectMappingInformation deserializedInfo =
                GenericSerializer.Deserialize <ProjectMappingInformation>(stringResentation);

            Assert.AreEqual(info.FileName, deserializedInfo.FileName, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables.Count, deserializedInfo.ProjectMappingTables.Count, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].Name, deserializedInfo.ProjectMappingTables[0].Name, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].ProjectMappings.Count, deserializedInfo.ProjectMappingTables[0].ProjectMappings.Count, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].ProjectMappings[0].ProjectId, deserializedInfo.ProjectMappingTables[0].ProjectMappings[0].ProjectId, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].ProjectMappings[0].ProjectPath, deserializedInfo.ProjectMappingTables[0].ProjectMappings[0].ProjectPath, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].ProjectMappings[0].Roles.Count, deserializedInfo.ProjectMappingTables[0].ProjectMappings[0].Roles.Count, "Not Equal");
            Assert.AreEqual(info.ProjectMappingTables[0].ProjectMappings[0].Roles[0].Name, deserializedInfo.ProjectMappingTables[0].ProjectMappings[0].Roles[0].Name, "Not Equal");
        }
        /// <summary>
        /// Converts the given object to the type of this converter, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"></see> to use as the current culture.</param>
        /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
        /// <returns>
        /// An <see cref="T:System.Object"></see> that represents the converted value.
        /// </returns>
        /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            ObjectExtenderContainer container = new ObjectExtenderContainer();
            string convertValue = value as string;

            if (!string.IsNullOrEmpty(convertValue))
            {
                try
                {
                    //We need to obtain all posible referenced types for the XMLSerializer (XMLInclude)
                    IList <Type> types = GetExtraTypesFromProviders(context);
                    container = GenericSerializer.Deserialize <ObjectExtenderContainer>(convertValue, types);
                }
                catch (Exception ex)
                {
                    Logger.Write(ex);
                }
            }
            return(container);
        }
Ejemplo n.º 23
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        bool wasEmpty = reader.IsEmptyElement;

        reader.Read();
        if (wasEmpty)
        {
            return;
        }
        reader.MoveToContent();
        reader.ReadStartElement("Animals");
        // you MUST deserialize with 'List<Animal>', if Animals class has no 'List<Animal>' fields but has been derived from 'List<Animal>'.
        List <Animal> coll = GenericSerializer.Deserialize <List <Animal> >(reader, _animalTypes);

        // And then, You can set 'Animals' to 'List<Animal>'.
        _animals.AddRange(coll);
        reader.ReadEndElement();
        //Read Closing Element
        reader.ReadEndElement();
    }
        public override string TranslateConflictDetailsToReadableDescription(string dtls)
        {
            if (string.IsNullOrEmpty(dtls))
            {
                throw new ArgumentNullException("dtls");
            }

            InvalidFieldValueConflictTypeDetails details = null;

            try
            {
                ConflictDetailsProperties properties = ConflictDetailsProperties.Deserialize(dtls);
                details = new InvalidFieldValueConflictTypeDetails(properties);
            }
            catch (Exception)
            {
                try
                {
                    GenericSerializer <InvalidFieldValueConflictTypeDetails> serializer =
                        new GenericSerializer <InvalidFieldValueConflictTypeDetails>();
                    details = serializer.Deserialize(dtls);
                }
                catch (Exception)
                {
                    // do nothing, fall back to raw string later
                }
            }

            if (null != details)
            {
                return(string.Format(
                           "Source work item {0} (revision {1}) contains invalid field change on {2} from '{3}' to '{4}' in target project '{5}'.",
                           details.SourceWorkItemID, details.SourceWorkItemRevision,
                           details.TargetFieldRefName, details.TargetFieldOriginalValue,
                           details.TargetFieldCurrentValue, details.TargetTeamProject));
            }
            else
            {
                return(dtls);
            }
        }
        public override string TranslateConflictDetailsToReadableDescription(string dtls)
        {
            if (string.IsNullOrEmpty(dtls))
            {
                throw new ArgumentNullException("dtls");
            }

            InvalidFieldConflictTypeDetails details = null;

            try
            {
                ConflictDetailsProperties properties = ConflictDetailsProperties.Deserialize(dtls);
                details = new InvalidFieldConflictTypeDetails(properties);
            }
            catch (Exception)
            {
                try
                {
                    GenericSerializer <InvalidFieldConflictTypeDetails> serializer =
                        new GenericSerializer <InvalidFieldConflictTypeDetails>();

                    details = serializer.Deserialize(dtls);
                }
                catch (Exception)
                {
                    // do nothing, fall back to raw string later
                }
            }

            if (null != details)
            {
                return(string.Format(
                           "Source Item {0} (revision {1}) contains Field {2} that does not exist on Work Item Type '{3}' of the target project '{4}'.",
                           details.SourceWorkItemID, details.SourceWorkItemRevision,
                           details.SourceFieldRefName, details.TargetWorkItemType, details.TargetTeamProject));
            }
            else
            {
                return(dtls);
            }
        }
Ejemplo n.º 26
0
        public override string TranslateConflictDetailsToReadableDescription(string dtls)
        {
            if (string.IsNullOrEmpty(dtls))
            {
                throw new ArgumentNullException("dtls");
            }

            WorkItemTypeNotExistConflictTypeDetails details = null;

            try
            {
                ConflictDetailsProperties properties = ConflictDetailsProperties.Deserialize(dtls);
                details = new WorkItemTypeNotExistConflictTypeDetails(properties);
            }
            catch (Exception)
            {
                try
                {
                    GenericSerializer <WorkItemTypeNotExistConflictTypeDetails> serializer =
                        new GenericSerializer <WorkItemTypeNotExistConflictTypeDetails>();
                    details = serializer.Deserialize(dtls);
                }
                catch (Exception)
                {
                    // do nothing, fall back to raw string later
                }
            }

            if (null != details)
            {
                return(string.Format(
                           "Work Item Type {0} is not defined for team project '{1}' on server '{2}'.",
                           details.MissingWorkItemType,
                           details.TeamProject,
                           details.TeamFoundationServer));
            }
            else
            {
                return(dtls);
            }
        }
        public InvalidFieldConflictTypeDetails 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 InvalidFieldConflictTypeDetails(conflict.ConflictDetailsProperties));
            }
            catch (Exception)
            {
                GenericSerializer <InvalidFieldConflictTypeDetails> serializer =
                    new GenericSerializer <InvalidFieldConflictTypeDetails>();
                return(serializer.Deserialize(conflict.ConflictDetails));
            }
        }
        public void ShouldNotDeSerializeWithNullFirstParameter()
        {
            string dummy = null;

            GenericSerializer.Deserialize <SerializableType>(dummy);
        }
Ejemplo n.º 29
0
        static void GetSetter(PropertyInfo propertyInfo, object instance, object value)
        {
            object valueToSet;

            if (propertyInfo.GetCustomAttributes <JsonAttribute>().Any())
            {
                var text = Serializer.Deserialize((string)value);

                valueToSet = text;
            }
            else
            {
                var propertyTypeToLookAt = propertyInfo.PropertyType;

                if (propertyTypeToLookAt.IsGenericType &&
                    propertyTypeToLookAt.GetGenericTypeDefinition() == typeof(Nullable <>))
                {
                    propertyTypeToLookAt = propertyTypeToLookAt.GetGenericArguments().Single();
                }

                // -- COLLECTIONS --------------------------------------------------
                if (propertyTypeToLookAt == typeof(List <string>))
                {
                    var tokens = ((string)value).Split(';');

                    valueToSet = tokens.ToList();
                }
                else if (propertyTypeToLookAt == typeof(List <int>))
                {
                    var tokens = ((string)value).Split(';').Select(int.Parse);

                    valueToSet = tokens.ToList();
                }
                else if (propertyTypeToLookAt == typeof(List <double>))
                {
                    var tokens = ((string)value).Split(';').Select(double.Parse);

                    valueToSet = tokens.ToList();
                }
                else if (propertyTypeToLookAt == typeof(List <decimal>))
                {
                    var tokens = ((string)value).Split(';').Select(decimal.Parse);

                    valueToSet = tokens.ToList();
                }
                else if (propertyTypeToLookAt == typeof(HashSet <string>))
                {
                    var tokens = ((string)value).Split(';');

                    valueToSet = new HashSet <string>(tokens);
                }
                else if (propertyTypeToLookAt == typeof(HashSet <int>))
                {
                    var tokens = ((string)value).Split(';').Select(int.Parse);

                    valueToSet = new HashSet <int>(tokens);
                }
                else if (propertyTypeToLookAt == typeof(string[]))
                {
                    var tokens = ((string)value).Split(';');

                    valueToSet = tokens.ToArray();
                }
                // -- ANY KIND OF NULL PRIMITIVE VALUE --------------------------------------------------
                else if (value == DBNull.Value)
                {
                    valueToSet = null;
                }
                // -- SPECIAL PRIMITIVES --------------------------------------------------
                else if (propertyTypeToLookAt == typeof(DateTime))
                {
                    var dateTime = (DateTime)value;

                    valueToSet = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond, DateTimeKind.Utc);
                }
                else if (propertyTypeToLookAt == typeof(DateTimeOffset))
                {
                    valueToSet = value;
                }
                else if (propertyTypeToLookAt == typeof(TimeSpan))
                {
                    var ticks = (long)value;
                    valueToSet = new TimeSpan(ticks);
                }
                else if (propertyTypeToLookAt == typeof(Guid))
                {
                    valueToSet = (Guid)value;
                }
                else
                {
                    valueToSet = Convert.ChangeType(value, propertyTypeToLookAt);
                }
            }

            propertyInfo.SetValue(instance, valueToSet);
        }
Ejemplo n.º 30
0
        static void Main1(string[] args)
        {
            TipNamestaja.Add(new TipNamestaja()
            {
                Id    = 4,
                Naziv = "proba"
            });
            AkcijskaProdaja.Add(new AkcijskaProdaja()
            {
                Id     = 1,
                Popust = 10
            });

            List <TipNamestaja> tipn2 = GenericSerializer.Deserialize <TipNamestaja>("tipoviNamestaja.xml");

            TipNamestaja = tipn2;
            List <Namestaj> ln2 = GenericSerializer.Deserialize <Namestaj>("namestaj.xml");

            Namestaj = ln2;
            List <Korisnik> kor2 = GenericSerializer.Deserialize <Korisnik>("korisnici.xml");

            Korisnici = kor2;
            Console.WriteLine("Finished serialization");



            Salon s1 = new Salon()
            {
                Id             = 1,
                Naziv          = " Salon namestaja",
                Adresa         = "bez broja",
                Telefon        = "021556123",
                Email          = "*****@*****.**",
                AdresaSajta    = "salonnamestaja.com",
                PIB            = 3322125,
                MaticniBroj    = 22113551,
                BrojZiroRacuna = "00443-21234542"
            };
            Korisnik k1 = new Korisnik()
            {
                Id            = 1,
                Ime           = "admin1",
                Prezime       = "abc",
                KorisnickoIme = "a",
                Lozinka       = "a",
                TipKorisnika  = TipKorisnika.Administrator,
                Obrisan       = false
            };
            Korisnik k2 = new Korisnik()
            {
                Id            = 2,
                Ime           = "prodavac1",
                Prezime       = "abc",
                KorisnickoIme = "b",
                Lozinka       = "b",
                TipKorisnika  = TipKorisnika.Prodavac,
                Obrisan       = false
            };
            var lk = new List <Korisnik>();

            lk.Add(k1);
            lk.Add(k2);
        }