// Resets the ObjectChangeTracker to the Unchanged state and
 // clears the original values as well as the record of changes
 // to collection properties
 public void AcceptChanges()
 {
     OnObjectStateChanging(ObjectState.Unchanged);
     OriginalValues.Clear();
     ObjectsAddedToCollectionProperties.Clear();
     ObjectsRemovedFromCollectionProperties.Clear();
     ChangeTrackingEnabled = true;
     _objectState          = ObjectState.Unchanged;
 }
 // Resets the ObjectChangeTracker to the Unchanged state and
 // clears the original values as well as the record of changes
 // to collection properties
 public void AcceptChanges()
 {
     ModifiedProperties.Clear();
     OriginalValues.Clear();
     ObjectsAddedToCollectionProperties.Clear();
     ObjectsRemovedFromCollectionProperties.Clear();
     IsChangeTrackingEnabled = true;
     State = ObjectState.Unchanged;
 }
Beispiel #3
0
        // Resets the ObjectChangeTracker to the Unchanged state and
        // rollback the original values as well as the record of changes
        // to collection properties
        public void CancelChanges()
        {
            OnObjectStateChanging(ObjectState.Unchanged);
            // rollback original values
            Type type = _parentObject.GetType();

            foreach (var originalValue in OriginalValues.ToList())
            {
                type.GetProperty(originalValue.Key).SetValue(
                    _parentObject, originalValue.Value, null);
            }
            // create copy of ObjectsAddedToCollectionProperties
            // and ObjectsRemovedFromCollectionProperties
            Dictionary <string, ObjectList> removeCollection =
                ObjectsAddedToCollectionProperties.ToDictionary(n => n.Key, n => n.Value);
            Dictionary <string, ObjectList> addCollection =
                ObjectsRemovedFromCollectionProperties.ToDictionary(n => n.Key, n => n.Value);

            // rollback ObjectsAddedToCollectionProperties
            if (removeCollection.Count > 0)
            {
                foreach (KeyValuePair <string, ObjectList> entry in removeCollection)
                {
                    PropertyInfo collectionProperty = type.GetProperty(entry.Key);
                    IList        collectionObject   = (IList)collectionProperty.GetValue(_parentObject, null);
                    foreach (object obj in entry.Value.ToList())
                    {
                        collectionObject.Remove(obj);
                    }
                }
            }
            // rollback ObjectsRemovedFromCollectionProperties
            if (addCollection.Count > 0)
            {
                foreach (KeyValuePair <string, ObjectList> entry in addCollection)
                {
                    PropertyInfo collectionProperty = type.GetProperty(entry.Key);
                    IList        collectionObject   = (IList)collectionProperty.GetValue(_parentObject, null);
                    foreach (object obj in entry.Value.ToList())
                    {
                        collectionObject.Add(obj);
                    }
                }
            }
            OriginalValues.Clear();
            ObjectsAddedToCollectionProperties.Clear();
            ObjectsRemovedFromCollectionProperties.Clear();
            _objectState = ObjectState.Unchanged;
            OnObjectStateChanged(ObjectState.Unchanged);
        }
Beispiel #4
0
        public void queryKey()
        {
            if (!hKeyQueried)
            {
                IntPtr subKeyNamesUnmanaged;
                int    cSubKeys;
                IntPtr regValuesUnmanaged;
                int    cValues;
                regQuery(hKey, out subKeyNamesUnmanaged, out cSubKeys, out regValuesUnmanaged, out cValues);

                var subKeyNames   = new KeyName[cSubKeys];
                var keyNameStride = Marshal.SizeOf(typeof(KeyName));
                for (int i = 0; i < cSubKeys; i++)
                {
                    var p = new IntPtr(subKeyNamesUnmanaged.ToInt64() + i * keyNameStride);
                    subKeyNames[i] = (KeyName)Marshal.PtrToStructure(p, typeof(KeyName));
                }

                Items.Clear();
                for (int i = 0; i < cSubKeys; i++)
                {
                    Items.Add(new RegTreeViewItem(RegTreeViewItemType.FOLDER)
                    {
                        Title = subKeyNames[i].Name, Parent = this
                    });
                }

                OriginalValues.Clear();
                Values.Clear();
                var regValueStride = Marshal.SizeOf(typeof(RegValue));
                for (int i = 0; i < cValues; i++)
                {
                    var p        = new IntPtr(regValuesUnmanaged.ToInt64() + i * regValueStride);
                    var regValue = (RegValue)Marshal.PtrToStructure(p, typeof(RegValue));
                    OriginalValues.Add(regValue);
                    Values.Add(new RegValueItem(regValue));
                }

                hKeyQueried = true;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Read the data file, skipping over data we're not interested in
        /// but parsing and storing the contents of the first data channel
        /// </summary>
        public static void Read()
        {
            OriginalValues.Clear();

            using (StreamReader r = new StreamReader("ECGSAMPLE.txt"))
            {
                int    bytesRead = 0;
                char[] buffer    = new char[24];

                while (!r.EndOfStream)
                {
                    bytesRead = r.ReadBlock(buffer, 0, 8);
                    if (bytesRead != 8)
                    {
                        break;
                    }

                    bytesRead = r.ReadBlock(buffer, 0, 24);
                    if (bytesRead != 24)
                    {
                        break;
                    }
                    else
                    {
                        ParseData(buffer);
                    }

                    bytesRead = r.ReadBlock(buffer, 0, 2);
                    if (bytesRead != 2)
                    {
                        break;
                    }
                }
            }

            return;
        }
Beispiel #6
0
 public static void Reset()
 {
     OriginalValues.Clear();
 }