private void MapArguments(Arguments arguments, Model.Arguments model, HashSet<string> stackTrace) { if (!string.IsNullOrEmpty(arguments.template)) { if (stackTrace.Contains(arguments.template, StringComparer.InvariantCulture)) throw new TemplateException(string.Format(Strings.XmlTemplateCircularReference, arguments.template)); var template = GetTemplate(arguments.template, TemplateType.Arguments); stackTrace.Add(arguments.template); MapArguments(template.Item, model, stackTrace); } if (arguments.Argument != null) { foreach (var argument in arguments.Argument) model.Add(argument.name, argument.Value); } }
public void AddItem(Model.Cart cart, string productCode, int saleUnitValue, int packagingValue, int quantity, Model.Price salePrice, Model.Price recyclePrice) { quantity = Math.Max(1, quantity); var existing = cart.Items.SingleOrDefault(i => i.ProductCode.Equals(productCode, StringComparison.InvariantCultureIgnoreCase)); if (existing == null) { cart.Add(new Model.CartItem() { ProductCode = productCode, Quantity = quantity, SalePrice = salePrice, SaleUnitValue = saleUnitValue, Packaging = packagingValue, RecyclePrice = recyclePrice ?? new Model.Price(0m,0d), }); } else { existing.Quantity += quantity; } }
public void Generate(IServiceRegistry services, Model model) { if (services == null) throw new ArgumentNullException("services"); if (model == null) throw new ArgumentNullException("model"); var graphicsDevice = services.GetSafeServiceAs<IGraphicsDeviceService>().GraphicsDevice; var data = this.CreatePrimitiveMeshData(); if (data.Vertices.Length == 0) { throw new InvalidOperationException("Invalid GeometricPrimitive [{0}]. Expecting non-zero Vertices array"); } var boundingBox = BoundingBox.Empty; for (int i = 0; i < data.Vertices.Length; i++) BoundingBox.Merge(ref boundingBox, ref data.Vertices[i].Position, out boundingBox); BoundingSphere boundingSphere; unsafe { fixed (void* verticesPtr = data.Vertices) BoundingSphere.FromPoints((IntPtr)verticesPtr, 0, data.Vertices.Length, VertexPositionNormalTexture.Size, out boundingSphere); } var originalLayout = data.Vertices[0].GetLayout(); // Generate Tangent/BiNormal vectors var resultWithTangentBiNormal = VertexHelper.GenerateTangentBinormal(originalLayout, data.Vertices, data.Indices); // Generate Multitexcoords var result = VertexHelper.GenerateMultiTextureCoordinates(resultWithTangentBiNormal); var meshDraw = new MeshDraw(); var layout = result.Layout; var vertexBuffer = result.VertexBuffer; var indices = data.Indices; if (indices.Length < 0xFFFF) { var indicesShort = new ushort[indices.Length]; for (int i = 0; i < indicesShort.Length; i++) { indicesShort[i] = (ushort)indices[i]; } meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indicesShort).RecreateWith(indicesShort), false, indices.Length); } else { if (graphicsDevice.Features.Profile <= GraphicsProfile.Level_9_3) { throw new InvalidOperationException("Cannot generate more than 65535 indices on feature level HW <= 9.3"); } meshDraw.IndexBuffer = new IndexBufferBinding(Buffer.Index.New(graphicsDevice, indices).RecreateWith(indices), true, indices.Length); } meshDraw.VertexBuffers = new[] { new VertexBufferBinding(Buffer.New(graphicsDevice, vertexBuffer, BufferFlags.VertexBuffer).RecreateWith(vertexBuffer), layout, data.Vertices.Length) }; meshDraw.DrawCount = indices.Length; meshDraw.PrimitiveType = PrimitiveType.TriangleList; var mesh = new Mesh { Draw = meshDraw, BoundingBox = boundingBox, BoundingSphere = boundingSphere }; model.BoundingBox = boundingBox; model.BoundingSphere = boundingSphere; model.Add(mesh); if (MaterialInstance != null && MaterialInstance.Material != null) { model.Materials.Add(MaterialInstance); } }
public List<Exception> AddMetadata(string key, object value, Model.Document doc) { JProperty jprop; JsonSerializerSettings settings = new JsonSerializerSettings(); List<Exception> errors = new List<Exception>(); settings.Error += delegate(object sender, ErrorEventArgs args) { if (args.CurrentObject == args.ErrorContext.OriginalObject) errors.Add(args.ErrorContext.Error); }; if (errors.Count > 0) return errors; if (key.StartsWith("$")) { errors.Add(new FormatException("Metadata keys cannot begin with '$'.")); return errors; } jprop = new JProperty(key, value); doc.Add(jprop); return null; }
public Model BuildComparisonObjects(IConnection sourceConnection, IConnection targetConnection) { SqlOption options = BuildOptions(); OnComparisonStarted(EventArgs.Empty); var source = new Generate {ConnectionString = sourceConnection.ConnectionString, Options = options}; source.OnProgress += args => OnFeedbackMessage(new FeedbackEventArgs { Message = args.Message, ProgressPercent = args.Progress*(40/Generate.MaxValue) }); _source = source.Process(); var target = new Generate {ConnectionString = targetConnection.ConnectionString, Options = options}; target.OnProgress += args => OnFeedbackMessage(new FeedbackEventArgs { Message = args.Message, ProgressPercent = 40 + (args.Progress*(40/Generate.MaxValue)) }); _target = target.Process(); OnFeedbackMessage(new FeedbackEventArgs {Message = "Running comparison...", ProgressPercent = 90}); _merged = Generate.Compare((Database) _target.Clone(null), _source); OnFeedbackMessage(new FeedbackEventArgs {Message = "Building Model...", ProgressPercent = 95}); var model = new Model(); _merged.Tables.ForEach( item => model.Add("Table", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Views.ForEach( item => model.Add("View", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Users.ForEach( item => model.Add("User", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.UserTypes.ForEach( item => model.Add("User Type", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.XmlSchemas.ForEach( item => model.Add("XML Schema", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Assemblies.ForEach( item => model.Add("CLR Assemblie", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.CLRFunctions.ForEach( item => model.Add("CLR Function", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.CLRProcedures.ForEach( item => model.Add("CLR Procedure", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.DDLTriggers.ForEach( item => model.Add("DDL Trigger", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Defaults.ForEach( item => model.Add("Default", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.ExtendedProperties.ForEach( item => model.Add("Extended Property", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.FileGroups.ForEach( item => model.Add("File Groups", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Functions.ForEach( item => model.Add("Functions", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.PartitionFunctions.ForEach( item => model.Add("Partition Function", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.PartitionSchemes.ForEach( item => model.Add("Partition Scheme", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Procedures.ForEach( item => model.Add("Stored Procedure", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Roles.ForEach( item => model.Add("Role", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Schemas.ForEach( item => model.Add("Schema", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Synonyms.ForEach( item => model.Add("Synonym", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); OnFeedbackMessage(new FeedbackEventArgs {Message = "Comparison Complete", ProgressPercent = 100}); OnComparisonCompleted(EventArgs.Empty); return model; }
private void MapArguments(EasyNetQ.Management.Client.Model.Arguments arguments, Model.Arguments modelArguments) { foreach (var argument in arguments) modelArguments.Add(argument.Key, argument.Value); }
private static void BuildClassTestModel() { EntityInterface iPerson = GetInterface(); EntityClass parent = new EntityClass(); parent.Name = "Pai"; EntityClass category = new EntityClass(); category.Name = "Category"; category.Visibility = "public"; category.Interfaces.Add(iPerson); category.Parent = parent; EntityField field = new EntityField(); field.Name = "Id"; field.Visibility = "protected"; field.IsPrimaryKey = true; field.Type = new Int(); category.Fields.Add(field); field = new EntityField(); field.Name = "Description"; field.IsRequired = true; field.MaxSize = 500; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); category.Fields.Add(field); category.IsAbstract = true; category.Persistable = true; category.Visibility = "protected"; EntityMethod init = new EntityMethod(); init.Name = "Init"; category.Methods.Add(init); Model list = new Model(); list.Add(category); classes.Model = list; }
private static void BuildSmsTestModel() { EntityField field = null; /** User **/ EntityClass user = new EntityClass(); user.Name = "Principal"; user.Visibility = "public"; field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); user.Fields.Add(field); /** IDescription Definition **/ EntityInterface iDescription = new EntityInterface(); iDescription.Name = "IDescription"; iDescription.Visibility = "public"; EntityMethod getDescription = new EntityMethod(); getDescription.Name = "GetDescription"; EntityParameter param = new EntityParameter(); param.IsReturn = true; param.Type = IntrinsicTypes.Create( "System.String" ); getDescription.ReturnEntity = param; iDescription.Methods.Add(getDescription); /** Category Definition **/ EntityClass category = new EntityClass(); category.Name = "Category"; category.Visibility = "public"; //category.Interfaces.Add(iDescription); field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); category.Fields.Add(field); field = new EntityField(); field.Name = "Description"; field.IsRequired = true; field.MaxSize = 500; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); category.Fields.Add(field); /** Sms Definition **/ EntityClass message = new EntityClass(); message.Name = "SmsBase"; message.IsAbstract = true; message.Visibility = "public"; //message.Interfaces.Add(iDescription); field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); message.Fields.Add(field); field = new EntityField(); field.Name = "Description"; field.IsRequired = true; field.MaxSize = 500; field.Default = "No Description"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); message.Fields.Add(field); field = new EntityField(); field.Name = "Category"; field.Type = category; field.Mult = Multiplicity.ManyToOne; field.IsRequired = true; message.Fields.Add(field); field = new EntityField(); field.Name = "Principal"; field.Type = user; field.Mult = Multiplicity.ManyToOne; field.IsRequired = true; message.Fields.Add(field); field = new EntityField(); field.Name = "Messages"; field.Type = message; field.Mult = Multiplicity.OneToMany; field.InfoOnly = true; user.Fields.Add(field); field = new EntityField(); field.Name = "Messages"; field.Type = message; field.InfoOnly = true; field.Mult = Multiplicity.OneToMany; category.Fields.Add(field); /** ImageSms **/ EntityClass imageSms = new EntityClass(); imageSms.Name = "ImageSms"; imageSms.Visibility = "public"; imageSms.Parent = message; field = new EntityField(); field.Name = "ImageUrl"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); field.IsRequired = true; field.Default = "#"; imageSms.Fields.Add(field); /** TextSms **/ EntityClass textSms = new EntityClass(); textSms.Name = "TextSms"; textSms.Visibility = "public"; textSms.Parent = message; field = new EntityField(); field.Name = "Text"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); field.IsRequired = true; field.Default = "Empty"; textSms.Fields.Add(field); /** Setting up project **/ Model list = new Model(); list.Add(category); list.Add(iDescription); list.Add(user); list.Add(message); list.Add(imageSms); list.Add(textSms); smsTestModel.Model = list; }
private static void BuildInterfaceTestModel() { EntityInterface iPerson = GetInterface(); Model list = new Model(); list.Add(iPerson); interfaces.Model = list; }