public XmlCloudEventV10(ICloudEventV10 ce)
        {
            AllElements = new List <XmlElement>();
            foreach (var propertyInfo in ce.GetType().GetProperties())
            {
                bool dontCopy = false;
                foreach (var customAttribute in propertyInfo.CustomAttributes)
                {
                    if (customAttribute.AttributeType == typeof(DontCopyAttribute))
                    {
                        dontCopy = true;
                        break;
                    }
                }

                if (dontCopy)
                {
                    continue;
                }

                var p = this.GetType().GetProperty(propertyInfo.Name);
                if (p != null)
                {
                    p.SetValue(this, propertyInfo.GetValue(ce));
                }
                else
                {
                    var element = XmlFactory.CreateElement(propertyInfo.Name);
                    element.InnerText = propertyInfo.GetValue(ce).ToString();
                    AllElements.Add(element);
                }
            }
            ((CloudEventsExtensions)this).CopyFrom(ce as CloudEventsExtensions);
        }
 public JsonCloudEventV10(ICloudEventV10 ce)
 {
     foreach (var propertyInfo in ce.GetType().GetProperties())
     {
         this.GetType().GetProperty(propertyInfo.Name).SetValue(this, propertyInfo.GetValue(ce));
     }
     ((CloudEventsExtensions)this).CopyFrom(ce as CloudEventsExtensions);
 }
        public ThriftCloudEventV11(ICloudEventV10 ce)
        {
            extensions = new Dictionary <string, string>();
            foreach (var propertyInfo in ce.GetType().GetProperties())
            {
                bool dontCopy = false;
                foreach (var customAttribute in propertyInfo.CustomAttributes)
                {
                    if (customAttribute.AttributeType == typeof(DontCopyAttribute))
                    {
                        dontCopy = true;
                        break;
                    }
                }

                if (dontCopy)
                {
                    continue;
                }

                var p = this.GetType().GetProperty(propertyInfo.Name);
                if (p != null)
                {
                    if (p.PropertyType == typeof(string))
                    {
                        p.SetValue(this, propertyInfo.GetValue(ce) ?? string.Empty);
                    }
                    else
                    {
                        p.SetValue(this, propertyInfo.GetValue(ce));
                    }
                }
                else
                {
                    extensions.Add(propertyInfo.Name, propertyInfo.GetValue(ce).ToString());
                }
            }
            ((CloudEventsExtensions)this).CopyFrom(ce as CloudEventsExtensions);
        }