static StateMachineWorkflowActivity ()
		{
			InitialStateNameProperty = DependencyProperty.Register ("InitialStateName",
				typeof (string), typeof (StateMachineWorkflowActivity));

      			CompletedStateNameProperty = DependencyProperty.Register ("CompletedStateName",
      				typeof (string), typeof (StateMachineWorkflowActivity));
		}
 public PropertyValidationContext(object propertyOwner, DependencyProperty dependencyProperty)
 {
     this.propertyName = string.Empty;
     if (propertyOwner == null)
     {
         throw new ArgumentNullException("propertyOwner");
     }
     this.propertyOwner = propertyOwner;
     this.propertyInfo = dependencyProperty;
 }
        internal static void RegisterAsKnown(DependencyProperty dependencyProperty, byte byteVal, PropertyValidity propertyValidity)
        {
            if (dependencyProperty == null)
                throw new ArgumentNullException("dependencyProperty");
            if (knownProperties[byteVal] != null)
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_AlreadyRegisteredAs, knownProperties[byteVal].dependencyProperty.ToString()));
            }

            dependencyProperty.KnownIndex = byteVal;
            knownProperties[byteVal] = new KnownDependencyProperty(dependencyProperty, propertyValidity);
        }
Пример #4
0
        public EventPropertyDescriptor(EventDescriptor eventDesc, IServiceProvider serviceProvider)
            : base(eventDesc)
        {
            _eventDescriptor = eventDesc;
            _serviceProvider = serviceProvider;

            FieldInfo eventFieldInfo = _eventDescriptor.ComponentType.GetField(_eventDescriptor.Name + "Event");
            if (eventFieldInfo != null)
            {
                _eventProperty = eventFieldInfo.GetValue(_eventDescriptor.ComponentType) as DependencyProperty;
            }
        }
		static CallExternalMethodActivity ()
		{
			CorrelationTokenProperty = DependencyProperty.Register ("CorrelationToken",
				typeof (CorrelationToken), typeof (CallExternalMethodActivity));

			InterfaceTypeProperty = DependencyProperty.Register ("InterfaceType",
				typeof (Type), typeof (CallExternalMethodActivity));

			MethodInvokingEvent = DependencyProperty.Register ("MethodInvoking",
				typeof (CorrelationToken), typeof (CallExternalMethodActivity));

			MethodNameProperty = DependencyProperty.Register ("MethodName",
				typeof (string), typeof (CallExternalMethodActivity));

			ParameterBindingsProperty = DependencyProperty.Register ("ParameterBindings",
				typeof (WorkflowParameterBindingCollection), typeof (CallExternalMethodActivity));
		}
Пример #6
0
		static Activity ()
		{
			NameProperty = DependencyProperty.Register ("Name", typeof (string),
				typeof (Activity), new PropertyMetadata ());

			DescriptionProperty = DependencyProperty.Register ("Description", typeof (string),
				typeof (Activity), new PropertyMetadata ());

			EnabledProperty = DependencyProperty.Register ("Enabled", typeof (bool),
				typeof (Activity), new PropertyMetadata ());

			ExecutionResultProperty = DependencyProperty.Register ("ActivityExecutionResult", typeof (ActivityExecutionResult),
				typeof (Activity), new PropertyMetadata ());

			ExecutionStatusProperty = DependencyProperty.Register ("ActivityExecutionStatus", typeof (ActivityExecutionStatus),
				typeof (Activity), new PropertyMetadata ());

		#if !RUNTIME_DEP
			Console.WriteLine ("*** Warning: You are using a version of System.Workflow.ComponentModel");
			Console.WriteLine ("*** library built without System.Workflow.Runtime dependencies");
			Console.WriteLine ("*** You should use a version built with the Runtime dependencies");
		#endif
		}
 internal KnownDependencyProperty(DependencyProperty dependencyProperty, PropertyValidity propertyValidity)
 {
     this.dependencyProperty = dependencyProperty;
     this.propertyValidity = propertyValidity;
 }
        private static DependencyProperty ValidateAndRegister(string name, System.Type propertyType, System.Type ownerType, PropertyMetadata defaultMetadata, System.Type validatorType, bool isRegistered)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (name.Length == 0)
                throw new ArgumentException(SR.GetString(SR.Error_EmptyArgument), "name");

            if (propertyType == null)
                throw new ArgumentNullException("propertyType");

            if (ownerType == null)
                throw new ArgumentNullException("ownerType");

            FieldInfo fieldInfo = null;
            bool isEvent = (typeof(System.Delegate).IsAssignableFrom(propertyType) && (defaultMetadata == null || (defaultMetadata.Options & DependencyPropertyOptions.DelegateProperty) == 0));

            // WinOE Bug 13807: events can not be meta properties.
            if (isEvent && defaultMetadata != null && defaultMetadata.IsMetaProperty)
                throw new ArgumentException(SR.GetString(SR.Error_DPAddHandlerMetaProperty), "defaultMetadata");

            //Field must exists
            if (isEvent)
                fieldInfo = ownerType.GetField(name + "Event", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.GetProperty);
            else
                fieldInfo = ownerType.GetField(name + "Property", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.GetProperty);

            if (fieldInfo == null)
            {
                string error = SR.GetString((isEvent) ? SR.Error_DynamicEventNotSupported : SR.Error_DynamicPropertyNotSupported, new object[] { ownerType.FullName, name });
                throw new ArgumentException(error, "ownerType");
            }


            PropertyMetadata metadata = null;
            object defaultValue = null;

            // Establish default metadata for all types, if none is provided
            if (defaultMetadata == null)
            {
                defaultValue = GetDefaultValue(name, propertyType, ownerType);
                metadata = new PropertyMetadata(defaultValue);
            }
            else
            {
                metadata = defaultMetadata;
                if (metadata.DefaultValue == null)
                    metadata.DefaultValue = GetDefaultValue(name, propertyType, ownerType);
            }

            DependencyProperty dependencyProperty = new DependencyProperty(name, propertyType, ownerType, metadata, validatorType, isRegistered);
            lock (((ICollection)DependencyProperty.dependencyProperties).SyncRoot)
            {
                if (DependencyProperty.dependencyProperties.ContainsKey(dependencyProperty.GetHashCode()))
                    throw new InvalidOperationException(SR.GetString(SR.Error_DPAlreadyExist, new object[] { name, ownerType.FullName }));

                DependencyProperty.dependencyProperties.Add(dependencyProperty.GetHashCode(), dependencyProperty);
            }

            return dependencyProperty;
        }
Пример #9
0
		static SetStateActivity ()
		{
			TargetStateNameProperty = DependencyProperty.Register ("TargetStateName",
				typeof (string), typeof (SetStateActivity));
		}
Пример #10
0
		public static DependencyProperty Register (string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata)
		{
			DependencyProperty property = new DependencyProperty (name, propertyType, ownerType, defaultMetadata);

			if (ownerType.GetField (name + "Event", BindingFlags.Public | BindingFlags.Static) != null) {
				property.IsEventSet = true;
			}

			if (properties.ContainsKey (property.GetHashCode ())) {
				throw new InvalidOperationException ("A property with the same name already exists");
			}

			properties.Add (property.GetHashCode (), property);
			return property;
		}
Пример #11
0
		static CodeCondition ()
		{
			ConditionEvent = DependencyProperty.Register ("Condition", typeof (EventHandler <ConditionalEventArgs>),
				typeof (CodeCondition));
		}
Пример #12
0
		static TerminateActivity ()
		{
		  	ErrorProperty = DependencyProperty.Register ("Error", typeof(string), typeof (TerminateActivity));
		}
 private ValidationErrorCollection ValidateDependencyProperty(DependencyObject dependencyObject, DependencyProperty dependencyProperty, ValidationManager manager)
 {
     ValidationErrorCollection errors = new ValidationErrorCollection();
     Attribute[] attributes = dependencyProperty.DefaultMetadata.GetAttributes(typeof(ValidationOptionAttribute));
     ValidationOption option = (attributes.Length > 0) ? ((ValidationOptionAttribute) attributes[0]).ValidationOption : ValidationOption.Optional;
     Activity propertyOwner = manager.Context[typeof(Activity)] as Activity;
     if (propertyOwner == null)
     {
         throw new InvalidOperationException(SR.GetString("Error_ContextStackItemMissing", new object[] { typeof(Activity).FullName }));
     }
     PropertyValidationContext context = new PropertyValidationContext(propertyOwner, dependencyProperty);
     manager.Context.Push(context);
     try
     {
         if (dependencyProperty.DefaultMetadata.DefaultValue != null)
         {
             if (!dependencyProperty.PropertyType.IsValueType && (dependencyProperty.PropertyType != typeof(string)))
             {
                 errors.Add(new ValidationError(SR.GetString("Error_PropertyDefaultIsReference", new object[] { dependencyProperty.Name }), 0x1a8));
             }
             else if (!dependencyProperty.PropertyType.IsAssignableFrom(dependencyProperty.DefaultMetadata.DefaultValue.GetType()))
             {
                 errors.Add(new ValidationError(SR.GetString("Error_PropertyDefaultTypeMismatch", new object[] { dependencyProperty.Name, dependencyProperty.PropertyType.FullName, dependencyProperty.DefaultMetadata.DefaultValue.GetType().FullName }), 0x1a9));
             }
         }
         object propValue = null;
         if (dependencyObject.IsBindingSet(dependencyProperty))
         {
             propValue = dependencyObject.GetBinding(dependencyProperty);
         }
         else if (!dependencyProperty.IsEvent)
         {
             propValue = dependencyObject.GetValue(dependencyProperty);
         }
         if ((propValue == null) || (propValue == dependencyProperty.DefaultMetadata.DefaultValue))
         {
             if (dependencyProperty.IsEvent)
             {
                 propValue = dependencyObject.GetHandler(dependencyProperty);
                 if (propValue == null)
                 {
                     propValue = WorkflowMarkupSerializationHelpers.GetEventHandlerName(dependencyObject, dependencyProperty.Name);
                 }
                 if ((propValue is string) && !string.IsNullOrEmpty((string) propValue))
                 {
                     errors.AddRange(this.ValidateEvent(propertyOwner, dependencyProperty, propValue, manager));
                 }
             }
             else
             {
                 propValue = dependencyObject.GetValue(dependencyProperty);
             }
         }
         bool flag = (propertyOwner.Parent != null) || ((propertyOwner is CompositeActivity) && (((CompositeActivity) propertyOwner).EnabledActivities.Count != 0));
         if (((option == ValidationOption.Required) && ((propValue == null) || ((propValue is string) && string.IsNullOrEmpty((string) propValue)))) && (dependencyProperty.DefaultMetadata.IsMetaProperty && flag))
         {
             errors.Add(ValidationError.GetNotSetValidationError(base.GetFullPropertyName(manager)));
             return errors;
         }
         if (propValue == null)
         {
             return errors;
         }
         if (propValue is IList)
         {
             PropertyValidationContext context2 = new PropertyValidationContext(propValue, null, string.Empty);
             manager.Context.Push(context2);
             try
             {
                 foreach (object obj3 in (IList) propValue)
                 {
                     errors.AddRange(ValidationHelpers.ValidateObject(manager, obj3));
                 }
                 return errors;
             }
             finally
             {
                 manager.Context.Pop();
             }
         }
         if (dependencyProperty.ValidatorType != null)
         {
             Validator validator = null;
             try
             {
                 validator = Activator.CreateInstance(dependencyProperty.ValidatorType) as Validator;
                 if (validator == null)
                 {
                     errors.Add(new ValidationError(SR.GetString("Error_CreateValidator", new object[] { dependencyProperty.ValidatorType.FullName }), 0x106));
                     return errors;
                 }
                 errors.AddRange(validator.Validate(manager, propValue));
                 return errors;
             }
             catch
             {
                 errors.Add(new ValidationError(SR.GetString("Error_CreateValidator", new object[] { dependencyProperty.ValidatorType.FullName }), 0x106));
                 return errors;
             }
         }
         errors.AddRange(ValidationHelpers.ValidateObject(manager, propValue));
     }
     finally
     {
         manager.Context.Pop();
     }
     return errors;
 }
 private ValidationErrorCollection ValidateEvent(Activity activity, DependencyProperty dependencyProperty, object propValue, ValidationManager manager)
 {
     ValidationErrorCollection errors = new ValidationErrorCollection();
     if ((propValue is string) && !string.IsNullOrEmpty((string) propValue))
     {
         bool flag = false;
         Type type = null;
         Activity rootActivity = Helpers.GetRootActivity(activity);
         Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
         string str = rootActivity.GetValue(WorkflowMarkupSerializer.XClassProperty) as string;
         if ((rootActivity == enclosingActivity) && !string.IsNullOrEmpty(str))
         {
             ITypeProvider service = manager.GetService(typeof(ITypeProvider)) as ITypeProvider;
             if (service == null)
             {
                 throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ITypeProvider).FullName }));
             }
             type = service.GetType(str);
         }
         else
         {
             type = enclosingActivity.GetType();
         }
         if (type != null)
         {
             MethodInfo method = dependencyProperty.PropertyType.GetMethod("Invoke");
             if (method != null)
             {
                 List<Type> list = new List<Type>();
                 foreach (ParameterInfo info2 in method.GetParameters())
                 {
                     list.Add(info2.ParameterType);
                 }
                 MethodInfo info3 = Helpers.GetMethodExactMatch(type, propValue as string, BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance, null, list.ToArray(), null);
                 if ((info3 != null) && TypeProvider.IsAssignable(method.ReturnType, info3.ReturnType))
                 {
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             ValidationError item = new ValidationError(SR.GetString("Error_CantResolveEventHandler", new object[] { dependencyProperty.Name, propValue as string }), 0x60f) {
                 PropertyName = base.GetFullPropertyName(manager)
             };
             errors.Add(item);
         }
     }
     return errors;
 }
        internal void Seal(DependencyProperty dependencyProperty, Type targetType)
        {
            OnApply(dependencyProperty, targetType);

            this.propertySealed = true;
        }
Пример #16
0
		static CodeActivity ()
		{
			ExecuteCodeEvent = DependencyProperty.Register ("ExecuteCode", typeof (EventHandler),
				typeof (CodeActivity));
		}
Пример #17
0
      		protected virtual void OnApply (DependencyProperty dependencyProperty, Type targetType)
		{

		}
		static WorkflowParameterBinding ()
		{
			ValueProperty = DependencyProperty.Register ("Value", typeof (object), typeof (WorkflowParameterBinding));
			ParameterNameProperty = DependencyProperty.Register ("ParameterName", typeof (string), typeof (WorkflowParameterBinding));
		}
 private static DependencyProperty ValidateAndRegister(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, Type validatorType, bool isRegistered)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw new ArgumentException(SR.GetString("Error_EmptyArgument"), "name");
     }
     if (propertyType == null)
     {
         throw new ArgumentNullException("propertyType");
     }
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     FieldInfo field = null;
     bool flag = typeof(Delegate).IsAssignableFrom(propertyType) && ((defaultMetadata == null) || (((byte) (defaultMetadata.Options & DependencyPropertyOptions.DelegateProperty)) == 0));
     if ((flag && (defaultMetadata != null)) && defaultMetadata.IsMetaProperty)
     {
         throw new ArgumentException(SR.GetString("Error_DPAddHandlerMetaProperty"), "defaultMetadata");
     }
     if (flag)
     {
         field = ownerType.GetField(name + "Event", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
     }
     else
     {
         field = ownerType.GetField(name + "Property", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
     }
     if (field == null)
     {
         throw new ArgumentException(SR.GetString(flag ? "Error_DynamicEventNotSupported" : "Error_DynamicPropertyNotSupported", new object[] { ownerType.FullName, name }), "ownerType");
     }
     PropertyMetadata metadata = null;
     if (defaultMetadata == null)
     {
         metadata = new PropertyMetadata(GetDefaultValue(name, propertyType, ownerType));
     }
     else
     {
         metadata = defaultMetadata;
         if (metadata.DefaultValue == null)
         {
             metadata.DefaultValue = GetDefaultValue(name, propertyType, ownerType);
         }
     }
     DependencyProperty property = new DependencyProperty(name, propertyType, ownerType, metadata, validatorType, isRegistered);
     lock (((ICollection) dependencyProperties).SyncRoot)
     {
         if (dependencyProperties.ContainsKey(property.GetHashCode()))
         {
             throw new InvalidOperationException(SR.GetString("Error_DPAlreadyExist", new object[] { name, ownerType.FullName }));
         }
         dependencyProperties.Add(property.GetHashCode(), property);
     }
     return property;
 }
Пример #20
0
		static WorkflowQueuingService ()
		{
      			PendingMessagesProperty = DependencyProperty.RegisterAttached ("PendingMessages",
      				typeof (Queue), typeof (WorkflowQueuingService), new PropertyMetadata ());
      		}
Пример #21
0
		static RuleDefinitions ()
		{
			RuleDefinitionsProperty = DependencyProperty.RegisterAttached ("RuleDefinitions",
				typeof (RuleDefinitions), typeof(RuleDefinitions));
		}