/// <summary> /// Gets a reference type from the OpaqueDataDictionary collection. /// </summary> /// <typeparam name="T">Type of the related opaque data.</typeparam> /// <param name="key">Key of the property being retrieved.</param> /// <returns>The related opaque data.</returns> protected T GetReferenceTypeProperty <T>(string key) where T : class { if (OpaqueData.TryGetValue(key, out object value)) { return((T)value); } return(default);
/** * Generate the DHCPv6 Server's DUID-LLT. See sections 9 and 22.3 of RFC 3315. * * @return the opaque opaqueData */ public static OpaqueData generateDUID_LLT() { OpaqueData opaque = null; try { Enumeration <NetworkInterface> intfs = NetworkInterface.getNetworkInterfaces(); if (intfs != null) { while (intfs.hasMoreElements()) { NetworkInterface intf = intfs.nextElement(); if (intf.isUp() && !intf.isLoopback() && !intf.isPointToPoint() && !intf.isVirtual()) { opaque = OpaqueData.Factory.newInstance(); ByteBuffer bb = ByteBuffer.allocate(intf.getHardwareAddress().length + 8); bb.putShort((short)1); // DUID based on LLT bb.putShort((short)1); // assume ethernet bb.putInt((int)(System.currentTimeMillis() / 1000)); // seconds since the Epoch bb.put(intf.getHardwareAddress()); opaque.setHexValue(bb.array()); break; } } } } catch (Exception ex) { log.error("Failed to generate DUID-LLT: " + ex); } return(opaque); }
/// <summary> /// Gets a value type from the OpaqueDataDictionary collection. /// </summary> /// <typeparam name="T">Type of the value being retrieved.</typeparam> /// <param name="key">Key of the value type being retrieved.</param> /// <returns>Index of the value type beng retrieved.</returns> protected Nullable <T> GetValueTypeProperty <T>(string key) where T : struct { object value; if (OpaqueData.TryGetValue(key, out value)) { return((T)value); } return(null); }
/// <summary> /// Sets a value in the contained OpaqueDataDictionary object. /// If null is passed, the value is removed. /// </summary> /// <typeparam name="T">Type of the element being set.</typeparam> /// <param name="key">Name of the key being modified.</param> /// <param name="value">Value being set.</param> protected void SetProperty <T>(string key, T value) { if (value != null) { OpaqueData[key] = value; } else { OpaqueData.Remove(key); } }
public DynamicVertexBufferContent(VertexBufferContent source, int size = 0) : base(size) { Identity = source.Identity; Name = source.Name; foreach (var keyPair in source.OpaqueData) { OpaqueData.Add(keyPair.Key, keyPair.Value); } VertexDeclaration = source.VertexDeclaration; CopyStream(source); }
/** * The main method. * * @param args the arguments */ public static void main(String[] args) { /* * OpaqueData o1 = OpaqueData.Factory.newInstance(); * OpaqueData o2 = OpaqueData.Factory.newInstance(); * o1.setHexValue(new byte[] { (byte)0xde, (byte)0xbb, (byte)0x1e }); * o2.setHexValue(new byte[] { (byte)0xde, (byte)0xbb, (byte)0x1e }); * System.out.println(equals(o1,o2)); */ OpaqueData opaque = generateDUID_LLT(); System.out.println(OpaqueDataUtil.toString(opaque)); }
/** * To string. * * @param opaque the opaque * * @return the string */ public static String toString(OpaqueData opaque) { if (opaque == null) { return(null); } String ascii = opaque.getAsciiValue(); if (ascii != null) { return(ascii); } else { return(Util.toHexString(opaque.getHexValue())); } }
/// <summary> /// Imports the asset. /// </summary> /// <param name="context">Contains any required custom process parameters.</param> public void Import(ContentProcessorContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrWhiteSpace(ModelDescription.FileName)) { throw new InvalidContentException("The attribute 'File' is not set in the model description (.drmdl file).", Identity); } var fileName = ContentHelper.FindFile(ModelDescription.FileName, Identity); var asset = new ExternalReference <NodeContent>(fileName); var node = context.BuildAndLoadAsset <NodeContent, NodeContent>(asset, null, null, ModelDescription.Importer); // BuildAndLoadAsset does not return root node in MonoGame. while (node.Parent != null) { node = node.Parent; } if (node.GetType() == typeof(NodeContent)) { // Root node is of type NodeContent. // --> Copy root node content and children. Name = node.Name; Transform = node.Transform; Animations.AddRange(node.Animations); OpaqueData.AddRange(node.OpaqueData); var children = node.Children.ToArray(); node.Children.Clear(); // Clear parents. Children.AddRange(children); } else { // Root node is a derived type. // --> Add node as child. Children.Add(node); } }