/// <summary>
 /// Apply the specified contract.
 /// </summary>
 /// <returns>The apply.</returns>
 /// <param name="contract">Contract.</param>
 public void Apply(BaseContract contract)
 {
     // use reflection to iterate through all contract properties
     // and set to equivalent view model properties
     foreach (PropertyInfo prop in contract.GetType().GetRuntimeProperties())
     {
         var vmProperty            = GetType().GetRuntimeProperty(prop.Name);
         var contractPropertyValue = prop.GetValue(contract);
         vmProperty.SetValue(this, contractPropertyValue);
     }
 }
            public void SaveContract(BaseContract contract)
            {
                if (contract.Address == this.integration.contractRegistryAddress)
                {
                    throw new ArgumentOutOfRangeException(contract.Address + " is a magic address which cannot be used for contracts.");
                }

                if (contract is NonexistentContract)
                {
                    return;
                }

                var data     = StrongForceSerialization.SerializeStatefulObject(contract);
                var typeName = Encoding.ASCII.GetBytes(contract.GetType().Name);

                this.SaveData(contract.Address, data, typeName);
                this.integration.logger.LogTrace("Saved contract data: " + data.Length + " bytes for " + contract.Address);
            }