/// <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>MeetupAttendee</returns> public static MeetupAttendee BuryElement(NeoVersionedAppUser vau, byte[] domain, int index) { if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY? { return(MeetupAttendee.Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName); //byte[] bkey; MeetupAttendee e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Bury(vau,index).MeetupAttendee.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = MeetupAttendee.Missing(); } else // not MISSING - bury it { e = MeetupAttendee.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, index, _bSTA), e._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeName), e._attendeeName); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeID), e._attendeeID); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeeUrl), e._attendeeUrl); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttendeePhotoUrl), e._attendeePhotoUrl); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bMeetingID), e._meetingID); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bMeetingUrl), e._meetingUrl); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bAttended), e._attended); // NPCLevel4EBuryElement_cs.txt } // Template: NPCLevel4Part2_cs.txt if (NeoTrace.RUNTIME) { LogExt("Bury(vau,i).MeetupAttendee", e); } return(e); }
/// <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>NeoCounter</returns> public static NeoCounter GetElement(NeoVersionedAppUser vau, byte[] domain, int index) { 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); NeoCounter e; //byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Get(bkey).NeoCounter.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NeoCounter.Missing(); } else // not MISSING { int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { e = NeoCounter.Tombstone(); } else // not MISSING && not TOMBSTONED { e = new NeoCounter(); BigInteger CurrentNumber = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bCurrentNumber)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt e._currentNumber = CurrentNumber; // NPCLevel4DBuryElement_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } if (NeoTrace.RUNTIME) { LogExt("Get(bkey).NeoCounter.e", e); } return(e); }
/// <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(NeoCounter e, NeoVersionedAppUser vau, string domain, string sindex) { 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, "NeoCounter"); byte[] bkey; e._state = NeoEntityModel.EntityState.PUTTED; Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, sindex, _bSTA), e._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, sindex, _bCurrentNumber), e._currentNumber); // Template: NPCLevel4APutElement_cs.txt LogExt("PutElement(vau,i).NeoCounter", e); // Template: NPCLevel4BGetElement_cs.txt return(true); }
/// <summary> /// Collectible methods (NPC Level 4) /// </summary> /// <param name="p">p</param> /// <param name="vau">vau</param> /// <param name="index">index</param> /// <returns>bool</returns> public static bool PutElement(Point p, NeoVersionedAppUser vau, int index) { 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, "Point"); byte[] bkey; p._state = NeoEntityModel.EntityState.PUTTED; Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA), p._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bX), p._x); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bY), p._y); LogExt("PutElement(vau,i).p", p); return(true); }
/// <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(UserCredentials e, NeoVersionedAppUser vau, string 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, "UserCredentials"); byte[] bkey; e._state = NeoEntityModel.EntityState.PUTTED; Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedUsername), e._encodedUsername); // Template: NPCLevel4APutElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedPassword), e._encodedPassword); // Template: NPCLevel4APutElement_cs.txt LogExt("PutElement(vau,i).UserCredentials", e); // Template: NPCLevel4BGetElement_cs.txt return(true); }
/// <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>UserCredentials</returns> public static UserCredentials GetElement(NeoVersionedAppUser vau, string 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, "UserCredentials"); UserCredentials e; byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bSTA)); NeoTrace.Trace("Get(bkey).UserCredentials.bsta", bsta.Length, bsta); if (bsta.Length == 0) { e = UserCredentials.Missing(); } else // not MISSING { /*EXT*/ byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEXT)); int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { e = UserCredentials.Tombstone(); } else // not MISSING && not TOMBSTONED { e = new UserCredentials(); byte[] EncodedUsername = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedUsername)); // Template: NPCLevel4CGetElement_cs.txt byte[] EncodedPassword = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, bindex, _bEncodedPassword)); // Template: NPCLevel4CGetElement_cs.txt e._encodedUsername = EncodedUsername; e._encodedPassword = EncodedPassword; // NPCLevel4DBuryElement_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } LogExt("Get(bkey).UserCredentials.e", e); return(e); }
/// <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>Line</returns> public static Line GetElement(NeoVersionedAppUser vau, string domain, int index) { 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, "Line"); Line e; byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA)); NeoTrace.Trace("Get(bkey).Line.bsta", bsta.Length, bsta); if (bsta.Length == 0) { e = Line.Missing(); } else // not MISSING { /*EXT*/ byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bEXT)); int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { e = Line.Tombstone(); } else // not MISSING && not TOMBSTONED { e = new Line(); byte[] BKeyP1 = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bBKeyP1)); // Template: NPCLevel4CGetElement_cs.txt byte[] BKeyP2 = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bBKeyP2)); // Template: NPCLevel4CGetElement_cs.txt e._bKeyP1 = BKeyP1; e._bKeyP2 = BKeyP2; // NPCLevel4DBuryElement_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } LogExt("Get(bkey).Line.e", e); return(e); }
/// <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>Point</returns> public static Point GetElement(NeoVersionedAppUser vau, int index) { 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, "Point"); Point p; byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA)); NeoTrace.Trace("Get(kb).bs", bsta.Length, bsta); if (bsta.Length == 0) { p = Point.Missing(); } else // not MISSING { /*EXT*/ byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bEXT)); int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { p = Point.Tombstone(); } else // not MISSING && not TOMBSTONED { p = new Point(); BigInteger x = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bX)).AsBigInteger(); BigInteger y = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bY)).AsBigInteger(); p._x = x; p._y = y; p._state = sta; p._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } LogExt("Get(kb).p", p); return(p); }
/// <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>UserPoint</returns> public static UserPoint GetElement(NeoVersionedAppUser vau, byte[] domain, int index) { 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, "UserPoint"); UserPoint e; byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bSTA)); NeoTrace.Trace("Get(bkey).UserPoint.bsta", bsta.Length, bsta); if (bsta.Length == 0) { e = UserPoint.Missing(); } else // not MISSING { /*EXT*/ byte[] bext = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bEXT)); int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { e = UserPoint.Tombstone(); } else // not MISSING && not TOMBSTONED { e = new UserPoint(); BigInteger X = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bX)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt BigInteger Y = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, bkey = NeoStorageKey.StorageKey(nsk, index, _bY)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt e._x = X; e._y = Y; // NPCLevel4DBuryElement_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } LogExt("Get(bkey).UserPoint.e", e); return(e); }
/// <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>NPCContributor</returns> public static NPCContributor BuryElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex) { if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY? { return(NPCContributor.Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName); //byte[] bkey; NPCContributor e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Bury(vau,index).NPCContributor.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCContributor.Missing(); } else // not MISSING - bury it { e = NPCContributor.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, _bName), e._name); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bTitle), e._title); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bApproverScriptHash), e._approverScriptHash); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bReqPublicKey), e._reqPublicKey); // NPCLevel4EBuryElement_cs.txt } // Template: NPCLevel4Part2_cs.txt if (NeoTrace.RUNTIME) { LogExt("Bury(vau,i).NPCContributor", e); } return(e); }
/// <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(NFT e, NeoVersionedAppUser vau, byte[] domain, int index) { 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[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Get(bkey).NFT.bsta", bsta.Length, bsta); } bool isMissing = false; if (bsta.Length == 0) { isMissing = true; } //byte[] bkey; e._state = NeoEntityModel.EntityState.PUTTED; Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA), e._state.AsBigInteger()); if (isMissing) { Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bUri), e._uri); // Template: NPCLevel4APutElementExt0_cs.txt } Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bFirstName), e._firstName); // Template: NPCLevel4APutElementExt0_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bLastName), e._lastName); // Template: NPCLevel4APutElementExt0_cs.txt if (NeoTrace.RUNTIME) { LogExt("PutElement(vau,i).NFT", e); // Template: NPCLevel4BGetElement_cs.txt } return(true); }
/// <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); }