public static void InjectExpression(Dev2DecisionStack ds, ModelProperty activityExpression) { if(ds == null) return; string modelData = ds.ToVBPersistableModel(); string expressionToInject = String.Join("", GlobalConstants.InjectedDecisionHandler, "(\"", modelData, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")"); if(activityExpression != null) { activityExpression.SetValue(expressionToInject); } }
public static void InjectExpression(Dev2Switch ds, ModelProperty activityExpression) { if(ds == null) return; // FetchSwitchData string expressionToInject = String.Join("", GlobalConstants.InjectedSwitchDataFetch, "(\"", ds.SwitchVariable, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")"); if(activityExpression != null) { activityExpression.SetValue(expressionToInject); } }
// this updates forward links public static void MorphProperties(ModelItem oldModelItem, ModelItem newModelitem) { if (oldModelItem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("oldModelItem")); } if (newModelitem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("newModelitem")); } foreach (ModelProperty modelProperty in oldModelItem.Properties) { ModelProperty propertyInNewModelItem = newModelitem.Properties[modelProperty.Name]; if (propertyInNewModelItem != null) { Console.WriteLine(propertyInNewModelItem.Name); if (CanCopyProperty(modelProperty, propertyInNewModelItem)) { if (propertyInNewModelItem.PropertyType.Equals(modelProperty.PropertyType)) { propertyInNewModelItem.SetValue(modelProperty.Value); modelProperty.SetValue(null); } else // See if there is morph helper for this type. { PropertyValueMorphHelper extension = GetPropertyValueMorphHelper(modelProperty.PropertyType); if (extension != null) { propertyInNewModelItem.SetValue(extension(modelProperty.Value, propertyInNewModelItem)); modelProperty.SetValue(null); } } } } } }
internal static bool TrySetPropertyValue(this ModelItem item, object value, out ModelItem wrappedValue, params string[] path) { if (null == item) { throw FxTrace.Exception.AsError(new ArgumentNullException("item")); } if (null == path) { throw FxTrace.Exception.AsError(new ArgumentNullException("path")); } if (path.Length < 1) { throw FxTrace.Exception.AsError(new ArgumentException(SR.ModelItemPathArrayShouldNotBeEmpty)); } wrappedValue = null; bool result = true; for (int i = 0; i < path.Length && true == result; ++i) { ModelProperty property = item.Properties[path[i]]; if (null != property) { if (i == path.Length - 1) { if (null != value) { wrappedValue = property.SetValue(value); } else { property.ClearValue(); } } else { item = property.Value; if (null == item) { result = false; } } } else { throw FxTrace.Exception.AsError(new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.PropertyDoesntExistFormatString, path[i]))); } } return(result); }
public object SetPropertyValue(string propertyName, object val) { ModelProperty modelProperty = this.Properties.Find(propertyName); if (modelProperty != null) { modelProperty.SetValue(val); } else { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this)[propertyName]; if (descriptor != null) { descriptor.SetValue(this, val); } } return(GetPropertyValue(propertyName)); }