public SavedEntryModel(SavedEntry entry) : this(
         entry.PostId,
         entry.Name,
         entry.Message,
         entry.Timestamp,
         entry.IPAddress
         )
 {
 }
示例#2
0
    private void checkForChanges()
    {
        string SavedEntry, NewEntry, ItemIDFile, ItemID;
        int    savedCurrentItemIndex;
        Tuple <string, string> dataTuple = new Tuple <string, string>("", "");        // For the item entry later

        // Save the current state - we will return to it later.
        savedCurrentItemIndex = this.currentItemIndex;

        ItemIDFile = listOfFiles[currentItemIndex];                     // Get the filename of the current ID
        ItemID     = extractIndexFromFilename(ItemIDFile);              // Get the ItemID from the filename

        // Check if the file exists (if it isn't a 'new' item
        if (File.Exists(ItemIDFile))
        {
            dataTuple = getXMLEntry(ItemID);             // Get the file for that specific item.
        }

        // Add the title and the entry together
        SavedEntry = dataTuple.Item1 + dataTuple.Item2;

        // Have to have a TextBuffer for the ItemText
        Gtk.TextBuffer ItemTextBuffer;

        // Assign the Item text to the buffer.
        ItemTextBuffer = ItemText.Buffer;

        // Get the text from the title and the main part.
        NewEntry = ItemTitle.Text + ItemTextBuffer.Text;

        bool result = SavedEntry.Equals(NewEntry, StringComparison.Ordinal);

        // return a value based on the T/F for result.
        // MessageBox(result ? "same" : "not the same");
        Console.WriteLine(ItemIDFile);
        Console.WriteLine(savedCurrentItemIndex);

        // If it is in the index
        if (File.Exists(ItemIDFile))
        {
            askForSave(result);
        }
        else
        {
            askForSave(result);
            GetDirectoryFiles();
            savedCurrentItemIndex = 0;
        }

        // Reset the current item to the number that it was at the beginning of this function.
        this.currentItemIndex = savedCurrentItemIndex;
    }
示例#3
0
        public void Add(Entry entry)
        {
            var savedEntry = SavedEntry.FromEntry(this.NewPostId(), entry);

            this.Entries.Add(savedEntry);
        }
        /// <summary>
        /// Locate the property that we should be synchronizing.
        /// </summary>

        void Awake()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                TNAutoSync[] tns = GetComponents <TNAutoSync>();

                if (tns.Length > 1 && tns[0] != this)
                {
                    Debug.LogError("Can't have more than one " + GetType() + " per game object", gameObject);
                    DestroyImmediate(this);
                }
            }
            else
#endif
            {
                // Find all properties, converting the saved list into the usable list of reflected properties
                for (int i = 0, imax = entries.Count; i < imax; ++i)
                {
                    SavedEntry ent = entries[i];

                    if (ent.target != null && !string.IsNullOrEmpty(ent.propertyName))
                    {
                        FieldInfo field = ent.target.GetType().GetField(ent.propertyName, BindingFlags.Instance | BindingFlags.Public);

                        if (field != null)
                        {
                            ExtendedEntry ext = new ExtendedEntry();
                            ext.target    = ent.target;
                            ext.field     = field;
                            ext.lastValue = field.GetValue(ent.target);
                            mList.Add(ext);
                            continue;
                        }
                        else
                        {
                            PropertyInfo pro = ent.target.GetType().GetProperty(ent.propertyName, BindingFlags.Instance | BindingFlags.Public);

                            if (pro != null)
                            {
                                ExtendedEntry ext = new ExtendedEntry();
                                ext.target    = ent.target;
                                ext.property  = pro;
                                ext.lastValue = pro.GetValue(ent.target, null);
                                mList.Add(ext);
                                continue;
                            }
                            else
                            {
                                Debug.LogError("Unable to find property: '" + ent.propertyName + "' on " + ent.target.GetType());
                            }
                        }
                    }
                }

                if (mList.size > 0f)
                {
                    if (updatesPerSecond > 0f)
                    {
                        StartCoroutine(PeriodicSync());
                    }
                }
                else
                {
                    Debug.LogWarning("Nothing to sync", this);
                    enabled = false;
                }
            }
        }