private static void RegisterOperator <T>( RuleActivityManager activityManager, OperatorEntry.OperatorCategory category, string displayName) where T : CodeActivity <DynamicValue>, new() { string functionName = typeof(T).Name; activityManager.RegisterOperator( functionName, displayName, () => new T(), OperatorSignature, typeof(T), typeof(DynamicValue), category); }
/// <summary> /// Registers operators with specified name, display name, factory function, signature, /// operator type(operator is a kind of activity), return type and category. /// </summary> /// <param name="name">The operator's name.</param> /// <param name="displayName">The operator's display name.</param> /// <param name="factoryFunction">The factory function to create new instance of the operator.</param> /// <param name="signature">The operator's signature.</param> /// <param name="activityType">The specified System.Type object representing the operator's type.</param> /// <param name="returnType">The specified System.Type object representing the operator's return type.</param> /// <param name="category">The specified category of the operator.</param> public void RegisterOperator(string name, string displayName, Func <Activity> factoryFunction, ActivitySignature signature, Type activityType, Type returnType, OperatorEntry.OperatorCategory category) { if (name == null) { throw new ArgumentNullException("name"); // NOXLATE } if (displayName == null) { throw new ArgumentNullException("displayName"); // NOXLATE } if (factoryFunction == null) { throw new ArgumentNullException("factoryFunction"); // NOXLATE } if (signature == null) { throw new ArgumentNullException("signature"); // NOXLATE } if (activityType == null) { throw new ArgumentNullException("activityType"); // NOXLATE } if (returnType == null) { throw new ArgumentNullException("returnType"); // NOXLATE } if (name.Length == 0) { throw new ArgumentException(String.Format(Properties.Resources.ArgumentExceptionMessage, "name")); // NOXLATE } if (displayName.Length == 0) { throw new ArgumentException(String.Format(Properties.Resources.ArgumentExceptionMessage, "displayName")); // NOXLATE } OperatorEntry entry = new OperatorEntry( name, displayName, factoryFunction, signature, activityType, returnType, category); operatorEntries.Add(entry); typeDictionary[activityType] = entry; }