コード例 #1
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn (context);
        if (string.IsNullOrEmpty (theName)) {
            throw new UTFailBuildException ("The name of the property must not be empty.",this);
        }

        object theRealValue = propertyValue.Value;
        if (propertyValue.UseExpression) {
            theRealValue = context.Evaluate (propertyValue.Expression);
        }

        var doSetOnlyIfUnset = onlyIfUnset.EvaluateIn(context);

        if (!doSetOnlyIfUnset || !context.ContainsProperty(theName)) {
            if (UTPreferences.DebugMode) {
                Type valueType = theRealValue != null ? theRealValue.GetType() : null;
                Debug.Log ("Setting property '" + theName + "' to " +
                    (valueType != null ? "[" + valueType.Name + "] " : "") + theRealValue, this);
            }
            context [theName] = theRealValue;
        }
        else {
            if (doSetOnlyIfUnset) {
                if (UTPreferences.DebugMode) {
                    Debug.Log("Not setting property '" + theName + "' because it is already set.");
                }
            }
        }
        yield return "";
    }
コード例 #2
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theName))
        {
            throw new UTFailBuildException("The name of the property must not be empty.", this);
        }

        object theRealValue = propertyValue.Value;

        if (propertyValue.UseExpression)
        {
            theRealValue = context.Evaluate(propertyValue.Expression);
        }

        var doSetOnlyIfUnset = onlyIfUnset.EvaluateIn(context);

        if (!doSetOnlyIfUnset || !context.ContainsProperty(theName))
        {
            if (UTPreferences.DebugMode)
            {
                Type valueType = theRealValue != null?theRealValue.GetType() : null;

                Debug.Log("Setting property '" + theName + "' to " +
                          (valueType != null ? "[" + valueType.Name + "] " : "") + theRealValue, this);
            }
            context [theName] = theRealValue;
        }
        else
        {
            if (doSetOnlyIfUnset)
            {
                if (UTPreferences.DebugMode)
                {
                    Debug.Log("Not setting property '" + theName + "' because it is already set.");
                }
            }
        }
        yield return("");
    }