/// <summary> /// Create an instance of ModelProgramProvider for a given assembly /// </summary> /// <param name="modelAssemblyFile">The full path to the assembly file.</param> /// <param name="generator">Optional parameter generator.</param> public ModelProgramProvider(string modelAssemblyFile, ParameterGenerator/*?*/ generator) { modelAssembly = Assembly.LoadFrom(modelAssemblyFile); this.generator = generator; Initialize(); initialState = GetState(); }
public Method(MethodInfo methodInfo) { //this.instanceType = null; this.parameterTypes = null; this.methodInfo = methodInfo; //this.isStatic = methodInfo.IsStatic; this.parameterInfos = methodInfo.GetParameters(); //this.returnType = methodInfo.ReturnType.Equals(typeof(void)) ? null : methodInfo.ReturnType; this.thisParameterGenerator = Method.GetThisParameterGenerator(methodInfo); this.inputParameterGenerators = Method.GetInputParameterGenerators(methodInfo); ; Type[] inputParameterTypes = ReflectionHelper.GetInputParameterTypes(methodInfo); this.parameterlessEnablingCondition = new EnablingCondition(true, inputParameterTypes, methodInfo); this.enablingCondition = new EnablingCondition(false, inputParameterTypes, methodInfo); }
internal static ParameterGenerator[] GetInputParameterGenerators(MethodInfo methodInfo) { ParameterInfo[] parameterInfos = methodInfo.GetParameters(); int nParameters = parameterInfos.Length; ParameterGenerator/*?*/[] result = new ParameterGenerator[nParameters]; for (int i = 0; i < nParameters; i += 1) { ParameterInfo pInfo = parameterInfos[i]; Type pType = pInfo.ParameterType; if (pType.IsByRef) { pType = pType.GetElementType(); } ParameterGenerator/*?*/ parameterGenerator = null; if (ReflectionHelper.IsInputParameter(pInfo)) { object/*?*/[]/*?*/ attrs1 = pInfo.GetCustomAttributes(typeof(DomainAttribute), true); // object/*?*/[]/*?*/ attrs2 = pInfo.GetCustomAttributes(typeof(_Attribute), true); // object/*?*/[]/*?*/ attrs3 = pInfo.GetCustomAttributes(typeof(NewAttribute), true); bool hasDomainAttr = (attrs1 != null && attrs1.Length > 0); if (hasDomainAttr) { DomainAttribute attr = (DomainAttribute)attrs1[0]; string attrName = attr.Name; if (string.Equals("new", attrName)) { Symbol sort = AbstractValue.TypeSort(pType); parameterGenerator = delegate() { return new Set<Term>(LabeledInstance.PeekNextLabelTerm(sort)); }; } else parameterGenerator = CreateDomainParameterGenerator(methodInfo, attr, pType); } else { parameterGenerator = Method.GetDefaultParameterGenerator(pType); } } result[i] = parameterGenerator; } return result; }
/// <summary> /// Set method parameters. /// </summary> /// <param name="parameters">A set of wanted parameters.</param> /// <returns>The current method builder</returns> public MethodBuilder WithParameters(params Parameter[] parameters) { _parameters.Clear(); _parameterXmlDocumentation.Clear(); foreach (var parameter in parameters) { _parameters.Add(ParameterGenerator.Create(parameter)); if (parameter.XmlDocumentation != null) { _parameterXmlDocumentation.Add(parameter); } } return(this); }
public override void Process(Impulse impulse) { Impulse result = null; if (impulse is Data) { //TODO: new to chew up the data before i decide what to do with it. // i will only check for a definition if that is what the query requests. Data query = impulse as Data; Parameters parameters = ParameterGenerator.GenerateParameters(query.Content, "/api/v1/entries/en/"); Definition definition = Collector.GatherData <Definition>(parameters).Result as Definition; if (definition != null) { result = Map.DefinitionToWord(definition); if (result != null) { result.Outcome = Outcome.Success; result.Signal = SignalType.Response; } else { Trace.WriteLine($"{Resources.Constants.Trace.Date};{this.ToString()};{SignalType.None};{Outcome.Failure}"); } } else { result = new Data { Content = "", Outcome = Outcome.Failure, Signal = SignalType.Response, }; } if (result != null) { Transmitter.SendSignal(result); Trace.WriteLine(string.Format("{0};{1};{2}", Resources.Constants.Trace.Date, this.ToString(), result.Signal)); } } }
private void AppendInsertQueryForValues(IDbCommand command, ParameterGenerator seed, object keyHandle, IEnumerable <VirtualRegistryValue> values) { foreach (var value in values) { var paramHandle = seed.Next(); var paramName = seed.Next(); var paramValue = seed.Next(); var paramType = seed.Next(); command.CommandText += string.Format("INSERT INTO [{0}] ({1}, {2}, {3}, {4}) VALUES ({5}, {6}, {7}, {8});", _DatabaseValueTable, _DatabaseValueKey, _DatabaseValueName, _DatabaseValueValue, _DatabaseValueType, paramHandle, paramName, paramValue, paramType); command.Parameters.Add(CreateParameter(paramHandle, keyHandle)); command.Parameters.Add(CreateParameter(paramName, value.Name)); command.Parameters.Add(CreateParameter(paramValue, value.Data)); command.Parameters.Add(CreateParameter(paramType, Enum.GetName(typeof(ValueType), value.Type))); } }
protected override void AppendUpdateQuery(IDbCommand command, ParameterGenerator seed, VirtualRegistryKey item) { var paramHandle = seed.Next(); var paramName = seed.Next(); // Append query for update of the key. command.CommandText += string.Format("UPDATE {0} SET {1} = {2} WHERE {3} = {4};", _DatabaseKeyTable, _DatabaseKeyName, paramName, _DatabaseKeyHandle, paramHandle); command.Parameters.Add(CreateParameter(paramHandle, item.Handle)); command.Parameters.Add(CreateParameter(paramName, item.Path)); // Delete all values. It's too complicated to use an update query. paramHandle = seed.Next(); command.CommandText += string.Format("DELETE FROM {0} WHERE {1} = {2};", _DatabaseValueTable, _DatabaseValueKey, paramHandle); command.Parameters.Add(CreateParameter(paramHandle, item.Handle)); // Now re-add all values. AppendInsertQueryForValues(command, seed, item.Handle, item.Values.Values); }
protected override ArgumentSyntax CreateArgumentSyntax() { ParenthesizedLambdaExpressionSyntax expression = null; if (_blockSyntax != null) { expression = ParenthesizedLambdaExpression(_blockSyntax); } else { expression = ParenthesizedLambdaExpression(_expressionSyntax); } if (_parameters.Any()) { expression = expression.WithParameterList(ParameterGenerator.ConvertParameterSyntaxToList(_parameters.Select(p => Parameter(Identifier(p.Name))).ToArray())); } return(Argument(expression)); }
protected override void Write(IEnumerator <DatabaseAction <T> > items) { using (var command = CreateCommand("")) { var seed = new ParameterGenerator(); while (items.MoveNext()) { switch (items.Current.ActionType) { case DatabaseActionType.Set: if (!ItemExists(items.Current.Item)) { AppendInsertQuery(command, seed, items.Current.Item); } else { AppendUpdateQuery(command, seed, items.Current.Item); } break; case DatabaseActionType.Remove: AppendDeleteQuery(command, seed, items.Current.Item); break; default: throw new NotImplementedException( "DatabaseActionType is changed without adding an extra handler to the Database.Flush() method."); } } // Execute the command as a single transaction to improve speed. command.CommandText = "BEGIN;" + command.CommandText + "COMMIT;"; if (!ExecuteCommand(command)) { throw new DatabaseException("Failed to flush the database."); } } }
protected override TypeGenerator OnGenerateType(ref string output, NamespaceGenerator @namespace) { var @class = ClassGenerator.Class(RootAccessModifier.Public, ClassModifier.None, Data.title.LegalMemberName(), Data.scriptableObject ? typeof(ScriptableObject) : typeof(object)); if (Data.definedEvent) { @class.ImplementInterface(typeof(IDefinedEvent)); } if (Data.inspectable) { @class.AddAttribute(AttributeGenerator.Attribute <InspectableAttribute>()); } if (Data.serialized) { @class.AddAttribute(AttributeGenerator.Attribute <SerializableAttribute>()); } if (Data.includeInSettings) { @class.AddAttribute(AttributeGenerator.Attribute <IncludeInSettingsAttribute>().AddParameter(true)); } if (Data.scriptableObject) { @class.AddAttribute(AttributeGenerator.Attribute <CreateAssetMenuAttribute>().AddParameter("menuName", Data.menuName).AddParameter("fileName", Data.fileName).AddParameter("order", Data.order)); } for (int i = 0; i < Data.constructors.Count; i++) { var constructor = ConstructorGenerator.Constructor(Data.constructors[i].scope, Data.constructors[i].modifier, Data.title.LegalMemberName()); if (Data.constructors[i].graph.units.Count > 0) { var unit = Data.constructors[i].graph.units[0] as FunctionNode; constructor.Body(FunctionNodeGenerator.GetSingleDecorator(unit, unit).GenerateControl(null, new ControlGenerationData(), 0)); for (int pIndex = 0; pIndex < Data.constructors[i].parameters.Count; pIndex++) { if (!string.IsNullOrEmpty(Data.constructors[i].parameters[pIndex].name)) { constructor.AddParameter(false, ParameterGenerator.Parameter(Data.constructors[i].parameters[pIndex].name, Data.constructors[i].parameters[pIndex].type, ParameterModifier.None)); } } } @class.AddConstructor(constructor); } for (int i = 0; i < Data.variables.Count; i++) { if (!string.IsNullOrEmpty(Data.variables[i].name) && Data.variables[i].type != null) { var attributes = Data.variables[i].attributes; if (Data.variables[i].isProperty) { var property = PropertyGenerator.Property(Data.variables[i].scope, Data.variables[i].propertyModifier, Data.variables[i].type, Data.variables[i].name, false); for (int attrIndex = 0; attrIndex < attributes.Count; attrIndex++) { AttributeGenerator attrGenerator = AttributeGenerator.Attribute(attributes[attrIndex].GetAttributeType()); property.AddAttribute(attrGenerator); } if (Data.variables[i].get) { property.MultiStatementGetter(AccessModifier.Public, NodeGenerator.GetSingleDecorator(Data.variables[i].getter.graph.units[0] as Unit, Data.variables[i].getter.graph.units[0] as Unit) .GenerateControl(null, new ControlGenerationData() { returns = Data.variables[i].type }, 0)); } if (Data.variables[i].set) { property.MultiStatementSetter(AccessModifier.Public, NodeGenerator.GetSingleDecorator(Data.variables[i].setter.graph.units[0] as Unit, Data.variables[i].setter.graph.units[0] as Unit) .GenerateControl(null, new ControlGenerationData(), 0)); } @class.AddProperty(property); } else { var field = FieldGenerator.Field(Data.variables[i].scope, Data.variables[i].fieldModifier, Data.variables[i].type, Data.variables[i].name); for (int attrIndex = 0; attrIndex < attributes.Count; attrIndex++) { AttributeGenerator attrGenerator = AttributeGenerator.Attribute(attributes[attrIndex].GetAttributeType()); field.AddAttribute(attrGenerator); } @class.AddField(field); } } } for (int i = 0; i < Data.methods.Count; i++) { if (!string.IsNullOrEmpty(Data.methods[i].name) && Data.methods[i].returnType != null) { var method = MethodGenerator.Method(Data.methods[i].scope, Data.methods[i].modifier, Data.methods[i].returnType, Data.methods[i].name); if (Data.methods[i].graph.units.Count > 0) { var unit = Data.methods[i].graph.units[0] as FunctionNode; method.Body(FunctionNodeGenerator.GetSingleDecorator(unit, unit).GenerateControl(null, new ControlGenerationData(), 0)); for (int pIndex = 0; pIndex < Data.methods[i].parameters.Count; pIndex++) { if (!string.IsNullOrEmpty(Data.methods[i].parameters[pIndex].name)) { method.AddParameter(ParameterGenerator.Parameter(Data.methods[i].parameters[pIndex].name, Data.methods[i].parameters[pIndex].type, ParameterModifier.None)); } } } @class.AddMethod(method); } } @namespace.AddClass(@class); return(@class); }
private MethodDeclarationSyntax BuildParameters(MethodDeclarationSyntax method) { return(!_parameters.Any() ? method : method.WithParameterList(ParameterGenerator.ConvertParameterSyntaxToList(_parameters.ToArray()))); }
public void Create_WhenProvidingParameterWithThisModifier_ShouldGenerateCorrectCode() { Assert.AreEqual("(thisinttest)", ParameterGenerator.Create(new Parameter("test", typeof(int), ParameterModifiers.This)).ToString()); }
public void Create_WhenNotProvidingAnyParameters_ShouldGetEmptyBraces() { Assert.AreEqual("()", ParameterGenerator.Create().ToString()); }
public override string Generate(int indent) { if (Data != null) { var output = string.Empty; NamespaceGenerator @namespace = NamespaceGenerator.Namespace(Data.category); InterfaceGenerator @interface = InterfaceGenerator.Interface(Data.title.LegalMemberName()); if (string.IsNullOrEmpty(Data.title)) { return(output); } for (int i = 0; i < Data.variables.Count; i++) { var prop = Data.variables[i]; if (string.IsNullOrEmpty(prop.name) || prop.type == null) { continue; } if (!prop.get && !prop.set) { prop.get = true; } @interface.AddProperty(InterfacePropertyGenerator.Property(prop.name, prop.type, prop.get, prop.set)); } for (int i = 0; i < Data.methods.Count; i++) { var method = Data.methods[i]; if (string.IsNullOrEmpty(method.name) || method.returnType == null) { continue; } var methodGen = InterfaceMethodGenerator.Method(method.name, method.returnType); for (int paramIndex = 0; paramIndex < Data.methods[i].parameters.Count; paramIndex++) { var parameter = Data.methods[i].parameters[paramIndex]; if (string.IsNullOrEmpty(parameter.name) || parameter.type == null) { continue; } methodGen.AddParameter(ParameterGenerator.Parameter(parameter.name, parameter.type, parameter.modifier)); } @interface.AddMethod(methodGen); } #if VISUAL_SCRIPTING_1_7 if (Data.lastCompiledName != Data.GetFullTypeName() && !string.IsNullOrEmpty(Data.GetFullTypeName()) && !string.IsNullOrEmpty(Data.lastCompiledName)) { @interface.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName)); } #endif @namespace.AddInterface(@interface); return(@namespace.Generate(indent)); } return(string.Empty); }
/// <summary> /// Appends a delete-query for <paramref name="item"/> to <paramref name="command"/>. /// The parameters are added to the Parameters of <paramref name="command"/>, /// the (unique) naming of these parameters is done by using <paramref name="seed"/>. /// </summary> /// <param name="command">The command to append the query to.</param> /// <param name="seed">The object to use for the generation of unique names.</param> /// <param name="item"></param> /// <returns></returns> protected abstract void AppendDeleteQuery(IDbCommand command, ParameterGenerator seed, T item);
public void AddOther(ParameterType id, string name, ParameterGenerator factory) { m_types.Add(id, new TypeData(factory, name)); Modified.Execute(id); }
public TypeData(ParameterGenerator generator, string name) { Generator = generator; Name = name; }
protected virtual string CreateRequestUrl(IUrlRouteParameters routeParameters, IUrlQueryParameters queryParameters) { return(CreateRequestUrl(ParameterGenerator.Generate(routeParameters), ParameterGenerator.Generate(queryParameters))); }
public override string Generate(int indent) { NamespaceGenerator @namespace = NamespaceGenerator.Namespace("Unity.VisualScripting.Community.Generated"); if (Data != null) { var title = GetCompoundTitle(); var delegateType = DelegateType; Data.title = title; if (!string.IsNullOrEmpty(Data.category)) { @namespace = NamespaceGenerator.Namespace(Data.category); } var @class = ClassGenerator.Class(RootAccessModifier.Public, ClassModifier.None, title, typeof(object)).ImplementInterface(delegateType); var properties = string.Empty; var method = Data.type.type.GetMethod("Invoke"); var parameterUsings = new List <string>(); var parameters = method.GetParameters(); var parameterNames = new List <string>(); var something = new Dictionary <ParameterInfo, string>(); for (int i = 0; i < parameters.Length; i++) { properties += " new".ConstructHighlight() + " TypeParam".TypeHighlight() + "() { name = " + $@"""{parameters[i].Name}""".StringHighlight() + ", type = " + "typeof".ConstructHighlight() + "(" + (parameters[i].ParameterType.IsGenericParameter ? Data.generics[i].type.type.As().CSharpName() : parameters[i].ParameterType.As().CSharpName()) + ") }"; if (!parameterUsings.Contains(parameters[i].ParameterType.Namespace)) { parameterUsings.Add(parameters[i].ParameterType.Namespace); } if (i < parameters.Length - 1) { properties += ", "; } } @class.AddUsings(parameterUsings); if (string.IsNullOrEmpty(properties)) { properties += " "; } else { properties = " " + properties + " "; } var displayName = string.IsNullOrEmpty(Data.displayName) ? Data.type.type.As().CSharpName().RemoveHighlights().RemoveMarkdown() : Data.displayName; var constructors = Data.type.type.GetConstructors(); var constructorParameters = constructors[constructors.Length - 1 > 0 ? 1 : 0]; var stringConstructorParameters = new List <string>(); var constParams = parameters.ToListPooled(); var assignParams = string.Empty; if (constParams.Count <= 0) { } var constParamsLength = constParams.Count; var invokeString = string.Empty; for (int i = constParamsLength - 1; i >= 0; i--) { if (constParams[i].Name == "object" || constParams[i].Name == "method") { constParams.Remove(constParams[i]); } } for (int i = 0; i < constParams.Count; i++) { assignParams += constParams[i].Name.EnsureNonConstructName().Replace("&", string.Empty); stringConstructorParameters.Add(constParams[i].Name.EnsureNonConstructName().Replace("&", string.Empty)); if (i < constParams.Count - 1) { assignParams += ", "; } } var remappedGenerics = string.Empty; var remappedGeneric = Data.type.type.Name.EnsureNonConstructName(); for (int i = 0; i < Data.generics.Count; i++) { remappedGenerics += Data.generics[i].type.type.As().CSharpName().Replace("&", string.Empty); if (i < Data.generics.Count - 1) { remappedGenerics += ", "; } } if (Data.generics.Count - 1 >= 0 || IsAction) { for (int i = 0; i < (IsAction ? Data.generics.Count : Mathf.Clamp(Data.generics.Count - 1, 0, Data.generics.Count)); i++) { if (i < Data.generics.Count - 1 || IsAction) { invokeString += $"({ Data.generics[i].type.type.As().CSharpName().Replace("&", string.Empty)})parameters[{i.ToString()}]"; if (i < Data.generics.Count - (IsAction ? 1 : 2)) { invokeString += ", "; } } } } if (Data.generics.Count > 0) { remappedGeneric = remappedGeneric.Contains("`") ? remappedGeneric.Remove(remappedGeneric.IndexOf("`"), remappedGeneric.Length - remappedGeneric.IndexOf("`")) : remappedGeneric; remappedGeneric = remappedGeneric.TypeHighlight() + "<" + remappedGenerics + ">"; } else { remappedGeneric.TypeHighlight(); } @class.AddField(FieldGenerator.Field(AccessModifier.Public, FieldModifier.None, remappedGeneric, Data.type.type.Namespace, "callback")); @class.AddField(FieldGenerator.Field(AccessModifier.Public, FieldModifier.None, remappedGeneric, Data.type.type.Namespace, "instance")); @class.AddField(FieldGenerator.Field(AccessModifier.Private, FieldModifier.None, typeof(bool), "_initialized")); @class.AddProperty(PropertyGenerator.Property(AccessModifier.Public, PropertyModifier.None, typeof(TypeParam), "parameters", false).SingleStatementGetter(AccessModifier.Public, "new".ConstructHighlight() + " TypeParam".TypeHighlight() + "[] {" + properties.Replace("&", string.Empty) + "}").AddTypeIndexer("")); @class.AddProperty(PropertyGenerator.Property(AccessModifier.Public, PropertyModifier.None, typeof(string), "DisplayName", false).SingleStatementGetter(AccessModifier.Public, $@"""{remappedGeneric.RemoveHighlights().RemoveMarkdown().Replace("<", " (").Replace(">", ")")}""".StringHighlight())); @class.AddProperty(PropertyGenerator.Property(AccessModifier.Public, PropertyModifier.None, typeof(bool), "initialized", false).SingleStatementGetter(AccessModifier.Public, "_initialized").SingleStatementSetter(AccessModifier.Public, "_initialized = value")); if (IsFunc) { @class.AddProperty(PropertyGenerator.Property(AccessModifier.Public, PropertyModifier.None, typeof(Type), "ReturnType", false).SingleStatementGetter(AccessModifier.Public, "typeof".ConstructHighlight() + "(" + Data.generics[Data.generics.Count - 1].type.type.As().CSharpName() + ")")); } @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(Type), "GetDelegateType").Body("return typeof".ConstructHighlight() + "(" + remappedGeneric + ");")); @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(object), "GetDelegate").Body("return".ConstructHighlight() + " callback;")); @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, IsAction ? typeof(void) : typeof(object), IsAction ? "Invoke" : "DynamicInvoke").AddParameter(ParameterGenerator.Parameter("parameters", typeof(object[]), Libraries.CSharp.ParameterModifier.None, isParameters: true)).Body($"{(IsAction ? string.Empty : "return").ConstructHighlight()} callback({invokeString});")); if (!IsAction) { @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, Data.generics[Mathf.Clamp(Data.generics.Count - 1, 0, Data.generics.Count - 1)].type.type, "Invoke").AddParameter(ParameterGenerator.Parameter("parameters", typeof(object[]), Libraries.CSharp.ParameterModifier.None, isParameters: true)).Body($"{(IsAction ? string.Empty : "return").ConstructHighlight()} callback({invokeString});")); } @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(void), "Initialize"). AddParameter(ParameterGenerator.Parameter("flow", typeof(Flow), Libraries.CSharp.ParameterModifier.None)). AddParameter(ParameterGenerator.Parameter("unit", IsAction ? typeof(ActionNode) : typeof(FuncNode), Libraries.CSharp.ParameterModifier.None)). AddParameter(ParameterGenerator.Parameter(IsAction ? "flowAction" : "flowFunc", IsAction ? typeof(Action) : typeof(Func <object>), Libraries.CSharp.ParameterModifier.None)). Body("SetInstance(flow, unit, " + (IsAction ? "flowAction" : "flowFunc") + "); \n" + "callback = " + "new ".ConstructHighlight() + remappedGeneric + "(" + LambdaGenerator.SingleLine(stringConstructorParameters, (!IsAction ? "return".ConstructHighlight() + " " : string.Empty) + $"instance({assignParams});").Generate(0) + ");\n" + "initialized = " + "true".ConstructHighlight() + ";")); @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(void), "SetInstance"). AddParameter(ParameterGenerator.Parameter("flow", typeof(Flow), Libraries.CSharp.ParameterModifier.None)). AddParameter(ParameterGenerator.Parameter("unit", IsAction ? typeof(ActionNode) : typeof(FuncNode), Libraries.CSharp.ParameterModifier.None)). AddParameter(ParameterGenerator.Parameter(IsAction ? "flowAction" : "flowFunc", IsAction ? typeof(Action) : typeof(Func <object>), Libraries.CSharp.ParameterModifier.None)). Body("instance = " + "new ".ConstructHighlight() + remappedGeneric + "(" + LambdaGenerator.SingleLine(stringConstructorParameters, (stringConstructorParameters.Count > 0 ? "unit.AssignParameters(flow, " + assignParams + "); " + (IsAction ? "flowAction();" : "return ".ConstructHighlight() + "(" + Data.generics[Data.generics.Count - 1].type.type.As().CSharpName() + ")" + "flowFunc();") : (IsAction ? "flowAction();" : "return ".ConstructHighlight() + "(" + Data.generics[Data.generics.Count - 1].type.type.As().CSharpName() + ")" + "flowFunc();"))).Generate(0) + ");")); @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(void), "Bind"). AddParameter(ParameterGenerator.Parameter("other", typeof(IDelegate), Libraries.CSharp.ParameterModifier.None)) .Body( "callback += (" + remappedGeneric + ")other.GetDelegate();" )); @class.AddMethod(MethodGenerator.Method(AccessModifier.Public, MethodModifier.None, typeof(void), "Unbind"). AddParameter(ParameterGenerator.Parameter("other", typeof(IDelegate), Libraries.CSharp.ParameterModifier.None)) .Body( "callback -= (" + remappedGeneric + ")other.GetDelegate();" )); @class.AddUsings(new List <string>() { Data.type.type.Namespace, "System" }); @class.AddAttribute(AttributeGenerator.Attribute <IncludeInSettingsAttribute>().AddParameter(true)); if (Data.lastCompiledName != Data.GetFullTypeName()) { @class.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName)); } var genericNamespace = new List <string>(); for (int i = 0; i < Data.generics.Count; i++) { if (!genericNamespace.Contains(Data.generics[i].type.type.Namespace)) { genericNamespace.Add(Data.generics[i].type.type.Namespace); } } @class.AddUsings(genericNamespace); @namespace.AddClass(@class); return(@namespace.Generate(indent)); } return(string.Empty); }
public void TestInitialize() { _generator = new ParameterGenerator(); _generator.InjectDependency(_statementGenerator = new StatementGeneratorStub()); }