Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - ParameterBinding

 
 
Old 11-06-2006   #1 (permalink)
chirag


 
 

ParameterBinding

ublic override void SetValue(object component, object value)
{
if (component != null)
{
ISite site = GetSite(component);
IComponentChangeService changeService = null;
if (site != null)
changeService =
(IComponentChangeService)site.GetService(typeof(IComponentChangeService));
// Raise the OnComponentChanging event
changeService.OnComponentChanging(component, this);

// Save the old value
object oldValue = GetValue(component);

try
{
WorkflowParameterBindingCollection parameters =
GetParametersPropertyValue(component);
if (parameters != null)
{
if (value == null)
// Remove the binding from the
ParameterBindings collection
parameters.Remove(this.Name);
else
{
// Add the binding to the ParameterBindings
collection
WorkflowParameterBinding binding = null;
if (parameters.Contains(this.Name))
binding = parameters[this.Name];
else
{
binding = new
WorkflowParameterBinding(this.Name);
parameters.Add(binding);
}

// Set the binding value on the
ParameterBindings collection correspondent binding item
if (value is ActivityBind)

binding.SetBinding(WorkflowParameterBinding.ValueProperty, value as
ActivityBind);
else

binding.SetValue(WorkflowParameterBinding.ValueProperty, value);
}
}
// Raise the OnValueChanged event
OnValueChanged(component, EventArgs.Empty);
}
catch (Exception)
{
value = oldValue;
throw;
}
finally
{
if (changeService != null)
// Raise the OnComponentChanged event
changeService.OnComponentChanged(component,
this, oldValue, value);
}
}
}

/// <summary>
/// Returns a component binding value from the
ParameterBindings collection.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
public override object GetValue(object component)
{
WorkflowParameterBindingCollection parameters =
GetParametersPropertyValue(component);
if (parameters != null && parameters.Contains(this.Name))
{
if
(parameters[this.Name].IsBindingSet(WorkflowParameterBinding.ValueProperty))
return
parameters[this.Name].GetBinding(WorkflowParameterBinding.ValueProperty);
else
return
parameters[this.Name].GetValue(WorkflowParameterBinding.ValueProperty);
}
return null;
}

/// <summary>
/// Returns the ParameterBindings collection of the
activity component.
/// </summary>
/// <param name="component"></param>
/// <returns></returns>
private static WorkflowParameterBindingCollection
GetParametersPropertyValue(object component)
{
WorkflowParameterBindingCollection
parameterBindingCollection = null;

MemberInfo memberInfo =
component.GetType().GetProperty("ParameterBindings",
BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance
| BindingFlags.FlattenHierarchy | BindingFlags.ExactBinding, null,
typeof(WorkflowParameterBindingCollection), new Type[] { }, new
ParameterModifier[] { });
if (memberInfo != null)
parameterBindingCollection =
component.GetType().InvokeMember("ParameterBindings",
BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance
| BindingFlags.FlattenHierarchy | BindingFlags.ExactBinding, null,
component, new object[] { }, CultureInfo.InvariantCulture) as
WorkflowParameterBindingCollection;
return parameterBindingCollection;
}
}
I have written the above code and still I am not able to bind the
parameters please solve my problem
thanks


My System SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46