Beispiel #1
0
    public static void CopyAtt <T>(T destinationObject, TriggerObject sourceObject)
    {
        var flags      = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public;
        var properties = destinationObject.GetType().GetProperties(flags);

        foreach (PropertyInfo source in properties)
        {
            PropertyInfo propertyDestination = destinationObject.GetType().GetProperty(source.Name);
            // var val = source.GetValue(ob, null);


            var prop = sourceObject.GetType().GetProperty(source.Name);
            if (prop == null)
            {
                continue;
            }
            var val = prop.GetValue(sourceObject, null);

            if (val == null)
            {
                Debug.Log("value is null/property does not exist");
                continue;
            }
            propertyDestination.SetValue(destinationObject,
                                         val,
                                         null);
        }
    }
Beispiel #2
0
    /// <summary>
    /// Update Trigger Object data replacing existing one
    /// </summary>
    /// <param name="old"></param>
    /// <param name="noo"></param>
    void UpdateObject(TriggerObject old, TriggerObject noo)
    {
        foreach (PropertyInfo sourceProperty in noo.GetType().GetProperties())
        {
            PropertyInfo des = old.GetType().GetProperty(sourceProperty.Name);

            des.SetValue(
                old,
                sourceProperty.GetValue(noo, null),
                null);
        }
    }
Beispiel #3
0
    /// <summary>
    /// copy all available matching properties
    /// </summary>
    void EditTriggerObject()
    {
        foreach (PropertyInfo source in this.GetType().GetProperties())
        {
            PropertyInfo des = _tO.GetType().GetProperty(source.Name);
            var          val = source.GetValue(this, null);

            if (des == null)
            {
                continue;
            }
            des.SetValue(_tO,
                         val,
                         null);
            //   Debug.Log(des.Name);
        }
    }