Exemple #1
0
        } // End of AlignBoundValueToValue ()

        public Boolean AlignValueToBoundValue()
        {
            IValueDomAlignable <IValueUnit, IValueUnit> valueDomAlignable = null;

            if (ValueBinder == null)
            {
                return(false);
            }

            valueDomAlignable = ValueBinder.BoundObjectValue
                                as IValueDomAlignable <IValueUnit, IValueUnit>;

            if (valueDomAlignable != null)
            {
                return(valueDomAlignable.Align());
            }

            Value = ValueBinder.BoundObjectValue;

            return(true);
        } // End of AlignValueToBoundValue ()
        public void Serialization1()
        {
            MainObject                     mainObj       = new MainObject();
            MainObjectRepoSerMgr           mainObjSerMgr = MainObjectRepoSerMgr.Singleton;
            RepositorySerializationContext serCtx        = new RepositorySerializationContext();
            RepositorySerializationContext serCtx2       = new RepositorySerializationContext();
            String     serialization = null;
            TextWriter tw            = new StringWriter();

            if (typeof(IMainObject).GetTypeGuid().ToString() == "e94473ee-f53f-4b7b-95d6-36d78d327e86")
            {
                System.Diagnostics.Debug.WriteLine("Guid verificato");
            }

            mainObj.DateTimeField       = DateTime.Now;
            mainObj.Field3              = new SubObject();
            mainObj.Field1              = "String Field \", \"aaa\" : \"bbb\", Insidioso";
            mainObj.Field2              = "Mario";
            mainObj.Field3.SubObjField1 = "Sub 1";
            mainObj.Field3.SubObjField2 = "Sub 2";
            mainObj.Field4              = true;
            mainObj.Field8              = -1234567.890;

            serCtx.SerializeMetadata = true;
            mainObjSerMgr.Serialize(tw, mainObj, serCtx);

            tw.Flush();
            tw.Close();

            serialization = tw.ToString();

            using (StringReader sr1 = new StringReader(serialization))
            {
                IMainObject deserResult = mainObjSerMgr.Deserialize(sr1, serCtx2);

                IMainObjectSerializationContract ppp = deserResult as IMainObjectSerializationContract;

                ppp.Field1 = "Primo";
                ppp.Field2 = "Coccodrillo";
                ppp.Field4 = false;
                ppp.Field8 = 987.654;

                IValueDomAlignable <IValueUnit, IValueUnit> vDomAligner = deserResult as IValueDomAlignable <IValueUnit, IValueUnit>;

                if (vDomAligner != null)
                {
                    vDomAligner.Align();

                    if (vDomAligner.GetContext(ref serCtx2))
                    {
                        serCtx2.SerializeData     = true;
                        serCtx2.SerializeMetadata = true;

                        tw = new StringWriter();
                        mainObjSerMgr.Serialize(tw, vDomAligner.Data, serCtx2);

                        serialization = tw.ToString();
                    }
                }
            }

            MainObjectFactory mainFact = MainObjectFactory.Singleton;

            mainFact.InitDto.DateTimeField       = DateTime.Now;
            mainFact.InitDto.Field1              = "Test";
            mainFact.InitDto.Field2              = "Mario";
            mainFact.InitDto.Field4              = false;
            mainFact.InitDto.Field8              = 9876.54;
            mainFact.InitDto.Field3.SubObjField1 = "Init Sub 1";
            mainFact.InitDto.Field3.SubObjField2 = "Init Sub 2";

            IMainObject k = mainFact.GetByDto();
        } // End of Serialization1 ()