public static FunctionConstraintBuilder EnsureDoesNotHaveFunction(this Class entity, string functionName, string returnType, List<ArchAngel.Interfaces.Scripting.NHibernate.Model.ISourceParameter> parameterTypeNames) { FunctionConstraintBuilder cb = new FunctionConstraintBuilder(entity, functionName, new List<string>()) .WithReturnType(returnType) .WithParameterTypes(parameterTypeNames) .RemoveFunction(); return cb; }
public static FunctionConstraintBuilder EnsureDoesNotHaveFunction(this Class entity, string functionName, string returnType, List <ArchAngel.Interfaces.Scripting.NHibernate.Model.ISourceParameter> parameterTypeNames) { FunctionConstraintBuilder cb = new FunctionConstraintBuilder(entity, functionName, new List <string>()) .WithReturnType(returnType) .WithParameterTypes(parameterTypeNames) .RemoveFunction(); return(cb); }
public string Process(ArchAngel.Interfaces.Scripting.NHibernate.Model.IEntity ientity, Dictionary <string, object> TemplateCache, out string CurrentFileName) { Entity entity = (Entity)ientity.ScriptObject; Actions actions = new Actions(); foreach (var att in ientity.MappedClass.SourceAttributesThatMustExist) { entity.MappedClass.EnsureHas() .AttributeNamed(att.Name) .Finish() .ApplyTo(actions); } foreach (var prop in ientity.MappedClass.SourcePropertiesThatMustExist) { string[] modifiers = prop.Modifiers == null ? new string[0] : prop.Modifiers.ToArray(); PropertyConstraintBuilder propertyConstraint = null; propertyConstraint = entity.MappedClass.EnsureHasProperty(prop.Name, prop.PreviousNames ?? new List <string>()) .WithType(prop.Type) .WithModifiers(modifiers) .WithGetAccessorBody(prop.GetAccessor.Body) .WithSetAccessorBody(prop.SetAccessor.Body); if (!string.IsNullOrEmpty(prop.SetAccessor.Modifier)) { propertyConstraint.WithSetAccessorAccessibility(prop.SetAccessor.Modifier); } propertyConstraint.ApplyTo(actions); } foreach (var prop in ientity.MappedClass.SourcePropertiesThatMustNotExist) { PropertyConstraintBuilder propertyConstraint = null; propertyConstraint.ApplyTo(actions); } foreach (var field in ientity.MappedClass.SourceFieldsThatMustExist) { string[] modifiers = field.Modifiers == null ? new string[0] : field.Modifiers.ToArray(); FieldConstraintBuilder fieldConstraint = null; fieldConstraint = entity.MappedClass.EnsureHasField(field.Name, field.PreviousNames ?? new List <string>()) .WithType(field.Type) .WithModifiers(modifiers) .WithInitialValue(field.InitialValue); fieldConstraint.ApplyTo(actions); } foreach (var function in ientity.MappedClass.SourceFunctionsThatMustExist) { string[] modifiers = function.Modifiers == null ? new string[0] : function.Modifiers.ToArray(); FunctionConstraintBuilder functionConstraint = null; functionConstraint = entity.MappedClass.EnsureHasFunction(function.Name, function.PreviousNames ?? new List <string>()) .WithBody(function.Body) .WithModifiers(modifiers) .WithParameterTypes(function.Parameters) .WithReturnType(function.ReturnType); functionConstraint.ApplyTo(actions); } foreach (var function in ientity.MappedClass.SourceFunctionsThatMustNotExist) { FunctionConstraintBuilder functionConstraint = null; functionConstraint.ApplyTo(actions); } // Load the existing C# file up var filename = entity.EntitySet.MappingSet.CodeParseResults.GetFilenameForParsedClass(entity.MappedClass); CurrentFileName = filename; string outputText; if (TemplateCache.ContainsKey(filename) || !System.IO.File.Exists(filename)) { outputText = actions.RunActions((string)TemplateCache[filename], entity.MappedClass.Controller.Root, false); } else { outputText = actions.RunActions(System.IO.File.ReadAllText(filename), entity.MappedClass.Controller.Root, true); } TemplateCache[filename] = outputText; return(outputText); }