Ejemplo n.º 1
0
 public SyncSourceRoot(object source, SyncSourceSettings settings)
 {
     Settings = settings;
     _fieldDeserializerResolver  = settings.FieldDeserializerResolverFactory.Create(_referencePool);
     _referenceCollector         = new ReferenceCollector <SyncSource>(_referencePool);
     AddReference(_rootReference = source);
 }
 public ObservableDictionarySyncSource(SyncSourceRoot syncSourceRoot, int referenceId,
                                       ObservableDictionary <TKey, TValue> baseObject,
                                       IFieldSerializerResolver fieldSerializerResolver) : base(syncSourceRoot, referenceId, baseObject)
 {
     _keySerializer                = fieldSerializerResolver.FindMatchingSerializer(typeof(TKey));
     _valueSerializer              = fieldSerializerResolver.FindMatchingSerializer(typeof(TValue));
     BaseObject.CollectionChanged += OnCollectionChanged;
     AddNewItemReferences(BaseObject.ToList());
 }
Ejemplo n.º 3
0
        public SyncTarget Create(int referenceId, Type baseType, ExtendedBinaryReader reader,
                                 IFieldSerializerResolver fieldDeserializerResolver, SyncTargetRoot root)
        {
            Type[] genericArgs = baseType.GetGenericArguments();
            Type   observableDictionarySyncSourceObjectType =
                typeof(ObservableDictionarySyncTarget <,>).MakeGenericType(genericArgs);

            return((SyncTarget)Activator.CreateInstance(observableDictionarySyncSourceObjectType, referenceId,
                                                        baseType, reader, root, fieldDeserializerResolver));
        }
Ejemplo n.º 4
0
        public NotifyPropertyChangedSyncSource(SyncSourceRoot syncSourceRoot, int referenceId,
                                               INotifyPropertyChanged baseObject,
                                               IFieldSerializerResolver fieldSerializerResolver) :
            base(syncSourceRoot, referenceId, baseObject)
        {
            baseObject.PropertyChanged += SourceObjectOnPropertyChanged;

            _changeTracker.Dirty += ChangeTrackerOnDirty;
            PropertyInfo[] properties = BaseObject.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
            (PropertyInfo info, SyncAttribute attibute)[] syncProperties =
        public SyncSource Create(SyncSourceRoot syncSourceRoot, int referenceId, object baseType,
                                 IFieldSerializerResolver fieldSerializerResolver)
        {
            Type[] genericArgs = baseType.GetType().GetGenericArguments();
            Type   observableDictionarySyncSourceObjectType =
                typeof(ObservableDictionarySyncSource <,>).MakeGenericType(genericArgs);

            return((SyncSource)Activator.CreateInstance(observableDictionarySyncSourceObjectType, syncSourceRoot,
                                                        referenceId,
                                                        baseType, fieldSerializerResolver));
        }
        public ObservableDictionarySyncTarget(int referenceId, Type baseType, ExtendedBinaryReader reader,
                                              SyncTargetRoot syncTargetRoot, IFieldSerializerResolver fieldDeserializerResolver) : base(referenceId)
        {
            _syncTargetRoot = syncTargetRoot;
            _clock          = _syncTargetRoot.Clock;

            base.BaseObject = Activator.CreateInstance(baseType);
            BaseObject.CollectionChanged += OnCollectionChanged;

            _keySerializer   = fieldDeserializerResolver.FindMatchingSerializer(typeof(TKey));
            _valueSerializer = fieldDeserializerResolver.FindMatchingSerializer(typeof(TValue));

            _syncTargetRoot.EndRead += EndRead;
            Read(reader);
        }
        public NotifyPropertyChangedSyncTarget(int referenceId, Type baseType, ExtendedBinaryReader reader,
                                               SyncTargetRoot syncTargetRoot,
                                               IFieldSerializerResolver fieldDeserializerResolver) : base(referenceId)
        {
            _syncTargetRoot = syncTargetRoot;

            ConstructorInfo attributeMarkedConstructor        = GetAttributeMarkedConstructor(baseType);
            bool            attributeMarkedConstructorPresent = attributeMarkedConstructor != null;

            base.BaseObject = attributeMarkedConstructorPresent
                ? FormatterServices.GetUninitializedObject(baseType)
                : Activator.CreateInstance(baseType);
            BaseObject.PropertyChanged += TargetOnPropertyChanged;

            (PropertyInfo info, SyncAttribute attibute)[] syncPropertiesInfo = GetProperties();
Ejemplo n.º 8
0
 public SyncTarget Create(int referenceId, Type baseType, ExtendedBinaryReader reader,
                          IFieldSerializerResolver fieldSerializerResolver, SyncTargetRoot root)
 {
     return(new StringSyncTarget(referenceId, reader));
 }
Ejemplo n.º 9
0
 public SyncSource Create(SyncSourceRoot syncSourceRoot, int referenceId, object baseType,
                          IFieldSerializerResolver fieldSerializerResolver)
 {
     return(new StringSyncSource(syncSourceRoot, referenceId, baseType as string));
 }
 public SyncSource Create(SyncSourceRoot syncSourceRoot, int referenceId, object baseType,
                          IFieldSerializerResolver fieldSerializerResolver)
 {
     return(new NotifyPropertyChangedSyncSource(syncSourceRoot, referenceId, baseType as INotifyPropertyChanged,
                                                fieldSerializerResolver));
 }
Ejemplo n.º 11
0
 public SyncTarget Create(int referenceId, Type baseType, ExtendedBinaryReader reader,
                          IFieldSerializerResolver fieldSerializerResolver, SyncTargetRoot clock)
 {
     return(new NotifyPropertyChangedSyncTarget(referenceId, baseType, reader, clock, fieldSerializerResolver));
 }