コード例 #1
0
ファイル: Records.cs プロジェクト: edalcazar/Simon
 /// <summary>
 /// Get the record holder information from local file
 /// </summary>
 /// <returns></returns>
 private static RecordObject getRecordInfo()
 {
     if (File.Exists(fileLocation))
     {
         try
         {
             IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
             using (Stream serialStream = new FileStream(fileLocation, FileMode.Open, FileAccess.Read, FileShare.Read))
             {
                 RecordObject recordInfo = (RecordObject)formatter.Deserialize(serialStream);
                 return(recordInfo);
             }
         }
         catch (Exception)
         {
             // Do nothing if the file can't be read (e.g., corrupted due to manual editing)
             // Just return blank RecordObject
             return(new RecordObject());
         }
     }
     else
     {
         return(new RecordObject());
     }
 }
コード例 #2
0
    protected virtual void Start()
    {
        recordState = RecordState.Idle;
        if (fps <= 0f)
        {
            m_TimePerFrame = 0.0f;
        }
        else
        {
            m_TimePerFrame = 1.0f / fps;
        }
        //
        int i = 0, imax = m_Transforms.Length;

        recordObjects = new RecordObject[imax];
        for (; i < imax; ++i)
        {
            recordObjects[i] = new RecordObject(this, m_Transforms[i]);
        }
        //
        if (!string.IsNullOrEmpty(fileName))
        {
#if UNITY_EDITOR
            Load(fileName);
#endif
        }
    }
コード例 #3
0
 public string GetValue(string identityId, string datasetName, string key)
 {
     lock (_lock)
     {
         RecordObject record = GetRecordInternal(identityId, datasetName, key);
         return(record == null ? null : record.Value);
     }
 }
コード例 #4
0
        private Record ConvertToRecord(RecordObject record)
        {
            if (record == null)
            {
                return(null);
            }

            return(new Record(record.Key, record.Value, record.SyncCount, record.LastModifiedTimestamp, record.LastModifiedBy, record.DeviceLastModifiedTimestamp, record.IsModified));
        }
コード例 #5
0
        public void flushUserRecord(string record)
        {
            var recObj = new RecordObject(record);

            lock (recordsLocker)
            {
                dbManager.insertRecord(recObj);
            }
        }
コード例 #6
0
    //レコードが端まで行って、逆の端に移動するときの処理
    private void changeRecordData(GameObject record, int listCount)
    {
        listShowRecordFolderCount = makeListShowRecord(showRecordMidNum, listMusicDict.Count);
        int          folderCount = listShowRecordFolderCount[listCount];
        RecordObject rd          = record.GetComponent <RecordObject>();

        Debug.Log("midNum : " + showRecordMidNum + " show_recoed_num :" + SHOW_RECOED_NUM);
        rd.setDictMusicData(listMusicDict[folderCount]);
        rd.showInfomation();
    }
コード例 #7
0
        public override ReferencePicklistItem GetValueAsPicklistItem()
        {
            if (Value == null)
            {
                return(null);
            }
            var iReocrd = new RecordObject(RecordTypeToLookup);

            iReocrd.Id = Value.Id;
            return(new ReferencePicklistItem(iReocrd, Value.Name));
        }
コード例 #8
0
    //レコードの作成
    private GameObject makeRecord(Dictionary <string, string> dictMusicData, Vector3 pos, int localRecordCount)
    {
        GameObject   obj = Instantiate(RECORD_OBJECT) as GameObject;
        RecordObject rd  = obj.GetComponent <RecordObject>();

        rd.setDictMusicData(dictMusicData);
        rd.setLocalRecordCount(localRecordCount);
        rd.showInfomation();
        obj.transform.position = pos;
        return(obj);
    }
コード例 #9
0
        public void PutRecords(string identityId, string datasetName, List <Record> records)
        {
            lock (_lock)
            {
                string datasetKey = MakeKey(identityId, datasetName);
                if (!InMemoryStorage.DatasetStore.ContainsKey(datasetKey))
                {
                    throw new KeyNotFoundException("Dataset");
                }

                Dictionary <string, RecordObject> inmemoryDatasetMap = InMemoryStorage.DatasetStore[datasetKey];
                RecordObject storedRecord;

                foreach (Record record in records)
                {
                    if (inmemoryDatasetMap.ContainsKey(record.Key))
                    {
                        storedRecord                             = inmemoryDatasetMap[record.Key];
                        storedRecord.Value                       = record.Value;
                        storedRecord.IsModified                  = record.IsModified;
                        storedRecord.SyncCount                   = record.SyncCount;
                        storedRecord.LastModifiedTimestamp       = record.LastModifiedDate;
                        storedRecord.LastModifiedBy              = record.LastModifiedBy;
                        storedRecord.DeviceLastModifiedTimestamp = record.DeviceLastModifiedDate;
                    }
                    else
                    {
                        storedRecord = new RecordObject
                        {
                            IdentityId                  = identityId,
                            DatasetName                 = datasetName,
                            Key                         = record.Key,
                            Value                       = record.Value,
                            SyncCount                   = record.SyncCount,
                            LastModifiedTimestamp       = record.LastModifiedDate,
                            LastModifiedBy              = record.LastModifiedBy,
                            DeviceLastModifiedTimestamp = record.DeviceLastModifiedDate,
                            IsModified                  = record.IsModified
                        };
                    }
                }
                UpdateLastModifiedTimestamp(identityId, datasetName);
            }
        }
コード例 #10
0
        public CommResult getRequestInsts <T>(string requestUrl)
        {
            string     json = null;
            CommResult ret  = new CommResult();

            try
            {
                json = AccessWebServerClass.GetData(requestUrl, Encoding.Default);
                if (json == null)
                {
                    ret.Message = "未请求到内容!";
                    return(ret);
                }
            }
            catch (Exception ce)
            {
                ret.Message = ce.Message;
                return(ret);
            }
            RecordObject rc = Activator.CreateInstance(typeof(T)) as RecordObject;

            try
            {
                rc = (rc as iSerialJsonClass <T>).getObjectByJsonString(json) as RecordObject;
            }
            catch (Exception e)
            {
                ret.Message = e.Message;
                return(ret);
            }
            ret.Json = json;
            if (rc == null)
            {
                ret.Message = "数据格式错误!";
                return(ret);
            }
            ret.Succ   = true;
            ret.Result = new List <RecordObject>();
            ret.Cnt    = 1;
            ret.Result.Add(rc);
            return(ret);
        }
コード例 #11
0
        private GraphUndo()
        {
            m_recordObject = ScriptableObject.CreateInstance <RecordObject> ();

            // Get the internal delegate from Unity.
            Assembly   UnityEditorAsssembly = Assembly.GetAssembly(typeof(UnityEditor.Editor));
            Type       undoType             = UnityEditorAsssembly.GetType("UnityEditor.Undo");
            MethodInfo getRecordsInternal   = undoType.GetMethod("GetRecordsInternal", BindingFlags.NonPublic | BindingFlags.Static);

            getRecordsInternalCallback = (Action <object, object>)Delegate.CreateDelegate(typeof(Action <object, object>), getRecordsInternal);

            EditorApplication.update -= Update;
            EditorApplication.update += Update;

            UnityEditor.Undo.undoRedoPerformed -= OnUndoRedoPerformed;
            UnityEditor.Undo.undoRedoPerformed += OnUndoRedoPerformed;


            #if UNDO_DEBUG
            Debug.Log("Undo Initialized");
            #endif
        }
コード例 #12
0
        private void PutValueInternal(string identityId, string datasetName, string key, string value)
        {
            lock (_lock)
            {
                string       datasetKey = MakeKey(identityId, datasetName);
                RecordObject record     = GetRecordInternal(identityId, datasetName, key);

                if (record != null && record.Value.Equals(value, StringComparison.Ordinal))
                {
                    return;
                }

                if (record == null)
                {
                    record = new RecordObject
                    {
                        IdentityId                  = identityId,
                        DatasetName                 = datasetName,
                        Key                         = key,
                        Value                       = value,
                        SyncCount                   = 0,
                        LastModifiedTimestamp       = DateTime.Now,
                        LastModifiedBy              = string.Empty,
                        DeviceLastModifiedTimestamp = null,
                        IsModified                  = true
                    };
                }
                else
                {
                    record.Value                 = value;
                    record.IsModified            = true;
                    record.LastModifiedTimestamp = DateTime.Now;
                }

                InMemoryStorage.DatasetStore[datasetKey][key] = record;
            }
        }
コード例 #13
0
        public void PutRecords(string identityId, string datasetName, List<Record> records)
        {
            lock (_lock)
            {
                string datasetKey = MakeKey(identityId, datasetName);
                if (!InMemoryStorage.DatasetStore.ContainsKey(datasetKey))
                    throw new KeyNotFoundException("Dataset");

                Dictionary<string, RecordObject> inmemoryDatasetMap = InMemoryStorage.DatasetStore[datasetKey];
                RecordObject storedRecord;

                foreach (Record record in records)
                {
                    if (inmemoryDatasetMap.ContainsKey(record.Key))
                    {
                        storedRecord = inmemoryDatasetMap[record.Key];
                        storedRecord.Value = record.Value;
                        storedRecord.IsModified = record.IsModified;
                        storedRecord.SyncCount = record.SyncCount;
                        storedRecord.LastModifiedTimestamp = record.LastModifiedDate;
                        storedRecord.LastModifiedBy = record.LastModifiedBy;
                        storedRecord.DeviceLastModifiedTimestamp = record.DeviceLastModifiedDate;
                    }
                    else
                    {
                        storedRecord = new RecordObject
                        {
                            IdentityId = identityId,
                            DatasetName = datasetName,
                            Key = record.Key,
                            Value = record.Value,
                            SyncCount = record.SyncCount,
                            LastModifiedTimestamp = record.LastModifiedDate,
                            LastModifiedBy = record.LastModifiedBy,
                            DeviceLastModifiedTimestamp = record.DeviceLastModifiedDate,
                            IsModified = record.IsModified
                        };
                    }
                }
                UpdateLastModifiedTimestamp(identityId, datasetName);
            }
        }
コード例 #14
0
        private void PutValueInternal(string identityId, string datasetName, string key, string value)
        {
            lock (_lock)
            {
                string datasetKey = MakeKey(identityId, datasetName);
                RecordObject record = GetRecordInternal(identityId, datasetName, key);

                if (record != null && record.Value.Equals(value, StringComparison.Ordinal))
                {
                    return;
                }

                if (record == null)
                {
                    record = new RecordObject
                    {
                        IdentityId = identityId,
                        DatasetName = datasetName,
                        Key = key,
                        Value = value,
                        SyncCount = 0,
                        LastModifiedTimestamp = DateTime.Now,
                        LastModifiedBy = string.Empty,
                        DeviceLastModifiedTimestamp = null,
                        IsModified = true
                    };
                }
                else
                {
                    record.Value = value;
                    record.IsModified = true;
                    record.LastModifiedTimestamp = DateTime.Now;
                }

                InMemoryStorage.DatasetStore[datasetKey][key] = record;
            }
        }
コード例 #15
0
        private Record ConvertToRecord(RecordObject record)
        {
            if (record == null)
                return null;

            return new Record(record.Key, record.Value, record.SyncCount, record.LastModifiedTimestamp, record.LastModifiedBy, record.DeviceLastModifiedTimestamp, record.IsModified);
        }