public static FrameContent Convert(FrameContent fc, Type dst) { Func <FrameContent, FrameContent> converter = (from item in conversions where item.SrcType == fc.GetType() && item.DstType == dst select item.Converter).FirstOrDefault(); if (Object.ReferenceEquals(converter, null)) { throw new Exception("Conversion failed"); } else { FrameContent result = converter(fc); if (result.GetType() != dst) { throw new Exception("Conversion failed. Requested type: " + dst.Name + " Converted type: " + result.GetType().Name); } return(result); } }
public FrameContent CreateContent(FrameDescription.FrameType _type) { FrameContent content = null; if (contentClasses.ContainsKey(_type)) { content = (FrameContent)Activator.CreateInstance(contentClasses[_type], new object[] { this }); } else { content = new FrameContentBinary(this); } content.DescriptionMap = this; return(content); }
public FrameContent(FrameContent other) : this(other.DescriptionMap) { Codec = other.Codec.Clone(); }