Ejemplo n.º 1
0
        public ObjectSourceSynchronizer(SourceSynchronizerRoot sourceSynchronizerRoot, int referenceId,
                                        object reference) :
            base(sourceSynchronizerRoot, referenceId, reference)
        {
            Type type = Reference.GetType();

            SynchronizableMember[] synchronizableMembers = sourceSynchronizerRoot.SynchronizableMemberFactory.FromType(type);
            SynchronizableSourceMembers = new SynchronizableSourceMember[synchronizableMembers.Length];
            for (var i = 0; i < synchronizableMembers.Length; i++)
            {
                SynchronizableMember synchronizableMember = synchronizableMembers[i];
                var synchronizableSourceMember            = new SynchronizableSourceMember(Reference, synchronizableMember);
                SynchronizableSourceMembers[i] = synchronizableSourceMember;
            }

            for (var i = 0; i < SynchronizableSourceMembers.Length; i++)
            {
                SynchronizableSourceMember synchronizableSourceMember = SynchronizableSourceMembers[i];
                if (!synchronizableSourceMember.IsValueType)
                {
                    object initialValue = synchronizableSourceMember.Value;
                    if (initialValue != null)
                    {
                        sourceSynchronizerRoot.Synchronize(initialValue);
                    }
                }
            }
        }
 public bool TryGetMemberByName(string memberName, out SynchronizableSourceMember synchronizableSourceMember)
 {
     for (var i = 0; i < SynchronizableSourceMembers.Length; i++)
     {
         SynchronizableSourceMember x = SynchronizableSourceMembers[i];
         if (x.Name == memberName)
         {
             synchronizableSourceMember = x;
             return(true);
         }
     }
     synchronizableSourceMember = default;
     return(false);
 }