Пример #1
0
        public static void ParseRDPSetOtherMode(F3DEX2Command cmd,
                                                out PipelineMode pm, out CycleType cyc, out TexturePersp tp, out TextureDetail td, out TextureLOD tl,
                                                out TextureLUT tt, out TextureFilter tf, out TextureConvert tc, out CombineKey ck, out ColorDither cd,
                                                out AlphaDither ad, out AlphaCompare ac, out DepthSource zs, out RenderMode rm)
        {
            rm = new RenderMode(cmd.Words & (0xFFFFFFFF & ~((ulong)AlphaCompare.Mask | (ulong)DepthSource.Mask)));

            if (!rm.Known) // Handle TCL modes by checking again with alpha compare and dither included
            {
                rm = new RenderMode(cmd.Words & (0xFFFFFFFF & ~(ulong)DepthSource.Mask));
            }

            ulong wordH = cmd.Words >> 32;

            ad  = (AlphaDither)(wordH & (ulong)AlphaDither.Mask);
            cd  = (ColorDither)(wordH & (ulong)ColorDither.Mask);
            ck  = (CombineKey)(wordH & (ulong)CombineKey.Mask);
            pm  = (PipelineMode)(wordH & (ulong)PipelineMode.Mask);
            cyc = (CycleType)(wordH & (ulong)CycleType.Mask);
            tp  = (TexturePersp)(wordH & (ulong)TexturePersp.Mask);
            td  = (TextureDetail)(wordH & (ulong)TextureDetail.Mask);
            tl  = (TextureLOD)(wordH & (ulong)TextureLOD.Mask);
            tt  = (TextureLUT)(wordH & (ulong)TextureLUT.Mask);
            tf  = (TextureFilter)(wordH & (ulong)TextureFilter.Mask);
            tc  = (TextureConvert)(wordH & (ulong)TextureConvert.Mask);

            ac = (AlphaCompare)(cmd.Words & (ulong)AlphaCompare.Mask);
            zs = (DepthSource)(cmd.Words & (ulong)DepthSource.Mask);
        }
Пример #2
0
 /// <summary>
 /// Creates a new ArgPipeline instance
 /// </summary>
 public ArgPipeline()
 {
     // We want to be the last thing that executes before the parser runs
     this.BeforeParsePriority         = 0;
     CommandLineDefinitionFactoryType = typeof(ArgumentScaffoldTypeCommandLineDefinitionFactory);
     this.Mode = PipelineMode.SerializedStages;
 }
Пример #3
0
        /// <summary>
        /// Sets indexes according to mesh pattern.
        /// IMPORTANT: Make sure there's enough vertices for width and height of the mesh.
        /// </summary>
        /// <param name="w">Width of the mesh.</param>
        /// <param name="h">Height of the mesh.</param>
        public static void PrimitiveSetMeshIndices(int w, int h)
        {
            // 0 - 1 - 2
            // | / | / |
            // 3 - 4 - 5
            // | / | / |
            // 6 - 7 - 8

            _primitiveType = PipelineMode.TrianglePrimitives;

            var offset = 0;             // Basically, equals w * y.

            for (var y = 0; y < h - 1; y += 1)
            {
                for (var x = 0; x < w - 1; x += 1)
                {
                    _primitiveIndices.Add((short)(x + offset));
                    _primitiveIndices.Add((short)(x + 1 + offset));
                    _primitiveIndices.Add((short)(x + w + offset));

                    _primitiveIndices.Add((short)(x + w + offset));
                    _primitiveIndices.Add((short)(x + w + 1 + offset));
                    _primitiveIndices.Add((short)(x + 1 + offset));
                }
                offset += w;
            }
        }
Пример #4
0
        /// <summary>
        /// Switches graphics pipeline mode.
        /// </summary>
        /// <param name="mode"></param>
        private static void SwitchPipelineMode(PipelineMode mode, Texture2D texture)
        {
            if (mode != _currentPipelineMode || texture != _currentTexture)
            {
                if (_currentPipelineMode != PipelineMode.None)
                {
                    if (_currentPipelineMode == PipelineMode.Sprites)
                    {
                        Batch.End();
                    }
                    else
                    {
                        DrawVertices();
                    }
                }

                if (mode == PipelineMode.Sprites)
                {
                    Device.ScissorRectangle = _scissorRectangle;

                    Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, _sampler, null, _rasterizer, null, CurrentTransformMatrix);
                }
                _currentPipelineMode = mode;
                _currentTexture      = texture;
            }
        }
Пример #5
0
        public NullSinkStream(Stream myInnerStream, PipelineMode mode)
        {
            operationMode = mode;

            this.innerStream   = myInnerStream;
            length             = 0;
            this.BlockMetadata = new List <IFileBlockMetadata>();
        }
        internal ArgPipelineManager(PipelineMode mode)
        {
            this.Mode          = mode;
            _stages            = new List <PipelineStage>();
            asyncExceptions    = new List <Exception>();
            asyncExceptionLock = new object();

            if (Mode == PipelineMode.SerializedStages)
            {
                serializedStageInput = new Dictionary <PipelineStage, Queue <object> >();
            }
        }
Пример #7
0
        internal ArgPipelineManager(PipelineMode mode)
        {
            this.Mode = mode;
            _stages = new List<PipelineStage>();
            asyncExceptions = new List<Exception>();
            asyncExceptionLock = new object();

            if(Mode == PipelineMode.SerializedStages)
            {
                serializedStageInput = new Dictionary<PipelineStage, Queue<object>>();
            }
        }
Пример #8
0
        /// <summary>
        /// Sets indexes according to trianglestrip pattern.
        /// </summary>
        public static void PrimitiveSetTriangleStripIndices()
        {
            // 0 - 2 - 4
            //  \ / \ /
            //   1 - 3

            _primitiveType = PipelineMode.TrianglePrimitives;

            for (var i = 0; i < _primitiveVertices.Count - 2; i += 1)
            {
                _primitiveIndices.Add((short)i);
                _primitiveIndices.Add((short)(i + 1));
                _primitiveIndices.Add((short)(i + 2));
            }
        }
Пример #9
0
        /// <summary>
        /// Sets indexes according to line strip pattern.
        /// </summary>
        /// <param name="loop">Tells is first and last vertix will have a line between them.</param>
        public static void PrimitiveSetLineStripIndices(bool loop)
        {
            // 0 - 1 - 2 - 3

            _primitiveType = PipelineMode.OutlinePrimitives;

            for (var i = 0; i < _primitiveVertices.Count - 1; i += 1)
            {
                _primitiveIndices.Add((short)i);
                _primitiveIndices.Add((short)(i + 1));
            }
            if (loop)
            {
                _primitiveIndices.Add((short)(_primitiveVertices.Count - 1));
                _primitiveIndices.Add(0);
            }
        }
Пример #10
0
        /// <summary>
        /// Sets indexes according to trianglefan pattern.
        /// </summary>
        public static void PrimitiveSetTriangleFanIndices()
        {
            //   1
            //  / \
            // 0 - 2
            //  \ /
            //   3

            _primitiveType = PipelineMode.TrianglePrimitives;

            for (var i = 0; i < _primitiveVertices.Count - 1; i += 1)
            {
                _primitiveIndices.Add(0);
                _primitiveIndices.Add((short)i);
                _primitiveIndices.Add((short)(i + 1));
            }
        }
Пример #11
0
        /// <summary>
        /// Adds vertices and indices to global vertex and index list.
        /// If current and suggested pipeline modes are different, draws accumulated vertices first.
        /// </summary>
        /// <param name="mode">Suggested pipeline mode.</param>
        /// <param name="vertices">List of vertices.</param>
        /// <param name="indices">List of indices.</param>
        private static void AddVertices(PipelineMode mode, Texture2D texture, List <VertexPositionColorTexture> vertices, short[] indices)
        {
            if (_indices.Count + indices.Length >= BUFFER_SIZE)
            {
                DrawVertices();                 // If buffer overflows, we need to empty it.
            }

            SwitchPipelineMode(mode, texture);

            short[] indexesCopy = new short[indices.Length];
            Array.Copy(indices, indexesCopy, indices.Length);             // We must copy an array to prevent modifying original.

            for (var i = 0; i < indices.Length; i += 1)
            {
                indexesCopy[i] += (short)_vertices.Count;                 // We need to offset each index because of single buffer for everything.
            }

            _vertices.AddRange(vertices);
            _indices.AddRange(indexesCopy);
        }
Пример #12
0
        // Text.


        /// <summary>
        /// Initialization function for draw controller.
        /// Should be called only once, by Game class.
        /// </summary>
        /// <param name="device">Graphics device.</param>
        public static void Init(GraphicsDevice device)
        {
            Device = device;

            Batch       = new SpriteBatch(Device);
            Cameras     = new List <Camera>();
            BasicEffect = new BasicEffect(Device);
            BasicEffect.VertexColorEnabled = true;
            Device.DepthStencilState       = DepthStencilState.DepthRead;

            _vertexBuffer = new DynamicVertexBuffer(Device, typeof(VertexPositionColorTexture), BUFFER_SIZE, BufferUsage.WriteOnly);
            _indexBuffer  = new DynamicIndexBuffer(Device, IndexElementSize.SixteenBits, BUFFER_SIZE, BufferUsage.WriteOnly);
            _vertices     = new List <VertexPositionColorTexture>();
            _indices      = new List <short>();

            _currentPipelineMode = PipelineMode.None;
            _currentTexture      = null;

            Device.SetVertexBuffer(_vertexBuffer);
            Device.Indices = _indexBuffer;

            _primitiveVertices = new List <VertexPositionColorTexture>();
            _primitiveIndices  = new List <short>();
            _primitiveTexture  = null;

            _surfaceStack   = new Stack <RenderTarget2D>();
            _currentSurface = null;

            CurrentColor        = Color.White;
            CircleVerticesCount = 16;

            _transformMatrixStack = new Stack <Matrix>();

            HorAlign = TextAlign.Left;
            VerAlign = TextAlign.Top;
        }
Пример #13
0
 internal DataPipeline(PipelineMode mode, DataProcessingFlags flags)
 {
     this.Flags = flags;
     this.Mode  = mode;
 }
Пример #14
0
 public MsSqlEntityPipeline(string connectString, PipelineMode mode = PipelineMode.Insert) : base(connectString, mode)
 {
 }
        protected EntityGeneralPipeline(Schema schema, Entity entityDefine, string connectString, PipelineMode mode = PipelineMode.Insert)
        {
            Mode          = mode;
            ConnectString = connectString;

            Schema  = GenerateSchema(schema);
            Columns = entityDefine.Fields.Where(f => f.DataType != null).ToList();
            var primary = entityDefine.Primary;

            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (mode == PipelineMode.Update && entityDefine.Updates != null)
            {
                foreach (var column in entityDefine.Updates)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == column);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as update is not a property of your entity.");
                    }
                    else
                    {
                        UpdateColumns.Add(col);
                    }
                }
                if (UpdateColumns == null || UpdateColumns.Count == 0)
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));
                }
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderExceptoin("Do you forget set the Primary in IndexesAttribute for your entity class.");
                }
            }

            AutoIncrement = entityDefine.AutoIncrement;

            if (entityDefine.Indexes != null)
            {
                foreach (var index in entityDefine.Indexes)
                {
                    List <string> tmpIndex = new List <string>();
                    foreach (var i in index)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as index is not a property of your entity.");
                        }
                        else
                        {
                            tmpIndex.Add(col.Name);
                        }
                    }
                    if (tmpIndex.Count != 0)
                    {
                        Indexs.Add(tmpIndex);
                    }
                }
            }
            if (entityDefine.Uniques != null)
            {
                foreach (var unique in entityDefine.Uniques)
                {
                    List <string> tmpUnique = new List <string>();
                    foreach (var i in unique)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as unique is not a property of your entity.");
                        }
                        else
                        {
                            tmpUnique.Add(col.Name);
                        }
                    }
                    if (tmpUnique.Count != 0)
                    {
                        Uniques.Add(tmpUnique);
                    }
                }
            }
        }
 protected BaseEntityDbPipeline(string connectString, PipelineMode mode = PipelineMode.Insert, bool checkIfSaveBeforeUpdate = false)
 {
     Mode                    = mode;
     ConnectString           = connectString;
     CheckIfSameBeforeUpdate = checkIfSaveBeforeUpdate;
 }
Пример #17
0
 protected BaseEntityDbPipeline(string connectString, PipelineMode mode = PipelineMode.Insert)
 {
     Mode          = mode;
     ConnectString = connectString;
 }
Пример #18
0
 protected override DbEntityPipeline CreatePipeline(PipelineMode pipelineMode = PipelineMode.InsertAndIgnoreDuplicate)
 {
     return(new SqlServerEntityPipeline(DefaultConnectionString, pipelineMode));
 }
Пример #19
0
 public EntityMySqlPipeline(Schema schema, EntityMetadata entityDefine, string connectString, PipelineMode mode)
     : base(schema, entityDefine, connectString, mode)
 {
 }
Пример #20
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="connectString">数据库连接字符串, 如果为空框架会尝试从配置文件中读取</param>
 /// <param name="pipelineMode">数据管道模式</param>
 public SqlServerEntityPipeline(string connectString = null, PipelineMode pipelineMode = PipelineMode.InsertAndIgnoreDuplicate) : base(connectString, pipelineMode)
 {
 }
Пример #21
0
        protected EntityGeneralPipeline(Schema schema, JObject entityDefine, string connectString, PipelineMode mode = PipelineMode.Insert)
        {
            Mode          = mode;
            ConnectString = connectString;

            Schema  = GenerateSchema(schema);
            Columns = entityDefine.SelectTokens("$.Fields[*]").Select(j => j.ToObject <Column>()).Where(c => !string.IsNullOrEmpty(c.DataType)).ToList();
            var primary = entityDefine.SelectToken("$.Primary")?.ToObject <List <string> >();

            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (mode == PipelineMode.Update)
            {
                var tmpUpdateColumns = entityDefine.SelectTokens("$.Update[*]").Select(u => u.ToString()).ToList();
                foreach (var column in tmpUpdateColumns)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == column);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as update is not a property of your entity.");
                    }
                    else
                    {
                        UpdateColumns.Add(col);
                    }
                }
                if (UpdateColumns == null || UpdateColumns.Count == 0)
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));
                }
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderExceptoin("Do you forget set the Primary in IndexesAttribute for your entity class.");
                }
            }

            AutoIncrement = entityDefine.SelectToken("$.AutoIncrement")?.ToString();

            foreach (var index in entityDefine.SelectTokens("$.Indexs[*]"))
            {
                List <string> tmpIndex = new List <string>();
                foreach (var i in index.ToObject <List <string> >())
                {
                    var col = Columns.FirstOrDefault(c => c.Name == i);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as index is not a property of your entity.");
                    }
                    else
                    {
                        tmpIndex.Add(col.Name);
                    }
                }
                if (tmpIndex.Count != 0)
                {
                    Indexs.Add(tmpIndex);
                }
            }

            foreach (var unique in entityDefine.SelectTokens("$.Uniques[*]"))
            {
                List <string> tmpUnique = new List <string>();
                foreach (var i in unique.ToObject <List <string> >())
                {
                    var col = Columns.FirstOrDefault(c => c.Name == i);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as unique is not a property of your entity.");
                    }
                    else
                    {
                        tmpUnique.Add(col.Name);
                    }
                }
                if (tmpUnique.Count != 0)
                {
                    Uniques.Add(tmpUnique);
                }
            }
        }
 protected virtual DbModelPipeline CreatePipeline(PipelineMode pipelineMode = PipelineMode.InsertAndIgnoreDuplicate)
 {
     return(new MySqlEntityPipeline(DefaultConnectionString, pipelineMode));
 }
Пример #23
0
 protected DbEntityPipeline(string connectString = null, PipelineMode pipelineMode = PipelineMode.InsertAndIgnoreDuplicate)
 {
     ConnectString = connectString;
     PipelineMode  = pipelineMode;
 }
Пример #24
0
 internal DataPipeline(PipelineMode mode, DataProcessingFlags flags, int bsId, DedupIndex ddidx) : this(mode, flags)
 {
     this.bsId = bsId;
     ddb       = ddidx;
 }
Пример #25
0
        /// <summary>
        /// Performs Draw events for all objects.
        /// </summary>
        public static void Update(GameTime gameTime)
        {
            __drawcalls = 0;

            var depthSortedObjects = Objects.GameObjects.OrderByDescending(o => o.Depth);


            // Main draw events.
            foreach (Camera camera in Cameras)
            {
                if (camera.Enabled)
                {
                    // Updating current transform matrix and camera.
                    camera.UpdateTransformMatrix();
                    CurrentCamera          = camera;
                    CurrentTransformMatrix = camera.TransformMatrix;
                    BasicEffect.View       = camera.TransformMatrix;
                    BasicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, camera.W, camera.H, 0, 0, 1);
                    // Updating current transform matrix and camera.

                    Input.UpdateMouseWorldPosition();

                    SetSurfaceTarget(camera.ViewSurface, camera.TransformMatrix);

                    if (camera.ClearBackground)
                    {
                        Device.Clear(camera.BackgroundColor);
                    }

                    foreach (GameObj obj in depthSortedObjects)
                    {
                        if (obj.Active)
                        {
                            obj.DrawBegin();
                        }
                    }

                    foreach (GameObj obj in depthSortedObjects)
                    {
                        if (obj.Active)
                        {
                            obj.Draw();
                        }
                    }

                    foreach (GameObj obj in depthSortedObjects)
                    {
                        if (obj.Active)
                        {
                            obj.DrawEnd();
                        }
                    }

                    ResetSurfaceTarget();
                }
            }
            // Main draw events.



            // Scales display to match canvas, but keeps aspect ratio.
            var windowManager = GameCntrl.WindowManager;

            var backbufferSize = new Vector2(
                windowManager.PreferredBackBufferWidth,
                windowManager.PreferredBackBufferHeight
                );
            float ratio,
                  offsetX = 0,
                  offsetY = 0;

            float backbufferRatio = windowManager.PreferredBackBufferWidth / (float)windowManager.PreferredBackBufferHeight;
            float canvasRatio     = windowManager.CanvasWidth / windowManager.CanvasHeight;

            if (canvasRatio > backbufferRatio)
            {
                ratio   = windowManager.PreferredBackBufferWidth / (float)windowManager.CanvasWidth;
                offsetY = (windowManager.PreferredBackBufferHeight - (windowManager.CanvasHeight * ratio)) / 2;
            }
            else
            {
                ratio   = windowManager.PreferredBackBufferHeight / (float)windowManager.CanvasHeight;
                offsetX = (windowManager.PreferredBackBufferWidth - (windowManager.CanvasWidth * ratio)) / 2;
            }

            CanvasMatrix = Matrix.CreateScale(new Vector3(ratio, ratio, 1)) * Matrix.CreateTranslation(new Vector3(offsetX, offsetY, 0));
            // Scales display to match canvas, but keeps aspect ratio.



            // Resetting camera and transform matrix.
            CurrentCamera          = null;
            CurrentTransformMatrix = CanvasMatrix;                                                                                                                    //Matrix.CreateTranslation(0, 0, 0);
            BasicEffect.View       = CurrentTransformMatrix;
            BasicEffect.Projection = Matrix.CreateOrthographicOffCenter(0, windowManager.PreferredBackBufferWidth, windowManager.PreferredBackBufferHeight, 0, 0, 1); // TODO: Set actual backbuffer size here.
            // Resetting camera and transform matrix.


            // Drawing camera surfaces.
            Device.Clear(Color.TransparentBlack);

            Batch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, CurrentTransformMatrix);
            foreach (Camera camera in Cameras)
            {
                if (camera.Autodraw && camera.Enabled)
                {
                    Batch.Draw(camera.ViewSurface, new Vector2(camera.PortX, camera.PortY), Color.White);
                }
            }
            Batch.End();
            // Drawing camera surfaces.


            // Drawing GUI stuff.
            _currentPipelineMode = PipelineMode.None;

            foreach (GameObj obj in depthSortedObjects)
            {
                if (obj.Active)
                {
                    obj.DrawGUI();
                }
            }

            if (_currentPipelineMode == PipelineMode.Sprites)             // If there's something left in batch or vertex buffer, we should draw it.
            {
                Batch.End();
            }
            DrawVertices();
            // Drawing GUI stuff.


            _currentPipelineMode = PipelineMode.None;

            // Safety checks.
            if (_surfaceStack.Count != 0)
            {
                throw(new InvalidOperationException("Unbalanced surface stack! Did you forgot to reset a surface somewhere?"));
            }

            if (_transformMatrixStack.Count != 0)
            {
                throw(new InvalidOperationException("Unbalanced matrix stack! Did you forgot to reset a matrix somewhere?"));
            }
            // Safety checks.

            //Debug.WriteLine("CALLS: " + __drawcalls);
        }
Пример #26
0
        internal DataPipeline_(PipelineMode mode, Session s, Backup b, DataProcessingFlags flags)
        {
            backup = b;

            storageSession = s;
            BinaryFormatter formatter = new BinaryFormatter();
            BChunkHeader    header    = new BChunkHeader();

            header.DataFlags = flags;

            header.Version = Utilities.PlatForm.Instance().NodeVersion;
            //header.TaskId = taskId;
            header.TaskId = b.TaskId;

            // end-of-chain stream
            sessionStream = new NetworkStream(storageSession.DataSocket);

            this.Flags = flags;
#if DEBUG
            if (ConfigManager.GetValue("BENCHMARK") != null)
            {
                sessionStream = new DummyStream();
            }
#endif
            if (flags.HasFlag(DataProcessingFlags.CChecksum))
            {
                finalStream = new NullSinkStream(new ChunkHasherStream(sessionStream), mode);
            }
            else
            {
                finalStream = new NullSinkStream(sessionStream, mode);                // dummy dest stream
            }
            //firstStream = new NullSinkStream(); // test and benchmarking

            // top-of-chain streams
            firstStream = finalStream;
            if (flags.HasFlag(DataProcessingFlags.CEncrypt))
            {
                EncryptorStream encStream = new EncryptorStream(firstStream, true, null);
                header.EncryptionMetaData = encStream.EncryptionMetadata;

                // TODO !! take encryptionMetadata and add it to index
                firstStream = encStream;
            }
            if (flags.HasFlag(DataProcessingFlags.CCompress))
            {
                //firstStream = new CompressorStream(firstStream, CompressorAlgorithm.Lzo, 1024);
                firstStream = new GZCompressorStream(firstStream, System.IO.Compression.CompressionMode.Compress);
            }
            if (flags.HasFlag(DataProcessingFlags.CDedup))
            {
                cdds = new ClientDeduplicatorStream(firstStream, s.ClientId);

                /*try{ // TODO ! remove cksum provider selection from here, find a more elegant solution
                 *      firstStream = new ChecksummerStream_MHash((ClientDeduplicatorStream)cdds);
                 * }
                 * catch(Exception e){*/
                firstStream = new ChecksummerStream((ClientDeduplicatorStream)cdds);
                //firstStream = new TigerTreeHasherStream((ClientDeduplicatorStream)cdds);

                /*}*/
                // Pre-Initialize dedup index (if needed)
                DedupIndex.Instance().Initialize();
            }
            MemoryStream headerStream = new MemoryStream();
            formatter.Serialize(headerStream, header);
            headerData = headerStream.ToArray();
            Logger.Append(Severity.INFO, "Created data pipeline with flags " + flags.ToString());
            //privilegesManager = new Utilities.PrivilegesManager();
        }
Пример #27
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="connectString">数据库连接字符串, 如果为空框架会尝试从配置文件中读取</param>
 /// <param name="pipelineMode">数据管道模式</param>
 public SqlServerEntityPipeline(string connectString = null, PipelineMode pipelineMode = PipelineMode.Insert) : base(connectString, pipelineMode)
 {
 }
        protected EntityGeneralPipeline(Schema schema, EntityMetadata entityDefine, string connectString, PipelineMode mode = PipelineMode.Insert)
        {
            Mode = mode;
            ConnectString = connectString;

            Schema = GenerateSchema(schema);
            foreach (var f in entityDefine.Entity.Fields)
            {
                if (!string.IsNullOrEmpty(((Field) f).DataType))
                {
                    Columns.Add((Field)f);
                }
            }
            var primary = entityDefine.Primary;
            if (primary != null)
            {
                foreach (var p in primary)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == p);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as primary is not a property of your entity.");
                    }
                    else
                    {
                        Primary.Add(col);
                    }
                }
            }

            if (mode == PipelineMode.Update && entityDefine.Updates != null)
            {
                foreach (var column in entityDefine.Updates)
                {
                    var col = Columns.FirstOrDefault(c => c.Name == column);
                    if (col == null)
                    {
                        throw new SpiderExceptoin("Columns set as update is not a property of your entity.");
                    }
                    else
                    {
                        UpdateColumns.Add(col);
                    }
                }
                if (UpdateColumns == null || UpdateColumns.Count == 0)
                {
                    UpdateColumns = Columns;
                    UpdateColumns.RemoveAll(c => Primary.Contains(c));
                }
                if (Primary == null || Primary.Count == 0)
                {
                    throw new SpiderExceptoin("Do you forget set the Primary in IndexesAttribute for your entity class.");
                }
            }

            AutoIncrement = entityDefine.AutoIncrement;

            if (entityDefine.Indexes != null)
            {
                foreach (var index in entityDefine.Indexes)
                {
                    List<string> tmpIndex = new List<string>();
                    foreach (var i in index)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as index is not a property of your entity.");
                        }
                        else
                        {
                            tmpIndex.Add(col.Name);
                        }
                    }
                    if (tmpIndex.Count != 0)
                    {
                        Indexs.Add(tmpIndex);
                    }
                }
            }
            if (entityDefine.Uniques != null)
            {
                foreach (var unique in entityDefine.Uniques)
                {
                    List<string> tmpUnique = new List<string>();
                    foreach (var i in unique)
                    {
                        var col = Columns.FirstOrDefault(c => c.Name == i);
                        if (col == null)
                        {
                            throw new SpiderExceptoin("Columns set as unique is not a property of your entity.");
                        }
                        else
                        {
                            tmpUnique.Add(col.Name);
                        }
                    }
                    if (tmpUnique.Count != 0)
                    {
                        Uniques.Add(tmpUnique);
                    }
                }
            }
        }
Пример #29
0
 /// <summary>
 /// Sets user-defined list of indices for list of lines.
 /// </summary>
 /// <param name="indices">List of indices.</param>
 public static void PrimitiveSetCustomLineIndices(List <short> indices)
 {
     _primitiveType    = PipelineMode.OutlinePrimitives;
     _primitiveIndices = indices;
 }
Пример #30
0
 public EntityMySqlPipeline(Schema schema, EntityMetadata entityDefine, string connectString, PipelineMode mode) : base(schema, entityDefine, connectString, mode)
 {
 }
Пример #31
0
 /// <summary>
 /// Sets user-defined array of indices for list of triangles.
 /// </summary>
 /// <param name="indices">Array of indices.</param>
 public static void PrimitiveSetCustomTriangleIndices(short[] indices)
 {
     _primitiveType    = PipelineMode.TrianglePrimitives;
     _primitiveIndices = indices.ToList();
 }
Пример #32
0
 public MySqlEntityPipeline(string connectString, PipelineMode mode = PipelineMode.Insert, bool checkIfSaveBeforeUpdate = false) : base(connectString, mode, checkIfSaveBeforeUpdate)
 {
 }
Пример #33
0
 /// <summary>
 /// Sets user-defined list of indices for list of triangles.
 /// </summary>
 /// <param name="indices">List of indices.</param>
 public static void PrimitiveSetCustomTriangleIndices(List <short> indices)
 {
     _primitiveType    = PipelineMode.TrianglePrimitives;
     _primitiveIndices = indices;
 }