public override MetadataDictionary GetMetadata() { var metadata = base.GetMetadata(); metadata[41] = new MetadataString($"npc_{(int) NpcSkinType}"); return(metadata); }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = base.GetMetadata(); metadata[1] = new MetadataInt(12); metadata[2] = new MetadataInt(0); metadata[3] = new MetadataByte(CollarColor); metadata[4] = new MetadataString("Testing"); metadata[5] = new MetadataLong(Owner.EntityId); metadata[7] = new MetadataShort(300); metadata[8] = new MetadataInt(0); metadata[9] = new MetadataByte(0); metadata[38] = new MetadataLong(0); metadata[39] = new MetadataFloat(1.0f); metadata[44] = new MetadataShort(300); metadata[45] = new MetadataInt(0); metadata[46] = new MetadataByte(0); metadata[47] = new MetadataInt(0); metadata[53] = new MetadataFloat(0.6f); metadata[54] = new MetadataFloat(0.8f); metadata[56] = new MetadataVector3(0, 0, 0); metadata[57] = new MetadataByte(0); metadata[58] = new MetadataFloat(0f); metadata[59] = new MetadataFloat(0f); return(metadata); }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataLong(0); // 0 metadata[1] = new MetadataInt(1); metadata[2] = new MetadataInt(12); metadata[3] = new MetadataByte(0); metadata[4] = new MetadataString(""); metadata[5] = new MetadataLong(-1); metadata[7] = new MetadataShort(300); metadata[39] = new MetadataFloat(1f); metadata[44] = new MetadataShort(300); metadata[45] = new MetadataInt(0); metadata[46] = new MetadataByte(0); metadata[47] = new MetadataInt(0); metadata[53] = new MetadataFloat(0.98f); metadata[54] = new MetadataFloat(0.98f); metadata[56] = new MetadataVector3(0, 0, 0); metadata[57] = new MetadataByte(0); metadata[58] = new MetadataFloat(0f); metadata[59] = new MetadataFloat(0f); return(metadata); }
public void Write_MetaDataObjects() { const string file = @"..\..\..\Sample\Core\metadata.x3d"; var x3d = new X3D(); var scene = x3d.Scene; var meta1 = new MetadataDouble(); var meta2 = new MetadataFloat(); var meta3 = new MetadataInteger(); var meta4 = new MetadataSet(); var meta5 = new MetadataString(); meta1.Name = "double"; meta1.Value = "1 1 1 1 1"; meta1.Reference = "reference"; scene.ChildNodes.Add(meta1); scene.ChildNodes.Add(meta2); scene.ChildNodes.Add(meta3); scene.ChildNodes.Add(meta4); scene.ChildNodes.Add(meta5); var submeta1 = new MetadataDouble(); var submeta2 = new MetadataFloat(); var submeta3 = new MetadataInteger(); var submeta4 = new MetadataString(); meta4.Value.Add(submeta1); meta4.Value.Add(submeta2); meta4.Value.Add(submeta3); meta4.Value.Add(submeta4); Write(file, x3d); }
public override MetadataDictionary GetMetadata() { var metadata = base.GetMetadata(); metadata[40] = new MetadataString(InteractionLabel); return(metadata); }
public override MetadataDictionary GetMetadata() { //[0] byte 0 0, //[1] short 1 300, //[2] string 4 Client12, //[3] byte 0 1, //[4] byte 0 0, //[7] int 2 0, //[8] byte 0 0, //[15] byte 0 0, //[16] byte 0 0, //[17] long 6 0 MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte)(HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(Username); metadata[3] = new MetadataByte(1); metadata[4] = new MetadataByte(0); metadata[7] = new MetadataInt(0); metadata[8] = new MetadataByte(0); metadata[15] = new MetadataByte(0); metadata[16] = new MetadataByte(0); metadata[17] = new MetadataLong(0); return(metadata); }
public void MetadataString() { var obj = new MetadataString(); Assert.AreEqual(obj.ContainerField, "metadata"); Assert.AreEqual(obj.Name, null); Assert.AreEqual(obj.Reference, null); }
public void MetadataString_AssignEvilString_IsEscapedAndUnescapesCorrectly() { var metadataString = new MetadataString(); metadataString.Text = EvilString; Assert.True(metadataString.Escaped); Assert.Equal(EvilString, metadataString.Text); }
public void MetadataString_SetToNullOrEmpty_DoesNotThrow(string nullOrEmpty) { var metadataString = new MetadataString(); metadataString.Text = nullOrEmpty; Assert.True(string.IsNullOrEmpty(metadataString.Text)); Assert.False(metadataString.Escaped); }
public override MetadataDictionary GetMetadata() { var metadata = base.GetMetadata(); metadata[40] = new MetadataString(DialogText); metadata[41] = new MetadataString($"npc_{(int) NpcSkinType}"); metadata[42] = new MetadataString(AdvancedConfig); return(metadata); }
protected void Button1_Click(object sender, EventArgs e) { HttpPostedFile postfile = (HttpPostedFile)Session["postfile"]; int i = Convert.ToInt32(Session["selectedvault"]); var uploadService = client.CreateChannel <IUploadService>(); string id; using (var fs = postfile.InputStream) { id = uploadService.UploadFileContent(fs, null); } var mcs = client.CreateChannel <IMediaContentService>(); var mediaItem = mcs.StoreContentInVault(id, postfile.FileName, "image/png", i); var mediaid = mediaItem.Id; var mi = client.Query <MediaItem>() .Where(u => u.Id == mediaid) .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .FirstOrDefault(); mi.Metadata.Clear(); foreach (Control item in PlaceHolder1.Controls) { switch (item.GetType().Name) { case "TextBox": var m = new MetadataString(); m.MetadataDefinitionId = Convert.ToInt32(item.ID); Control mytextbox = (TextBox)PlaceHolder1.FindControl(item.ID); m.StringValue = (mytextbox as TextBox).Text; //m.StringValue = Request.Form[item.ID]; mi.Metadata.Add(m); break; } } var ms = client.CreateChannel <IMediaService>(); ms.Save(new List <MediaItem> { mi }, MediaServiceSaveOptions.Metadata); ms.Save(new List <MediaItem> { mediaItem }, MediaServiceSaveOptions.MarkAsOrganized); Console.WriteLine("Media item marked as organized"); Session.RemoveAll(); }
public override MetadataDictionary GetMetadata() { //TODO: These are wrong. Have new values now for all of it var metadata = base.GetMetadata(); metadata[0x27] = new MetadataString(DialogText); metadata[0x28] = new MetadataString($"npc_{(int) NpcSkinType}"); metadata[0x29] = new MetadataString(AdvancedConfig); return(metadata); }
public void MetadataString_ShouldNotNeedEscaping_IsNotEscaped(string stringThatDoesNotNeedToBeEscaped) { var metadataString = new MetadataString(); metadataString.Text = stringThatDoesNotNeedToBeEscaped; Assert.False(metadataString.Escaped); Assert.Equal(stringThatDoesNotNeedToBeEscaped, metadataString.XmlText); Assert.Equal(stringThatDoesNotNeedToBeEscaped, metadataString.Text); }
public int NumberOfVisibleFields(bool considerAlwaysShow = true) { int size = 0; MetaMetadataOneLevelNestingEnumerator fullEnumerator = FullNonRecursiveMetaMetadataIterator(); // iterate over all fields in this & then in each mixin of this while (fullEnumerator.MoveNext()) { MetaMetadataField metaMetadataField = fullEnumerator.Current; MetaMetadataField metaMetadata = fullEnumerator.CurrentObject(); // stays the same for until we // iterate over all mfd's for // it Metadata currentMetadata = fullEnumerator.CurrentMetadata; // When the iterator enters the metadata in the mixins "this" in getValueString has to be // the corresponding metadata in mixin. bool hasVisibleNonNullField = false; MetadataFieldDescriptor mfd = metaMetadataField.MetadataFieldDescriptor; if (metaMetadata.IsChildFieldDisplayed(metaMetadataField.Name)) { if (mfd.IsScalar && !mfd.IsCollection) { hasVisibleNonNullField = MetadataString.IsNotNullAndEmptyValue(mfd.GetValueString(currentMetadata)); } else if (mfd.IsComposite) { Metadata nestedMetadata = (Metadata)mfd.GetNestedMetadata(currentMetadata); hasVisibleNonNullField = (nestedMetadata != null) ? (nestedMetadata.NumberOfVisibleFields() > 0) : false; } else if (mfd.IsCollection) { ICollection collection = mfd.GetCollection(currentMetadata); hasVisibleNonNullField = (collection != null) ? (collection.Count > 0) : false; } } // "null" happens with mixins fieldAccessor b'coz getValueString() returns "null". // TODO use MetaMetadataField.numNonDisplayedFields() bool isVisibleField = !metaMetadataField.Hide && ((considerAlwaysShow && metaMetadataField.AlwaysShow) || hasVisibleNonNullField); if (isVisibleField) { size++; } } return(size); }
public virtual MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte) (HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(NameTag ?? string.Empty); metadata[3] = new MetadataByte(1); metadata[4] = new MetadataByte(0); metadata[15] = new MetadataByte(0); //metadata[16] = new MetadataByte(0); return metadata; }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataLong(8592556032); // 1000000000001010000000000000000000; CanClimb, CanFly, Breathing metadata[1] = new MetadataInt(1); metadata[2] = new MetadataInt(0); metadata[3] = new MetadataByte(0); metadata[4] = new MetadataString(""); metadata[5] = new MetadataLong(-1); metadata[7] = new MetadataShort(300); metadata[8] = new MetadataInt(0); metadata[9] = new MetadataByte(0); metadata[10] = new MetadataByte(0); metadata[22] = new MetadataByte(0); metadata[38] = new MetadataLong(0); metadata[39] = new MetadataFloat(1f); metadata[43] = new MetadataShort(300); metadata[44] = new MetadataInt(0); metadata[45] = new MetadataByte(0); metadata[46] = new MetadataInt(0); metadata[47] = new MetadataInt(0); metadata[49] = new MetadataInt(AnimationStep); metadata[50] = new MetadataLong(-1); metadata[51] = new MetadataLong(-1); metadata[52] = new MetadataLong(-1); metadata[53] = new MetadataShort((short)(ShowAuora ? 0 : 1)); metadata[54] = new MetadataFloat(1f); metadata[55] = new MetadataFloat(3f); metadata[58] = new MetadataByte(0); metadata[59] = new MetadataFloat(0f); metadata[60] = new MetadataFloat(0f); metadata[70] = new MetadataByte(0); metadata[71] = new MetadataString(""); metadata[72] = new MetadataString(""); metadata[73] = new MetadataByte(1); metadata[74] = new MetadataByte(0); metadata[75] = new MetadataInt(0); metadata[76] = new MetadataInt(0); metadata[77] = new MetadataInt(0); metadata[78] = new MetadataInt(-1); //metadata[49] = new MetadataInt(0); //metadata[53] = new MetadataShort(0); return(metadata); }
protected void Button1_Click(object sender, EventArgs e) { HttpPostedFile postfile = (HttpPostedFile)Session["postfile"]; int i = Convert.ToInt32(Session["selectedvault"]); var uploadService = client.CreateChannel<IUploadService>(); string id; using (var fs = postfile.InputStream) { id = uploadService.UploadFileContent(fs, null); } var mcs = client.CreateChannel<IMediaContentService>(); var mediaItem = mcs.StoreContentInVault(id, postfile.FileName, "image/png", i); var mediaid = mediaItem.Id; var mi = client.Query<MediaItem>() .Where(u => u.Id == mediaid) .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .FirstOrDefault(); mi.Metadata.Clear(); foreach (Control item in PlaceHolder1.Controls) { switch (item.GetType().Name) { case "TextBox": var m = new MetadataString(); m.MetadataDefinitionId = Convert.ToInt32(item.ID); Control mytextbox = (TextBox)PlaceHolder1.FindControl(item.ID); m.StringValue = (mytextbox as TextBox).Text; //m.StringValue = Request.Form[item.ID]; mi.Metadata.Add(m); break; } } var ms = client.CreateChannel<IMediaService>(); ms.Save(new List<MediaItem> { mi }, MediaServiceSaveOptions.Metadata); ms.Save(new List<MediaItem> { mediaItem }, MediaServiceSaveOptions.MarkAsOrganized); Console.WriteLine("Media item marked as organized"); Session.RemoveAll(); }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte)(HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(NameTag ?? Name); metadata[3] = new MetadataByte(!HideNameTag); metadata[4] = new MetadataByte(Silent); metadata[7] = new MetadataInt(0); // Potion Color metadata[8] = new MetadataByte(0); // Potion Ambient metadata[15] = new MetadataByte(NoAi); metadata[16] = new MetadataByte(0); // Player flags metadata[17] = new MetadataLong(0); return(metadata); }
public virtual MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte(GetDataValue()); metadata[2] = new MetadataString(NameTag ?? string.Empty); metadata[3] = new MetadataByte(!HideNameTag); metadata[4] = new MetadataByte(Silent); metadata[7] = new MetadataInt(0); // Potion Color metadata[8] = new MetadataByte(0); // Potion Ambient metadata[15] = new MetadataByte(NoAi); metadata[16] = new MetadataByte(0); // Player flags //metadata[17] = new MetadataIntCoordinates(0, 0, 0); metadata[23] = new MetadataLong(-1); // Leads EID (target or holder?) metadata[24] = new MetadataByte(0); // Leads on/off return(metadata); }
public override MetadataDictionary GetMetadata() { Log.Warn("Metadata"); MetadataDictionary metadata = new MetadataDictionary(); //metadata[38] = new MetadataLong(0); //metadata[39] = new MetadataFloat(1f); //metadata[44] = new MetadataShort(300); //MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataLong(8388608); // 100000000000000000000000; Sitting metadata[1] = new MetadataInt(1); metadata[2] = new MetadataInt(0); metadata[3] = new MetadataByte(0); metadata[4] = new MetadataString(""); metadata[5] = new MetadataLong(-1); metadata[7] = new MetadataShort(300); metadata[8] = new MetadataInt(0); metadata[9] = new MetadataByte(0); metadata[10] = new MetadataByte(0); metadata[22] = new MetadataByte(0); metadata[38] = new MetadataLong(0); metadata[39] = new MetadataFloat(1f); metadata[43] = new MetadataShort(300); metadata[44] = new MetadataInt(0); metadata[45] = new MetadataByte(0); metadata[46] = new MetadataInt(0); metadata[47] = new MetadataInt(0); metadata[54] = new MetadataFloat(13f); metadata[55] = new MetadataFloat(4f); metadata[58] = new MetadataByte(0); metadata[59] = new MetadataFloat(0f); metadata[60] = new MetadataFloat(0f); metadata[70] = new MetadataByte(0); metadata[71] = new MetadataString(""); metadata[72] = new MetadataString(""); metadata[73] = new MetadataByte(1); metadata[74] = new MetadataByte(0); metadata[75] = new MetadataInt(0); metadata[76] = new MetadataInt(0); metadata[77] = new MetadataInt(0); metadata[78] = new MetadataInt(-1); return(metadata); }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte)(HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(NameTag ?? Name); metadata[3] = new MetadataByte(!HideNameTag); metadata[4] = new MetadataByte(Silent); metadata[7] = new MetadataInt(0); // Potion Color metadata[8] = new MetadataByte(0); // Potion Ambient metadata[15] = new MetadataByte(NoAi); metadata[16] = new MetadataByte(0); // Player flags //metadata[17] = new MetadataIntCoordinates(0, 0, 0); metadata[23] = new MetadataInt(-1); // Leads EID (target or holder?) metadata[24] = new MetadataByte(0); // Leads on/off return(metadata); }
/// <summary> /// Initializes a new instance of ProgramDescription. /// </summary> /// <param name="crc">The CRC of the program.</param> /// <param name="rom">The ROM file or files.</param> /// <param name="programInfo">Additional information about the program.</param> public ProgramDescription(uint crc, IRom rom, IProgramInformation programInfo) { _crc = crc; _rom = rom; _programInfo = new UserSpecifiedProgramInformation(programInfo); _xmlVendor = new MetadataString() { Text = _programInfo.Vendor }; _name = _programInfo.GetNameForCrc(crc); _xmlName = new MetadataString() { Text = _name }; _shortName = programInfo.ShortName; _xmlShortName = new MetadataString() { Text = _shortName }; _programFiles = new ProgramSupportFiles(rom); var allIncompatibilities = _programInfo.Crcs.Select(c => c.Incompatibilities); var crcData = _programInfo.Crcs.First(c => c.Crc == crc); var romSpecificIncompatibilities = crcData.Incompatibilities; if ((romSpecificIncompatibilities != IncompatibilityFlags.None) || (allIncompatibilities.Distinct().Count() > 1)) { var incompatibilities = _programInfo.Features.ToIncompatibilityFlags(); if (romSpecificIncompatibilities != incompatibilities) { _features = romSpecificIncompatibilities.ApplyFlagsToProgramFeatures(_programInfo.Features.Clone()); } else { _features = programInfo.Features; } } else { _features = programInfo.Features; } }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataLong(4398046511104); // 1000000000000000000000000000000000000000000; metadata[1] = new MetadataInt(1); metadata[2] = new MetadataInt(0); metadata[3] = new MetadataByte(0); metadata[4] = new MetadataString(""); metadata[5] = new MetadataLong(-1); metadata[7] = new MetadataShort(300); metadata[8] = new MetadataInt(0); metadata[9] = new MetadataByte(0); metadata[10] = new MetadataByte(0); metadata[22] = new MetadataByte(0); metadata[38] = new MetadataLong(0); metadata[39] = new MetadataFloat(1f); metadata[43] = new MetadataShort(300); metadata[44] = new MetadataInt(0); metadata[45] = new MetadataByte(0); metadata[46] = new MetadataInt(0); metadata[47] = new MetadataInt(0); metadata[54] = new MetadataFloat(0.4f); metadata[55] = new MetadataFloat(0.8f); metadata[58] = new MetadataByte(0); metadata[59] = new MetadataFloat(0f); metadata[60] = new MetadataFloat(0f); metadata[70] = new MetadataByte(0); metadata[71] = new MetadataString(""); metadata[72] = new MetadataString(""); metadata[73] = new MetadataByte(1); metadata[74] = new MetadataByte(0); metadata[75] = new MetadataInt(0); metadata[76] = new MetadataInt(0); metadata[77] = new MetadataInt(0); metadata[78] = new MetadataInt(-1); return(metadata); }
public Document GetOrCreateDocument(DocumentParser documentParser /*, LinkType linkType*/) { Document result = (Document)GetArgumentObject(SemanticOperationNamedArguments.Document); // get the ancestor container Document sourceDocument = ResolveSourceDocument(); // get the seed. Non null only for search types . //Seed seed = documentParser.getSeed(); if (result == null) { Object outlinkPurlObject = GetArgumentObject(SemanticOperationNamedArguments.Location); if (outlinkPurlObject != null) { ParsedUri outlinkPurl = ((MetadataParsedURL)outlinkPurlObject).Value; //result = sessionScope.GetOrConstructDocument(outlinkPurl); } } if (result == null) { result = sourceDocument; //direct binding?! } if (result != null /*&& !result.IsRecycled()*/ && (result.Location != null)) { result.SemanticsSessionScope = (SemanticsSessionScope)sessionScope; MetadataNS.Metadata mixin = (MetadataNS.Metadata)GetArgumentObject(SemanticOperationNamedArguments.Mixin); if (mixin != null) { result.AddMixin(mixin); } /* if (seed != null) * { * seed.bindToDocument(result); * } */ MetadataString anchorText = (MetadataString)GetArgumentObject(SemanticOperationNamedArguments.AnchorText); // create anchor text from Document title if there is none passed in directly, and we won't // be setting metadata // if (anchorText == null) // anchorText = result.Title; // work to avoid honey pots! MetadataString anchorContextString = (MetadataString)GetArgumentObject(SemanticOperationNamedArguments.AnchorContext); bool citationSignificance = GetArgumentBoolean(SemanticOperationNamedArguments.CitationSignificance, false); float significanceVal = GetArgumentFloat(SemanticOperationNamedArguments.SignificanceValue, 1); bool traversable = GetArgumentBoolean(SemanticOperationNamedArguments.Traversable, true); bool ignoreContextForTv = GetArgumentBoolean(SemanticOperationNamedArguments.IgnoreContextForTv, false); ParsedUri location = result.Location.Value; /* if (traversable) * { * Seeding seeding = sessionScope.getSeeding(); * if (seeding != null) * seeding.traversable(location); * } * bool anchorIsInSource = false; * if (sourceDocument != null) * { * // Chain the significance from the ancestor * SemanticInLinks sourceInLinks = sourceDocument.getSemanticInlinks(); * if (sourceInLinks != null) * { * significanceVal *= sourceInLinks.meanSignificance(); * anchorIsInSource = sourceInLinks.containsKey(location); * } * } * if(! anchorIsInSource) * { * //By default use the boost, unless explicitly stated in this site's MMD * SemanticsSite site = result.GetSite; * boolean useSemanticBoost = !site.ignoreSemanticBoost(); * if (citationSignificance) * linkType = LinkType.CITATION_SEMANTIC_ACTION; * else if (useSemanticBoost && linkType == LinkType.OTHER_SEMANTIC_ACTION) * linkType = LinkType.SITE_BOOSTED_SEMANTIC_ACTION; * SemanticAnchor semanticAnchor = new SemanticAnchor(linkType, location, null, * sourceDocument.getLocation(), significanceVal);// this is not fromContentBody, * // but is fromSemanticActions * if(ignoreContextForTv) * semanticAnchor.addAnchorContextToTV(anchorText, null); * else * semanticAnchor.addAnchorContextToTV(anchorText, anchorContextString); * result.addSemanticInlink(semanticAnchor, sourceDocument); * } * else * { * Console.WriteLine("Ignoring inlink, because ancestor contains the same, we don't want cycles in the graph just yet: sourceContainer -- outlinkPurl :: " + sourceDocument + " -- " + location); * }*/ } // adding the return value to map Scope <Object> semanticActionVariableMap = SemanticOperationHandler.SemanticOperationVariableMap; if (semanticActionVariableMap != null) { if (GetReturnObjectName() != null) { semanticActionVariableMap.Put(GetReturnObjectName(), result); } } else { Debug.WriteLine("semanticActionVariableMap is null !! Not frequently reproducible either. Place a breakpoint here to try fixing it next time."); } // set flags if any // setFlagIfAny(action, localContainer); // return the value. Right now no need for it. Later it might be used. return(result); }
public static MetadataDictionary ReadMetadataDictionaryAlternate(this Packet packet) { MetadataDictionary metadata = new MetadataDictionary(); uint count = 0; int index; uint type; try { //var stream = (Stream)ReflectionHelper.GetPrivateFieldValue<MemoryStreamReader>(typeof(Packet), packet, "_reader"); count = packet.ReadUnsignedVarInt(); //VarInt.ReadInt32(stream); for (int i = 0; i < count; ++i) { index = (int)packet.ReadUnsignedVarInt(); //VarInt.ReadInt32(stream); type = packet.ReadUnsignedVarInt(); //VarInt.ReadInt32(stream); switch (type) { case 0: metadata[index] = new MetadataByte(packet.ReadByte()); break; case 1: metadata[index] = new MetadataShort(packet.ReadShort()); break; case 2: metadata[index] = new MetadataInt(packet.ReadVarInt()); break; case 3: metadata[index] = new MetadataFloat(packet.ReadFloat()); break; case 4: metadata[index] = new MetadataString(packet.ReadString()); break; case 5: metadata[index] = new MetadataNbt(packet.ReadNbt()); break; case 6: metadata[index] = new MetadataIntCoordinates( packet.ReadVarInt(), packet.ReadVarInt(), packet.ReadVarInt()); break; case 7: metadata[index] = new MetadataLong(packet.ReadVarLong()); break; case 8: metadata[index] = new MetadataVector3(packet.ReadVector3()); break; default: Log.Warn($"Unknown metadata type: {type} at index {index}"); break; } } return(metadata); } catch (Exception ex) { Log.Warn(ex, $"Incomplete metadata: {ex.ToString()}"); return(metadata); } }
public TestClassForXmlSerialization() { XmlString = new MetadataString(); }
public void SaveMetadataTest() { var client = ClientFactory.GetSdkClient(); //Yuck! Metadata handling is ugly so far. //create or find the metadata definition that you want to store //here we create the one we need if it isn't found var template = new MetadataDefinition { MetadataDefinitionType = MetadataDefinitionTypes.User, Name = "Test", MetadataType = MetadataTypes.String }; var mds = client.CreateChannel <IMetadataDefinitionService>(); //first find all metadata definitions of the same def type and type as the one requested and that matches the name. var definition = mds.Find(new MetadataDefinitionQuery { Filter = { MetadataDefinitionType = template.MetadataDefinitionType, MetadataType = template.MetadataType } }).FirstOrDefault(d => d.Name == template.Name); if (definition == null) { //if no match was found, create the template instead var id = mds.Save(template); definition = template; definition.Id = id; } //create the metadata itself by setting the id of the definition and the value (important to create a metadata of //the same sort as the defined MetadataType. var m = new MetadataString { MetadataDefinitionId = definition.Id, StringValue = "test value" }; //get the media item to which we should attach the metadata to. (We inlcude all user metadata) var mi = client.Query <MediaItem>() .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .Take(1).FirstOrDefault(); //when we save the metadata we only want to modify the new one //when we clear the metadata, this will not clear the metadata stored in the db only for this copy mi.Metadata.Clear(); //add the new/modified metadata mi.Metadata.Add(m); var ms = client.CreateChannel <IMediaService>(); //supply the Metadata save option flag to indicate that medatata should be saved as well. //as stated above, we cannot delete any metadata. Any metadata passed to the save function will only //be added/modified for now. ms.Save(new List <MediaItem> { mi }, MediaServiceSaveOptions.Metadata); }
public void SaveMetadataTest() { var client = ClientFactory.GetSdkClient(); //Yuck! Metadata handling is ugly so far. //create or find the metadata definition that you want to store //here we create the one we need if it isn't found var template = new MetadataDefinition { MetadataDefinitionType = MetadataDefinitionTypes.User, Name = "Test", MetadataType = MetadataTypes.String }; var mds = client.CreateChannel<IMetadataDefinitionService>(); //first find all metadata definitions of the same def type and type as the one requested and that matches the name. var definition = mds.Find(new MetadataDefinitionQuery { Filter = { MetadataDefinitionType = template.MetadataDefinitionType, MetadataType = template.MetadataType } }).FirstOrDefault(d => d.Name == template.Name); if (definition == null) { //if no match was found, create the template instead var id = mds.Save(template); definition = template; definition.Id = id; } //create the metadata itself by setting the id of the definition and the value (important to create a metadata of //the same sort as the defined MetadataType. var m = new MetadataString { MetadataDefinitionId = definition.Id, StringValue = "test value" }; //get the media item to which we should attach the metadata to. (We inlcude all user metadata) var mi = client.Query<MediaItem>() .Include(x => x.Metadata.Where(md => md.DefinitionType == MetadataDefinitionTypes.User)) .Take(1).FirstOrDefault(); //when we save the metadata we only want to modify the new one //when we clear the metadata, this will not clear the metadata stored in the db only for this copy mi.Metadata.Clear(); //add the new/modified metadata mi.Metadata.Add(m); var ms = client.CreateChannel<IMediaService>(); //supply the Metadata save option flag to indicate that medatata should be saved as well. //as stated above, we cannot delete any metadata. Any metadata passed to the save function will only //be added/modified for now. ms.Save(new List<MediaItem> { mi }, MediaServiceSaveOptions.Metadata); }