public void SerializeTemplate(BinaryWriter writer)
 {
     writer.Write(serializableFields.Count);
     writer.Write(serializableProperties.Count);
     foreach (SerializationField serializableField in serializableFields)
     {
         SerializationField current = serializableField;
         writer.WriteKleiString(current.field.Name);
         Type fieldType = current.field.FieldType;
         WriteType(writer, fieldType);
     }
     foreach (SerializationProperty serializableProperty in serializableProperties)
     {
         SerializationProperty current2 = serializableProperty;
         writer.WriteKleiString(current2.property.Name);
         Type propertyType = current2.property.PropertyType;
         WriteType(writer, propertyType);
     }
 }
 public void SerializeData(object obj, BinaryWriter writer)
 {
     if (onSerializing != null)
     {
         onSerializing.Invoke(obj, null);
     }
     foreach (SerializationField serializableField in serializableFields)
     {
         SerializationField current = serializableField;
         try
         {
             object value = current.field.GetValue(obj);
             writer.WriteValue(current.typeInfo, value);
         }
         catch (Exception innerException)
         {
             string text = $"Error occurred while serializing field {current.field.Name} on template {serializableType.Name}";
             Debug.LogError(text);
             throw new ArgumentException(text, innerException);
         }
     }
     foreach (SerializationProperty serializableProperty in serializableProperties)
     {
         SerializationProperty current2 = serializableProperty;
         try
         {
             object value2 = current2.property.GetValue(obj, null);
             writer.WriteValue(current2.typeInfo, value2);
         }
         catch (Exception innerException2)
         {
             string text2 = $"Error occurred while serializing property {current2.property.Name} on template {serializableType.Name}";
             Debug.LogError(text2);
             throw new ArgumentException(text2, innerException2);
         }
     }
     if (onSerialized != null)
     {
         onSerialized.Invoke(obj, null);
     }
 }
Esempio n. 3
0
        private void a(OrganizationMaintenanceJobData A_0)
        {
            int lastResultCode = -1;

            try

            {
                this.a("#start: property bag contents:");
                SerializationProperty[] serializationProperties = A_0.InternalPropertyBag.SerializationProperties;

                for (int i = 0; i < (int)serializationProperties.Length; i++)
                {
                    SerializationProperty serializationProperty = serializationProperties[i];

                    this.a(string.Format("Name: {0} - Value: {1}", serializationProperty.Name, serializationProperty.Value));
                }

                this.a("#end: property bag contents:");
                this.a("Trying last result now.");
                lastResultCode = A_0.LastResultCode;
                this.a(string.Concat("last result: ", lastResultCode));
            }

            catch (NullReferenceException)
            {
                this.a("caught system.NullReferenceException");
            }

            catch (MissingMethodException)
            {
                this.a("caught system.MissingMethodException");
            }

            catch (Exception exception1)
            {
                Exception exception = exception1;
                this.a(string.Concat(new object[] { "caught unhandled exception: ", exception.Message, "\r\n", exception.StackTrace, "\r\n", exception.Source, "\r\n", exception.InnerException }));
            }

            if (lastResultCode == 0)
            {
                this.label2.Image = null;
                return;
            }
            int   num   = 13;
            Label label = this.label2;

            label.Text = string.Concat(label.Text, "      ");
            Image obj    = (Image)this.rscMgrTypeResources.GetObject("imgJobError");
            Image bitmap = new Bitmap(num, num);

            Graphics.FromImage(bitmap).DrawImage(obj, 0, 0, num, num);
            this.label2.Image      = bitmap;
            this.label2.ImageAlign = ContentAlignment.MiddleRight;
            if (lastResultCode == -1)
            {
                this.toolTip.SetToolTip(this.label2, string.Format("Last result code for job was not available: {0}", lastResultCode));
                return;
            }
            this.toolTip.SetToolTip(this.label2, string.Format("Last job run failed with resultcode: {0}", lastResultCode));
        }