当前位置: 首页>>代码示例>>C#>>正文


C# Core.ToObjectType方法代码示例

本文整理汇总了C#中Core.ToObjectType方法的典型用法代码示例。如果您正苦于以下问题:C# Core.ToObjectType方法的具体用法?C# Core.ToObjectType怎么用?C# Core.ToObjectType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core的用法示例。


在下文中一共展示了Core.ToObjectType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteStream

            private static int WriteStream(
                out IntPtr stream_out,
                IntPtr backend,
                UIntPtr length,
                Core.GitObjectType type)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    length.ToUInt64() < long.MaxValue)
                {
                    OdbBackendStream stream;

                    try
                    {
                        int toReturn = odbBackend.WriteStream((long)length.ToUInt64(), objectType, out stream);

                        if (0 == toReturn)
                        {
                            stream_out = stream.GitOdbBackendStreamPointer;
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:36,代码来源:OdbBackend.cs

示例2: Write

            private static unsafe int Write(
                ref GitOid oid,
                IntPtr backend,
                IntPtr data,
                UIntPtr len,
                Core.GitObjectType type)
            {
                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    len.ToUInt64() < long.MaxValue)
                {
                    try
                    {
                        using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)data, (long)len.ToUInt64()))
                        {
                            byte[] finalOid;

                            int toReturn = odbBackend.Write(oid.Id, stream, (long)len.ToUInt64(), objectType, out finalOid);

                            if (0 == toReturn)
                            {
                                oid.Id = finalOid;
                            }

                            return toReturn;
                        }
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:38,代码来源:OdbBackend.cs


注:本文中的Core.ToObjectType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。