Exemplo n.º 1
0
        public static ParameterKey <T[]> NewDynamic <T>(int arraySize, ParameterDynamicValue <T[]> dynamicValue, string name = null) where T : struct
        {
            if (name == null)
            {
                name = string.Empty;
            }

            var metadata = new ParameterKeyValueMetadata <T[]>(dynamicValue);
            var result   = new ParameterKey <T[]>(name, arraySize, metadata);

            return(result);
        }
Exemplo n.º 2
0
        public static ParameterKey <T> NewDynamic <T>(ParameterDynamicValue <T> dynamicValue, string name = null)
        {
            if (name == null)
            {
                name = string.Empty;
            }

            var metadata = new ParameterKeyValueMetadata <T>(dynamicValue);
            var result   = new ParameterKey <T>(name, 1, metadata);

            return(result);
        }
Exemplo n.º 3
0
        public override void Serialize(ref ParameterKey <T> obj, ArchiveMode mode, SerializationStream stream)
        {
            if (mode == ArchiveMode.Serialize)
            {
                stream.Write(obj.Name);
                stream.Write(obj.Length);
            }
            else
            {
                var parameterName   = stream.ReadString();
                var parameterLength = stream.ReadInt32();
                obj = (ParameterKey <T>)ParameterKeys.FindByName(parameterName);

                // If parameter could not be found, create one matching this type.
                if (obj == null)
                {
                    var metadata = new ParameterKeyValueMetadata <T>();
                    obj = new ParameterKey <T>(parameterName, parameterLength, metadata);
                    ParameterKeys.Merge(obj, null, parameterName);
                }
            }
        }