public static bool Put(REL_Contrib_Req e, string key)
        {
            if (key.Length == 0)
            {
                return(false);
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(skey).REL_Contrib_Req", e);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            string _skeyTag = key + _classKeyTag;

            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Put(skey)._skeyTag", _skeyTag);
            }

            e._state = NeoEntityModel.EntityState.PUTTED;
            BigInteger bis = e._state.AsBigInteger();

            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Put(skey).bis", bis);
            }
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sSTA, bis);
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sReqIndex, e._reqIndex); // Template: NPCLevel2EPut_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(skey).REL_Contrib_Req", e);                   // Template: NPCLevel2FGet_cs.txt
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Bury an element of an array of entities in Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>REL_Contrib_Req</returns>
        public static REL_Contrib_Req BuryElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY?
            {
                return(REL_Contrib_Req.Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            //byte[] bkey;
            REL_Contrib_Req e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Bury(vau,index).REL_Contrib_Req.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = REL_Contrib_Req.Missing();
            }
            else // not MISSING - bury it
            {
                e = REL_Contrib_Req.Tombstone(); // TODO - should Bury() preserve the exist field values or re-initialize them? Preserve is cheaper but not as private
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger());

                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bReqIndex), e._reqIndex); // NPCLevel4EBuryElement_cs.txt
            } // Template: NPCLevel4Part2_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Bury(vau,i).REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #3
0
        public static REL_Contrib_Req Bury(string key)
        {
            if (key.Length == 0)
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            string _skeyTag = key + _classKeyTag;

            REL_Contrib_Req e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA);
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Bury(skey).REL_Contrib_Req.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = REL_Contrib_Req.Missing();
            }
            else // not MISSING - bury it
            {
                e = REL_Contrib_Req.Tombstone(); // but don't overwrite existing field values - just tombstone it
                Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sSTA, e._state.AsBigInteger());

                //Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sReqIndex, e._reqIndex); // Template: NPCLevel3CBury_cs.txt
            } // Template: NPCLevel3Part2_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Bury(skey).REL_Contrib_Req", e);
            }
            return(e); // return Entity e to signal if key is Missing or bad key
        }
コード例 #4
0
 // Factory methods // Template: NPCLevel1Part2_cs.txt
 private static REL_Contrib_Req _Initialize(REL_Contrib_Req e)
 {
     e._reqIndex = 0;
     e._state    = NeoEntityModel.EntityState.NULL;
     if (NeoTrace.RUNTIME)
     {
         LogExt("_Initialize(e).REL_Contrib_Req", e);
     }
     return(e);
 }
コード例 #5
0
        public static REL_Contrib_Req Null()
        {
            REL_Contrib_Req e = new REL_Contrib_Req();

            _Initialize(e);
            if (NeoTrace.RUNTIME)
            {
                LogExt("Null().REL_Contrib_Req", e);
            }
            return(e);
        }
        public static REL_Contrib_Req Missing()
        {
            REL_Contrib_Req e = new REL_Contrib_Req();

            e._reqIndex = 0;
            e._state    = NeoEntityModel.EntityState.MISSING;
            if (NeoTrace.RUNTIME)
            {
                LogExt("Missing().REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #7
0
        public static REL_Contrib_Req Tombstone()
        {
            REL_Contrib_Req e = new REL_Contrib_Req();

            e._reqIndex = 0;
            e._state    = NeoEntityModel.EntityState.TOMBSTONED;
            if (NeoTrace.RUNTIME)
            {
                LogExt("Tombstone().REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #8
0
        public static REL_Contrib_Req New(BigInteger ReqIndex)
        {
            REL_Contrib_Req e = new REL_Contrib_Req();

            e._reqIndex = ReqIndex;
            e._state    = NeoEntityModel.EntityState.INIT;
            if (NeoTrace.RUNTIME)
            {
                LogExt("New(.,.).REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #9
0
        /// <summary>
        /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4)
        /// </summary>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>REL_Contrib_Req</returns>
        public static REL_Contrib_Req GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            REL_Contrib_Req e;

            //byte[] bkey;
            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).REL_Contrib_Req.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = REL_Contrib_Req.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                if (sta == NeoEntityModel.EntityState.TOMBSTONED)
                {
                    e = REL_Contrib_Req.Tombstone();
                }
                else // not MISSING && not TOMBSTONED
                {
                    e = new REL_Contrib_Req();
                    BigInteger ReqIndex = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bReqIndex)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt

                    e._reqIndex = ReqIndex;                                                                                                                            // NPCLevel4DBuryElement_cs.txt
                    e._state    = sta;
                    e._state    = NeoEntityModel.EntityState.GETTED;                                                                                                   /* OVERRIDE */
                }
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).REL_Contrib_Req.e", e);
            }
            return(e);
        }
コード例 #10
0
        public static REL_Contrib_Req Get(string key)
        {
            if (key.Length == 0)
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            string _skeyTag = key + _classKeyTag;

            REL_Contrib_Req e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA);
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(skey).REL_Contrib_Req.bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = REL_Contrib_Req.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                e = new REL_Contrib_Req();

                BigInteger ReqIndex = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sReqIndex).AsBigInteger(); //NPCLevel2IGet_cs.txt
                if (NeoTrace.RUNTIME)
                {
                    TraceRuntime("Get(skey).e._reqIndex", e._reqIndex);                   // Template: NPCLevel2Part2_cs.txt
                }
                e._reqIndex = ReqIndex;
                e._state    = sta;
                e._state    = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(skey).REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #11
0
        public static bool Put(REL_Contrib_Req e, byte[] key)
        {
            if (key.Length == 0)
            {
                return(false);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            byte[] _bkeyTag = Helper.Concat(key, _bclassKeyTag);

            e._state = NeoEntityModel.EntityState.PUTTED;
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bSTA), e._state.AsBigInteger());

            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, Helper.Concat(_bkeyTag, _bReqIndex), e._reqIndex); // Template: NPCLevel2CPut_cs.txt
            if (NeoTrace.RUNTIME)
            {
                LogExt("Put(bkey).REL_Contrib_Req", e);                   // Template: NPCLevel2DPut_cs.txt
            }
            return(true);
        }
コード例 #12
0
        /// <summary>
        /// Collectible methods (NPC Level 4)
        /// </summary>
        /// <param name="e">e</param>
        /// <param name="vau">vau</param>
        /// <param name="index">index</param>
        /// <returns>bool</returns>
        public static bool PutElement(REL_Contrib_Req e, NeoVersionedAppUser vau, byte[] domain, byte[] bindex)
        {
            if (NeoVersionedAppUser.IsNull(vau))
            {
                return(false);
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName);

            //byte[] bkey;
            e._state = NeoEntityModel.EntityState.PUTTED;
            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger());

            Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bReqIndex), e._reqIndex); // Template: NPCLevel4APutElement_cs.txt

            if (NeoTrace.RUNTIME)
            {
                LogExt("PutElement(vau,i).REL_Contrib_Req", e);                   // Template: NPCLevel4BGetElement_cs.txt
            }
            return(true);
        }
コード例 #13
0
        public static REL_Contrib_Req Get(byte[] key)
        {
            if (key.Length == 0)
            {
                return(Null());
            }

            Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext;
            byte[] _bkeyTag = Helper.Concat(key, _bclassKeyTag);

            REL_Contrib_Req e;

            byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bSTA));
            if (NeoTrace.RUNTIME)
            {
                TraceRuntime("Get(bkey).bsta", bsta.Length, bsta);
            }
            if (bsta.Length == 0)
            {
                e = REL_Contrib_Req.Missing();
            }
            else // not MISSING
            {
                int ista = (int)bsta.AsBigInteger();
                NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista;
                e = new REL_Contrib_Req();

                BigInteger ReqIndex = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bReqIndex)).AsBigInteger(); //NPCLevel2GGet_cs.txt
                e._reqIndex = ReqIndex;                                                                                                              // Template: NPCLevel2HGet_cs.txt
                e._state    = sta;
                e._state    = NeoEntityModel.EntityState.GETTED;                                                                                     /* OVERRIDE */
            }
            if (NeoTrace.RUNTIME)
            {
                LogExt("Get(bkey).REL_Contrib_Req", e);
            }
            return(e);
        }
コード例 #14
0
 // Persistable methods
 public static bool IsMissing(REL_Contrib_Req e)
 {
     return(e._state == NeoEntityModel.EntityState.MISSING);
 }
コード例 #15
0
 public static void LogExt(string label, REL_Contrib_Req e)
 {
     TraceRuntime(label, e._reqIndex, e._state);
 }
コード例 #16
0
 public static void Set(REL_Contrib_Req e, BigInteger ReqIndex) // Template: NPCLevel1Set_cs.txt
 {
     e._reqIndex = ReqIndex;  e._state = NeoEntityModel.EntityState.SET;
 }
コード例 #17
0
 public static BigInteger GetReqIndex(REL_Contrib_Req e)
 {
     return(e._reqIndex);
 }
コード例 #18
0
        // Accessors

        public static void SetReqIndex(REL_Contrib_Req e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
        {
            e._reqIndex = value; e._state = NeoEntityModel.EntityState.SET;
        }
コード例 #19
0
 // EntityState wrapper methods
 public static bool IsNull(REL_Contrib_Req e)
 {
     return(e._state == NeoEntityModel.EntityState.NULL);
 }
コード例 #20
0
 // Deletable methods
 public static bool IsBuried(REL_Contrib_Req e)
 {
     return(e._state == NeoEntityModel.EntityState.TOMBSTONED);
 }